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

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

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:
BNY raises profit target as CEO Robin Vince says 'turnaround' is taking hold
Intel and AMD get upgrades at KeyBanc thanks to strong server demand for AI
Stocks making the biggest moves premarket: L3Harris, JPMorgan, Delta, Intel, AMD and more
CEOs, security executives are divided on cyber risks of AI, survey finds
New York offshore wind project to resume construction after judge lifts Trump suspension
DeepMind CEO is talking to Google CEO 'every day' as lab ramps up competition with OpenAI
India’s exports to China surge in December while shipments to U.S. decline as Trump tariffs bite
TSMC is set to expand its $165 billion U.S. investment — here’s what we know
Here are Needham's top picks for 2026
Amazon threatens 'drastic' action after Saks bankruptcy, says $475M stake is now worthless