Targeting components/pages conditionally

23 Feb 2017

PHPVibe comes with a few simple but efficient conditional functions for components restrictions (all located in lib/functions.php):

is_home() – Returns true if the current page is the homepage
is_video() – Returns true for single video & music pages
is_picture() – Returns true for single image
is_channel() – Returns true for single channel

For all the rest you could use the function is_com($com)

if(is_com('login')) {
/* You are on the login page */}

To see the components you could check the router declarations in index.php

$router->map('/api/:section', 'api', array('methods' => 'GET', 'filters' => array('section' => '(.*)')));

The structure is RewritenUrl format, Component, arrays of methods.

You could also just

echo com();

to print the current component.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.