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

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

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:
There's a new idea of alpha in the market that big money managers are pursuing
Jim Cramer says he's not abandoning the Mag 7 stocks despite recent struggles. Here's why
Elon Musk says Tesla taking safety supervisors out of some Robotaxi vehicles in Austin
Advisors to the ultra rich say AI isn't a gamechanger for landing new clients
From French drug pricing to 'loser' windmills: A rundown of who Trump criticized at Davos
Cramer says 'a big move is coming' for this financial, weighs a chip stock buy
Adani group stocks plunge as U.S. SEC looks to question founder over fraud charges
Wall Street braced for a private credit meltdown. The risk of one is rising
What obesity drugmakers see next in the market: More pills, easier access and drug combinations
Stocks making the biggest moves midday: Fortinet, Moderna, Intel, Bausch Health & more