Author Topic: Is there a home conditional tag?  (Read 4163 times)

0 Members and 1 Guest are viewing this topic.

Offline a_rojilla

  • Pre-Newbie
  • Posts: 5
    • View Profile
Is there a home conditional tag?
« on: October 30, 2008, 01:16:45 PM »
I've been searching these forums (using Google) but haven't found what I looking for: a conditional tag for when you are in the home page, something like (for templates)

Code: [Select]
{if home}
or like (for php files)

Code: [Select]
if (is_home)
I remember that this can be done, or at least it could be done some time ago, because I used this for an old site (like one or two years ago) but now I can't find the code.

Regards.

Offline a_rojilla

  • Pre-Newbie
  • Posts: 5
    • View Profile
Re: Is there a home conditional tag?
« Reply #1 on: November 12, 2008, 05:00:21 PM »
Anyone?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Is there a home conditional tag?
« Reply #2 on: November 13, 2008, 02:15:56 AM »
In includes/page_header.php find:
Code: [Select]
$site_template->register_vars(array(

Insert ABOVE:
Code: [Select]
$file = get_included_files();
$file = get_file_name(basename($file[0]));
$list = array("categories", "details", "index", "member", "postcards", "register", "search", "top");
$array = array();
foreach ($list as $name)
{
  $array[$name] = ($name == $file);
}
$site_template->register_vars($array);
After that you can use in any template: {if index}...{if index} for home page , {if details}..{endif details} for details.php page, so on (check the $list array for the available tag names)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)