Answered: How do I create conditions, to control where something appears

Post date: 2021-09-18 07:48:15
Views: 164

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.

Please click Here to read the full story.
 
Other Top and Latest Questions:
The Trump administration equity portfolio is growing. These are the investments so far
First the quarter zip, now a '401(k) mullet' — what Gen Z trends say about the economy
In reversal, Trump backs Nexstar's proposed acquisition of Tegna
Here are the 5 big things we're watching in the stock market this week
Epstein files: UK PM Starmer's top aide McSweeney quits over Mandelson scandal
Elon Musk wants to be a trillionaire — here's how SpaceX may get him there
Washington Post publisher Will Lewis announces departure, following mass layoffs
Japanese Prime Minister Takaichi's ruling LDP set to secure supermajority in Lower House: NHK
Goldman Sachs says this under-the-radar biotech play could more than double in value
Japan's Nikkei 225 skyrockets over 5% to hit record highs as Takaichi secures historic mandate