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

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

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:
CrowdStrike is a buy, just not yet. Here's why
Eli Manning's private equity firm acquires licensing company for NFL Flag in bet on youth sports
India's viral 'Cockroach' party has millions of followers. What investors need to know
What should I do with a free day in Paris?
Star City: A Bear on a Chain
Book: Against the Gods: The Remarkable Story of Risk (1996)
Stargate SG-1: Between Two Fires Rewatch
Investors can 'buy' SpaceX early with Coinbase perpetual futures on pre-IPOs
Here are Thursday's biggest analyst calls: Nvidia, Apple, Broadcom, Netflix, Oracle, Microsoft, CrowdStrike & more
Oil prices fall 3% on report Trump reluctant to restart Iran war