Different JavaScript for HomePage

From Adult Web Scripts Wiki

Jump to: navigation, search

A template called home.php will be searched for first for your home page, then home.tpl, home.pct and home.tgp before then searching for index* template files.

If you use shared files, like header.php and footer.php in all pages, but need to display different javascript in them to only display a popup etc for your home page use this code:

PHP:

  <? if ($url_decode['urlconfig_name'] == 'home'): ?>
  put home page code here
  <? endif; ?>

PCT/TGP: You can embed PHP code with a *.tgp or *.pct template, but they dont have the $url_decode variable available, so you need to create it yourself.

  <? $url_decode = zestoi_decode_url(); ?>
  <? if ($url_decode['urlconfig_name'] == 'home'): ?>
  put home page code here
  <? endif; ?>

Smarty:

  {decode_url var=decode}
  {if $decode.urlconfig_name == 'home'}
  put home page code here 
  {/if}

You can use this technique for any type of page. Here we check that urlconfig_name matches home since by default there is a urlconfig rule called home for the home page. If you wanted to display something whenever the type was webcams then you could check that urlconfig_type has the value webcams and so on.