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

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

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:
Trump administration equity stakes pose risks to U.S. companies and markets
The Trump administration equity portfolio is growing. These are the investments so far
Nearly a thousand Google workers sign letter urging company to divest from ICE, CBP
Berkshire Hathaway outperforms this week as tech stocks sink
I've studied over 200 kids—the happiest ones have parents who do 6 things with them before bedtime
Pressure mounts on American Airlines CEO as carrier lags rivals
Trump’s 'big beautiful bill' may spur significant changes to higher education in 2026 and the rise of 'un-college,' experts say
NFL plans to have discussions with partners outside of core media for live games, media chief says
Kroger to name former Walmart exec Greg Foran as next CEO, WSJ reports
Goldman Sachs says this under-the-radar biotech play could more than double in value