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

I need to add new links to the nav sub list. For example in the questions page there exists these links:

how can I add another link to this list?


1 Answer

+2 votes
selected by
Best answer

Adding a link is the easy part. The complex part is adding some logic into it :)

Anyway, to add a link just create a layer and add this method to it:

public function initialize(){
    if ($this->template === 'questions') {
        $newSort = 'new-sort';
        $newTabSelected = qa_get('sort') === $newSort;
        $this->content['navigation']['sub']['recent']['selected'] = $this->content['navigation']['sub']['recent']['selected'] && !$newTabSelected;
        $this->content['navigation']['sub']['my-id'] = array(
            'label' => 'Link text',
            'url' => qa_path_html('questions', array('sort' => $newSort)),
            'selected' => $newTabSelected,

Piece of cake!

Thank you pupi. What if template is a custom page?
Rather than answering the question directly, I'll let you figure out how to answer it. Just echo the template (right above the IF statement) while you're browsing the page and you'll find out what the name is.

echo $this->template;
Thank you for your answer.
I have two custom pages(I created them from admin/pages/add page) the slug of one of them is "help" and the other "ads". after  "echo $this->template;" I found out the name of the both is "custom". I want to add links to the sub nav of the help page. is it possible?
Got it. In this case you could use qa_request() then.