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

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

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:
Michael Burry believes the AI bubble 'may burst' sooner than he first believed
A key test looms for the AI trade this week. Here's how Mike Khouw is trading it
Senate tees up college sports bill aimed at regulating NIL deals
Snowpiercer: A Beacon for Us All Rewatch
Movie: Mayday
Help me refine my sleep setup so I can ideally get some
3D Printing Functional Replacement Parts for a Turntable?
Can I use this cat shelf idea safely?
Samsung to inject $1 billion into Nvidia- and KKR-backed AI infrastructure firm
Stock futures are little changed after higher yields lead to losing session: Live updates