Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
1.9k views
in Themes by
Hello All,

I want add ''something'' in my case ads code on sidepanel, but just on question page, when now add on sidepanel this show on whole pages home,tags,hot ... i need just on question page ?

Thanks,

:)
by
What do you mean by "case ads code on sidepanel"? A screenshot might help. Also pasting the code you're using right now (and mentioning in which file it is) would help understand what you're trying to do
by
ads code e.g. adsense ads code i want add just on question page, when i use admin panel and add on sidepanel they add on whole pages home,hot,tags ... i need this show only on question page, i guess i need edit question page file, but don't know which file ? i can't add here adsense code this is against adsense rules :)
by
edited by
Adsense is not part of the core. You must have configured that by means of a plugin. Which plugin are you using? Actually, I just need to see the code and see what the plugin is doing so if you can link to a github page that would be the best
by
edited by
sidepanel, question page, on question page we have sidepanel there i want add code, i don't know where i can edit this, where i edit sidepanel for question page ?

Thanks.

1 Answer

+1 vote
by
edited by

I don't understand by something add but I believe you want to show some content on only question page (Question View) if that is the case than use below code.

Wrap your code with the condition below

if ( $this->template === 'question')
{
    //put yoru code for something here
}

EDIT: With more detail

In your theme file qa-theme/your-theme-dir/qa-theme.php cross check if there is sidepanel() function already placed. Add/Update the code below

function sidepanel()
{    
    if ( $this->template === 'question' )
    {
        //add your code here
    }

    qa_html_theme_base::sidepanel();
}
by
where i add this ? i need add this in sidepanel only on question page ?

Thanks.
by
See my edited answer...
by
I add like this:

        function sidepanel()
        {
            $this->output('<div class="qa-sidepanel">');
           
           
            if ( $this->template === 'question' )
    {
       <div>something</div>
    }
           
            $this->widgets('side', 'top');
            $this->sidebar();
            $this->widgets('side', 'high');
            $this->nav('cat', 1);
            $this->widgets('side', 'low');
            $this->output_raw(@$this->content['sidepanel']);
            $this->feed();
            $this->widgets('side', 'bottom');
            $this->output('</div>', '');
        }

and show me error when i try open website ?

Thanks.
by
Post the error message...Where you added this function? In your theme file?
by
Parse error: syntax error, unexpected '<' in /localhost/qa/qa-include/qa-theme-base.php on line 584
by
Hai Ivan Simic,
please check your html script and also write this code in your theme's qa-theme.php and do not edit on qa-theme-base.php
by
i can't found qa-theme.php i only have qa-theme-base.php, and when i edit qa-theme-base.php this solution don't work
by
which theme you are currently using , if you are using q2a's Classic theme

go to question2answer directory and
qa-theme-> Classic-> seek qa-theme.php file

open and edit the above code.
by
The error says you have unexpected '<' in your theme file. You may by mistake added this one. Look in to your theme file.
by
> i can't found qa-theme.php
>> You need to look into your theme directory.
by
qa-theme - classic there not exsist qa-theme.php
by
i make qa-theme.php and add this code, again not work, but never mind i found this plugin https://github.com/svivian/q2a-widget-anywhere this fix all problem :) thanks all for help ;)
...