Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+7 votes
547 views
in Q2A Core by
"Ask a Question" is a very helpful link, when you are viewing a question or a category and you click "Ask a Question" you will ask a question in the exact category.

I would like to customize a little bit, but found out that it's hard to find the solution.

Of course I'm not asking how to apply CSS style onto it, or change the associated language file.

I would like to hide it on homepage, on tags list page, on tag page, on search result page, user profile page... The reason is that on those pages, there is no categoryid, so users have to manually select the correct category.

Unfortunately, the "Ask a Question" link source code is buried deep in a chain of functions in qa-theme-base.php file (nav --> nav_list --> nav_item --> nav_link)

I cannot find a clear-cut solution to customize it, or put it in a widget.
by
what about

 if($this->tamplate == 'question' OR $this->tamplate == 'questions')

but this big mistake , user need to have question button on every page , to get more activatgy , for user UX

2 Answers

0 votes
by

Here's what I get

qa_opt('nav_ask') : if "Ask a Question" link exists

$this->content['navigation']['main']['ask']['url']  : return the url

$this->content['navigation']['main']['ask']['label']  : return the label

If you want to customize, you need to modify  function nav_main_sub()

So far, to hide this link, I can only unset those values. The outer wrapper is still there, but not visible to human eyes.

by
thank you!!!
0 votes
by

Late to the party, but anyway. Since every page has a unique template style assigned to the <body> tag you should be able to hide the "Ask a Question" button on the desired pages via your theme's stylesheet. Something like this:

.qa-template-tags li.qa-nav-main-ask,
.qa-template-tag li.qa-nav-main-ask,
.qa-template-user li.qa-nav-main-ask {
  visibility: hidden;
}

Use display: none; instead of visibility: hidden; if you don't want the element completely removed from the page (see here for more information about the difference between the two attributes).

...