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

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

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:
What will it take to get tech stocks rising again? An unemployment rate above 4%
Here's why FEMA has spent about $4 billion to help destroy flood-prone homes
The highest-paying in-demand jobs that don't require a degree, according to new research
Emirates CEO issues apology after Dubai flood chaos; says airline has 30,000 suitcases to return
Supreme Court will take up the legal fight over ghost guns, firearms without serial numbers
Any good articles about homelessness and "authority" in the US?
How can i solve the problem?
Movie: A Certain Kind of Death
Delta Air Lines gives staff another 5% raise, hikes starting wages to $19 an hour
Crypto prices gain to start the week following first Bitcoin halving since 2020