1 laibcoms Jul 17, 2006 14:39
3 yabba Jul 17, 2006 17:39
How about a tad of expansion on that (which should work with multiblogs)
<?php
if( file_exists( dirname(__FILE__).$case.$Blog->ID.'.php' ) )
{
include dirname(__FILE__).$case.$Blog->ID.'.php' );
} elseif ( file_exits( dirname(__FILE__).$case.'_default.php' ) )
{
include dirname(__FILE__).$case.'_default.php' );
}
?>
I use something similar on my own blog ( which I really really really need to upgrade to 1.8 :p )
¥
*Customer notice : The accuraccy of my syntax is inversely proportional to the alcahol level in my blood stream
4 laibcoms Aug 15, 2006 14:17
Trying to understand Y's code, I can see it is an expansion though I still don't understand much about the codes before .$case.$Blog->ID. :p
I mean, where will the code get the dirname and __FILE__ ? (sorry my php knowledge is still limited)
And if I understand it correctly $case will call the one in EdB's code right?
Thanks ^^
5 yabba Aug 15, 2006 17:19
I do tend to post condensed answers huh :p
$case is your "block" (ie/ sidbar, top, bottom etc). To use it you create something like sidebar1.php sidebar2.php sidebar_default.php etc.
Then, in your sidebar you put the following code :-
<?php
$case = 'sidebar';
if( file_exists( dirname(__FILE__).$case.$Blog->ID.'.php' ) )
{
include dirname(__FILE__).$case.$Blog->ID.'.php' );
} elseif ( file_exits( dirname(__FILE__).$case.'_default.php' ) )
{
include dirname(__FILE__).$case.'_default.php' );
}
?>
What will happens is the code will look for the relevant sidebar##.php for the blog the page is displaying, if it's not there then it'll try and load sidebar_default.php instead.
You then do the same for top, bottom etc and use the same code (except you change $case = to match).
¥
In one skin in any location you can do something like this (though my syntax might be off because I'm winging it):
If you have a constantly changing number of blogs it's no good, but if you have a fixed number it'll work.
Heck you could even use "require blahblahblah._head_block_bit.php" (copy the real way to do it from where your linkblog is linked!) then create a file called _head_block_bit.php and put the switch above in it. That'll keep your skin file looking nice and let you easily tweak bits and pieces of each block file.
Just a thought is all!