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

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

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:
Meta announces new AI parental controls following FTC inquiry
U.S. Chamber of Commerce sues Trump administration over $100,000 H-1B visa fee
U.S. budget deficit edged lower in 2025 as tariffs, debt payments both saw new records
Trump puts Russia on notice over Ukraine as two leaders prepare to meet
Gold's record run leads to latest market-moving tweak to the classic 60/40 investing portfolio
Benioff’s backing of Trump, troops in SF leads Salesforce Foundation director Conway to quit
OpenAI stops Sora videos of Martin Luther King Jr. after users made 'disrespectful' deepfakes
Apple and F1 reach 5-year media deal, bringing all races to Apple TV streaming in the U.S.
Democrats' distrust of Trump keeps them from forming 'gang' to negotiate government shutdown
Former Trump official John Bolton pleads not guilty to criminal charges