Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
329 views
in Q2A Core by
edited

I want to see categories only on hom epage. How can I do it?

However I found an answer to a similar question as follows but I dont know exactly how to implement it.

You can do this with a custom theme, using a nested CSS selector which looks for the qa-nav-cat class within the appropriate qa-template-... class. You can see the qa-template-... class inside the <BODY> tag of each page.

Anyone with a bit more detailed answer?

1 Answer

+1 vote
by

 

That depends on which page is Your home page.
Look into Your homepage sourcecode in Your browser for qa-template.....
 
If it is qa-template-qa ........ add the following to Your css file after the normal .qa-nav-cat{......}
 
.qa-nav-cat {display:none;}
.qa-template-qa .qa-nav-cat {display:block;}
 
Thats all
 
_______________________
 
Explanation: The first instruction says not to display the categories, the second one says display the categories if You are on a page with .qa-template-qa
 
.qa-template-qa .qa-nav-cat {display:block;} is a nested class or a class in a class...
by
edited by
Thanks a lot for answering my question.

In my home page source I find this: CLASS="qa-template-qa qa-body-js-off". So after .qa-nav-cat{......}  I added as follows in the CSS file:
.qa-nav-cat {display:none;}
.qa-template-qa .qa-nav-cat {display:block;}

Now the category list is no more shown in a specific question page (great!). But it is still shown in the category pages. For example if I click on a particular category, that category page will have the category list again on the side bar, which I don't wonna see. How can I remove that also?

Thanks in advance.
by
Ok, this happens because the class of a category page looks like that:

CLASS="qa-template-qa qa-category-1 qa-body-js-off"

Our condition was to show the navigation on all pages with the template class .qa-template-qa . So it is right that the category pages still show the categories in sidebar as the body template is .qa-template-qa ........

Now, it was a bit tricky but i think I found a solution as follows:

Add to Your advanced theme at /SNOW/qa-theme.php the following function at the end before the closing }

.................
...............

function sidepanel()
        {
            $this->output('<DIV CLASS="qa-sidepanel">');
            $this->widgets('side', 'top');
            $this->sidebar();
            $this->widgets('side', 'high');
            if (qa_request_part(0)==''){
            $this->nav('cat', 1);
            }else{}
            $this->widgets('side', 'low');
            $this->output_raw(@$this->content['sidepanel']);
            $this->feed();
            $this->widgets('side', 'bottom');
            $this->output('</DIV>', '');
        }

..........
..........

__________________________

To the original sidepanel we are adding

------->        if (qa_request_part(0)==''){
            $this->nav('cat', 1);
------->        }else{}

So, now the categories only show up if the first part of the internal url request is empty '' (this is two times ' not one time ") . This works if Your homepage looks like
www.myhomepage.com/

If still not enough please let me know, I will see what I can do.

In my install the end of the qa-theme.php look like that:

function sidepanel()
        {
            $this->output('<DIV CLASS="qa-sidepanel">');
            $this->widgets('side', 'top');
            $this->sidebar();
            $this->widgets('side', 'high');
            if (qa_request_part(0)==''){
            $this->nav('cat', 1);
            }else{}
            $this->widgets('side', 'low');
            $this->output_raw(@$this->content['sidepanel']);
            $this->feed();
            $this->widgets('side', 'bottom');
            $this->output('</DIV>', '');
        }

       
    }
     

/*
    Omit PHP closing tag to help avoid accidental output
*/
by
Great! It works like a charm.

Thank you very much for your kind attention & time.
by
No problem, if You like my answer You can vote it up or even choose it as best answer....two really great functions of this script...
...