Page id based on file path? My page structure looks a little something like this:


www.site.com/sub-directory-1/page-1
www.site.com/sub-directory-1/page-2
www.site.com/sub-directory-1/page-3
www.site.com/sub-directory-2/page-1
www.site.com/sub-directory-2/sub-sub-directory-1/page-1
www.site.com/sub-directory-2/page-2
www.site.com/sub-directory-2/page-3


What is the easiest way to make the page's ID the name of the first subdirectory it's stored in? 

For example, in the first case, the &lt;body&gt; tag should be like the following.

&lt;body id="sub-directory-1"&gt;
You need to edit your page.tpl.php file, and add this where you have the &lt;body&gt; tag. 

&lt;body class="&lt;?php
   print arg(0, request_path());
?&gt;


This will print the first part of $_SERVER['REQUEST_URI'] delimited by a slash. 
arg() and request_path() are Drupal functions.