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

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

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:
Dave's Hot Chicken investors bet on birria with national franchise expansion plan
Trump's 'no tax on overtime' deduction could be tricky this season — how to claim it
Pentagon threatens to cut off Anthropic in AI safeguards dispute: Report
India discussing age-based restrictions with social media firms, top minister says
French prosecutors are investigating companies like Nestle and Danone over contaminated baby formula. Here's the latest
S&P 500 finds itself once again unable to surmount the 7,000 threshold
Snap to launch creator subscriptions in push to diversify revenue
Danaher to buy Masimo in $9.9 billion deal in diagnostics push
Hedge fund manager Rob Citrone is short U.S. stocks. Here's why
Special Event: Rifftrax: Hunks of Junk