Hide Those Templates
When using Expression Engine sometimes you don’t want a template accessible to anyone that could stumble across a url. Most likely you’ll be using these templates as embedded fragments to make up the common parts of a page.
They’re incomplete HTML, that make sense when part of the whole, but you really don’t want to be visible on their own. In EE you can use hidden templates to solve this. By making a template hidden it will still be available to embed the standard way, but can’t be accessed via the template_group/template_name url.
So in our case our template head (which has all the html header in) previously would have been embedded such : embed=“includes/head”
but would have also been accessible via _http://site_url/includes/head _
So now, we rename it to .head and change our embed to : embed=“includes/.head”
Now a visit to http://site_url/includes/.head gives us a 404, and all is good in the world. This method of hiding templates boils down to prepending the templates you want hidden with a period.
That works ok, but cause conflicts with other things, notably TextMate, and to a lesser degree Finder. There are workarounds for solving the issues in TextMate, but it’s not too pretty.
I Don’t Like the Look of Them
Come on. Periods at the start of every hidden file are just unpleasant. That single factor was the primary reason I hadn’t done anything with hidden EE templates until recently. Of course if I’d of known of that hidden templates can be prepended with the character of your choice, I would have jumped on the band wagon ages ago.
Heading over to your trusty EE’s config.php simply set the conf variable hidden_template_indicator to your choosing. In my case :
$conf[‘hidden_template_indicator’] = ‘_’;
As by previous convention I use underscores as separators already.
By having a non period character as your hidden template indicator you neatly sidestep all the issues with hidden files and TextMate/Finder. Using this convention, my includes (or globals folder if you please) folder looks something link this.