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

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

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 Gilded Age: Love is Never Easy
Getting swole for the revolution, for some values of swole
Help me find a pro bono illustrator for my childrens book for Gaza
Cannot connect my MacBook to the new wireless printer
Answered: [New Premium Plugin] Q2A Avatar Cropper (square image 1:1)
White House: Odds of tariff-related inflation are low, like 'pandemics or meteors'
Waymo offers teen accounts for driverless rides
'Revenge savings' can boost your bottom line, experts say — here's how to get started
'Big beautiful bill' may help some seniors on Social Security. But it doesn't eliminate taxes on benefits
Here are the 15 busiest airports in the world