Recent Topics

1 Jul 17, 2006 14:39    

I like to suggest a built-in feature for "Custom Blocks" (for the lack of an appropriate name for this idea).

What this does is to allow each blog to have different blocks without touching the skin itself.

Currently, to put (example) "ranking images", the skin itself needs to be edited. If the other blogs are using the edited skin, they also adopt whatever changes in the skin there are.

This will also avoid duplicating the same skin just so blogs that use the same skin can have different blocks.

Of course, the blocks can be positioned per blog.

The areas that are best to have the blocks are:
TOP, SIDEBAR, BOTTOM

TOP = good for tracking urls and ads (so each blog can have its own)
SIDEBAR = as explained
BOTTOM = copyright and other stuff.

Maybe in the skin, the blocks are called by:
<!--TOP_BLOCKS-->
<!--SIDEBAR_BLOCKS-->
<!--BOTTOM_BLOCKS-->

Then the block creation are done via the backoffice.
There can be an unlimited number of blocks as well.

I'm not sure if this is already possible.

If it will not go through as a built-in feature, then this may well server as a plugin feature or hack.

Thanks!!

2 Jul 17, 2006 16:38

In one skin in any location you can do something like this (though my syntax might be off because I'm winging it):

<?php
switch ( $blog ) {
case '1':
--- do this for blog #1 ---
break;

case 'N':
--- make a case for each blog that you want to have an action for ---
break;

default:
--- the default is do nothing ---
} ?>

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!

3 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 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 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).

¥


Form is loading...