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

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

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:
CoreWeave stock slides as quarterly revenue guidance disappoints
Smartphone market poised for 'sharpest decline on record' in 2026
UBS turns bullish on Palantir, says buy the dip on this clear AI winner
Jim Cramer's top 10 things to watch in the stock market Friday
This obscure ETF may hold the key to whether the bull market lasts
Apple appears to be sitting out the AI arms race. Will the strategy work?
Stock futures tumble as traders monitor latest with U.S.-Iran conflict: Live updates
Amazon says drone strikes damaged 3 facilities in UAE and Bahrain
Iran war live updates: U.S. embassy in Riyadh hit by drones, Trump promises response 'soon'
Movie: Mile End Kicks