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

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

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:
RV buyers are trading up and this stock is set to benefit, Loop Capital says
Bank of America boosts Micron price target, sees upside driven by tight memory supply
Why Jim Cramer is bullish on Goldman Sachs and Morgan Stanley
Wikipedia parent partners with Amazon, Meta, Perplexity on AI access
Goldman Sachs CEO is looking at how the Wall Street bank can get involved in prediction markets
Australia banned social media for under 16s a month ago — here's how it's going
Trump pitches direct payments to consumers for health care. What policy experts say about the plan
Venezuela oil fetching 30% higher price, U.S. energy chief says, after first sale worth $500 million
Here are Needham's top picks for 2026
Stocks making the biggest moves premarket: PNC, ImmunityBio, Coupang & more