One of the bigger improvements in the EE 1.2 beta that some folks might overlook is the new ability to define optional “global variables” via the path.php file. This is primarily of importance to folks who, like me, are running multiple blogs in different subdirectories or domains. What this allows you to do is to define a list of global variables that will only apply to a particular blog based on the subdirectory it is associated with. Among other things, using this feature will allow you to design templates that are truly blog independent.
ExpressionEngine is unique in that it doesn’t force an association between a particular template group and a particular blog, but this flexibility was hampered if you wanted to limit the output to just one blog out of all the ones in your system. Previously to do that you’d have to force an association by specifying in your {exp:weblog:entries} loop which blog it should pull the data from. This was fine if you were using different template groups for each blog, but what if you wanted to use a single template group for all of your blogs? Couldn’t be done. You’d have to duplicate that template group repeatedly for each blog even though the templates in each group were all the same other than being hardcoded for a particular blog. Under 1.2 with this new option, though, it can be done.
Here’s how:
- Download and open up the path.php for the blog you want to set a global variable for.
- Add the following code at the bottom before the closing ?> tag changing the words “short name of blog” appropriately:
$global_vars = array( "master_weblog_name" => "short name of blog" );
- Save the path.php and re-upload it to your site making sure it goes back into the same sub-directory you downloaded it from.
Now to make a template universal you’ll need to modify it to add the global variable in you just created. If you’re assigning a global variable at the top of the template such as {assign_variable:master_weblog_name="myblog"} then you can just delete that line and your templates should still work just fine. If you hardcoded the weblog="shortname" in all the EE tags that use it then you’ll need to go through and change them to the global variable you defined. Keep in mind that any universal templates you create will require that the blogs using it all share the same weblog fields in order to work properly.
To illustrate exactly what it does take a look at my port of the Kubrick template: Here’s SEB using Kubrick and here’s Momma’s Corner using it as well. Or how about SEB with Neil’s Icy Blue and then Momma with Neil’s Icy Blue. One template group, two different blogs.


















very interesting. I’ll have to take a closer look at this feature. Thanks for pointing it out, Les!