Having control over different page styles

Permalink
I was asked if a bar could be put across the index page as a background but only on the index page.
The bar was simple enough, just use a css background image to the body with a repeat x.
The fun was keeping it on only one page.
The solution...
<?php
//this will grab the current url/page in concrete 5
$address = $_SERVER['PHP_SELF'];
$address = substr($address, strrpos($address, '/') + 1);
?>
</head>
<body class="<?php 
if($address == "index.php"){
   echo("bar");
} else {
   //this will be any page but the index
}
?>">

Hope some might find this useful.

scorpa54
 
glockops replied on at Permalink Reply
glockops
That's actually not the best way of doing that - since index.php can technically be any page on the site - Example index.php?cID=#, etc.

You can use the concrete5 API to ask if the page is the homepage
if($c->getCollectionID() == 1) {
// This is the homepage, do magic
}


Also could have a custom page type for the pages that need a different style.
scorpa54 replied on at Permalink Reply
scorpa54
I realize that index.php is every page on the site but it is appended with other pages and the append, or lack of it, is what the code looks for. So if your url reads "index.php/about", for example, the code would spit out "about".

I did not know about the method you describe and I do like having more than one way to go about anything.
Thank you.