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

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

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:
Bank of America says Nvidia and these stocks are its top picks for 2026
What the Christmas movie ‘Elf’ can teach us about today's cost of living
I've studied happiness for 15 years: If you do these 9 things every day, you're more 'emotionally resilient' than most
Oracle stock jumps 7% as cloud provider joins investor group to run TikTok's U.S. business
25-year-old certified nutrition and health coach’s grocery store hack for eating well
Here’s where the stock market is headed in 2026, according to Wall Street’s top strategists
Denmark to summon U.S. ambassador as Trump's Greenland special envoy appointment stirs tensions
Asset manager Janus Henderson gets bought by Trian, General Catalyst for $7.4 billion
S&P 500 rises to start a holiday-shortened week, led by tech: Live updates
Why Warner Bros. Discovery shareholders might opt for Paramount's offer — and why they might not