Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
2.2k views
in Q2A Core by
In my site, very few people register--it's sort of "public asks, experts answer", so most questions are anonymous. Sort of an FAQ/knowledge base. So with the Snow theme I moved the login bar to the bottom of the page, since it is not relevant to most users. But this also puts the search box where few will see it. It would be better in the sidebar. I don't really understand PHP very well so I dont know what to do with the advanced theme. How would I tell it to put the search box in the sidebar, or, alternatively, plug some HTML into the sidebar text widget (what would that HTML look like?). thanks a bunch for any help.
Q2A version: 1.5.3

1 Answer

+4 votes
by

 

Add the following as is to Your /qa-theme.php in your snow folder.
 
In the first function //$this->search(); indicates that the search will not appear, and in the second function $this->search(); indicates that it has to appear. I f You want it somewhere else in the sidepanel and not in the sidebar (what is nothing else then the welcome box), you can copy from qa-include/qa-theme-base.php the sidepanel function to your advanced theme qa-theme.php and add the search instruction there.
 
function nav_user_search()
{
$this->nav('user');
//$this->search();
}
 
function sidebar()
{
$sidebar=@$this->content['sidebar'];
 
if (!empty($sidebar)) {
$this->output('<DIV CLASS="qa-sidebar">');
$this->search();
$this->output_raw($sidebar);
$this->output('</DIV>', '');
}
}

 

by
Thanks for your help. Based on what you wrote I was able to edit the qa-theme.php file and get the search box to show up in the sidebar to my satisfaction. I could not figure out how to remove the search box from the login bar without wiping out the login form as well, but it's not a problem to have it in two places on the page.
by
I am late with a comment. But it should work well.

The function nav_user_search combines the user menu (login form) with the search box. In the code here the search function is "turned off" using // in front of it. Make sure that $this->nav('user'); does not have two slashes . if it still does not work I wil check again, pls let me know...

function nav_user_search()
{
$this->nav('user');
//$this->search();
}
by
Thank you, but I don't know how to use it. There is already a long "function nav_user_search" statement in Snow's qa_theme.php file, and I don't understand how to combine this one with it... I tried simply preceding it with this and the site became inaccessible.
by
I will downoad it and look into it. Please wait.
by
OK

Replace in SNOW qa-theme.php function nav_user_search() the line

qa_html_theme_base::nav_user_search();

with

$this->nav('user');

Thats all

________________________________________________________

Explanation:

The line qa_html_theme_base::nav_user_search(); does load the original function from qa-theme-base.php
We are replacing the line with all that what is left of this original function.

The original function was :
function nav_user_search()
        {
            $this->nav('user');
            $this->search();
        }
but we only need the first part  $this->nav('user');

I hope it works now.

The function in SNWO qa-theme.php shpoud ook ike that:

function nav_user_search() // outputs login form if user not logged in
        {
            if (!qa_is_logged_in()) {
                $login=@$this->content['navigation']['user']['login'];
               
                if (isset($login)) {
                    $this->output(
                        '<!--[Begin: login form]-->',               
                        '<form id="qa-loginform" action="'.$login['url'].'" method="post">',
                            '<input type="text" id="qa-userid" name="emailhandle" placeholder="'.trim(qa_lang_html('users/email_handle_label'), ':').'" />',
                            '<input type="password" id="qa-password" name="password" placeholder="'.trim(qa_lang_html('users/password_label'), ':').'" />',
                            '<div id="qa-rememberbox"><input type="checkbox" name="rememberme" id="qa-rememberme" />',
                            '<label for="rememberme" id="qa-remember">'.qa_lang_html('users/remember').'</label></div>',
                            '<input type="submit" value="'.$login['label'].'" id="qa-login" name="dologin" />',
                        '</form>',               
                        '<!--[End: login form]-->'
                    );
                   
                    unset($this->content['navigation']['user']['login']); // removes regular navigation link to log in page
                }
            }
           
            $this->nav('user');
        }
by
It worked, thanks so much. I now have the search box where I want it, and it is no longer where I don't need it to be. Perfect.
...