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

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

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:
Why do I get “You do not have permission to perform this operation” when editing my listing, and how can I fix it?
Advisors to the ultra rich say AI isn't a gamechanger for landing new clients
Nvidia’s Huang to visit China as AI chip sales stall
Why a niche category of CRE lending is suddenly seeing record deals
Shares of CSG, one of the world’s fastest-growing defense firms, jump 31% on debut
Trump signed his Gaza 'Board of Peace' into being. Here's who's on it — and who isn't
Wall Street braced for a private credit meltdown. The risk of one is rising
Intel's likely to still move higher. Here's a 'no-cost' options strategy to play it
A former Trump official wants to build a massive data center in a remote corner of Greenland. Will it work?
Pardoned Binance founder Zhao says his business relationship with the Trumps was 'misconstrued'