Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
417 views
in Q2A Core by

HI

How do I create conditions, to control where something appears in my layer, like :

is_post

is_page

is_category

is_search

...

Q2A version: last
by
It's not quite clear to me what you're asking here. Do you mean how such checks would be implemented? Or what you would need to evaluate in such a check? Also, layers are similar to themes in that they extend the class qa_html_theme_base and override methods of the base class where needed. I don't see how the conditions you mention would factor into that.

Bottom line: I suspect this might be an X-Y problem, so please elaborate on what you're actually trying to accomplish by doing this.

1 Answer

+1 vote
by
selected by
 
Best answer

You can use  $this->template  to create conditions for different types of pages, much like WordPress.

if ($this->template == 'question') {
    // DO SOMETHING
}

Conditions:

Linked to Navigation

$this->template == 'ask'                          // Ask Page
$this->template == 'qa'                           // Homepage / Q&A Page
$this->template == 'activity'                  // Activity Page
$this->template == 'questions'             // Questions List Page
$this->template == 'hot'                          // Hot Page
$this->template == 'unanswered'        // Unanswered Page
$this->template == 'tags'                       // Tags Page
$this->template == 'categories'           // Categories Page
$this->template == 'users'                     // Users List Page


Single Pages:

$this->template == 'question'              // Single Question Page
$this->template == 'custom'                // Single Page
$this->template == 'search'                  // Search Result Page
$this->template == 'user'                      // Single User Page


Page templates are rendered as a body class in the DOM. You can inspect element to check for other page templates.

...