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

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

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:
Ken Griffin’s flagship hedge fund at Citadel rises 10.2% in volatile 2025
Bank of America is betting on these stocks, including one Big Tech laggard, in the first quarter of 2026
Be careful buying the top 10 ETFs of 2025: They have 'very little, if any' role in your portfolio, says expert
Bank of America expects a boost in dividends in 2026. These stocks have payouts that beat the market
U.S. indictment against Venezuela President Maduro, wife is unsealed
Watch Trump's full comments following the U.S. strike against Venezuela
Protest over AI, climate crisis leaves tens of thousands without power in Berlin
Overspent this holiday season? 3 easy ways to pay down debt
Josh Brown: The bull market in this bank stock is ready to be renewed to start 2026
JPMorgan forms special advisory group to share some of bank's 'secret sauce' with clients