B2Evolution Hack: Exit to Active Blog

Published by Andrew Hreschak in Web Development, b2evolution 0.9.x, PHP
Published on 09/10/05 @ 06:41:00 pm using 288 words, and has 45629 views

This hack allows you to avoid the annoyingness of exiting to the first blog/stub after creating or editing a post in a sub-blog. In short, it saves a mouse-click and a little confusion... This hack for the b2evolution 0.9.x admin interface only works for people who use stubfiles to access their b2evo blogs, and who have correctly configured their stubfiles in their server's .htaccess file.

In /admin/_menutop.php find:

<div id="headfunctions">
<?php echo T_('Style:') ?>
<a href="#" onclick="setActiveStyleSheet('Variation'); return false;" title="Variation (Default)">V</a>&middot;<a href="#" onclick="setActiveStyleSheet('Desert'); return false;" title="Desert">D</a>&middot;<a href="#" onclick="setActiveStyleSheet('Legacy'); return false;" title="Legacy">L</a><?php if( is_file( dirname(__FILE__).'/custom.css' ) ) { ?>&middot;<a href="#" onclick="setActiveStyleSheet('Custom'); return false;" title="Custom">C</a><?php } ?>
&bull;
<a href="<?php echo $htsrv_url ?>/login.php?action=logout"><?php echo T_('Logout') ?></a>
&bull;
<a href="<?php echo $baseurl ?>"><?php echo T_('Exit to blogs') ?> <img src="img/close.gif" width="14" height="14" class="top" alt="" title="<?php echo T_('Exit to blogs') ?>" /></a><br />
</div> 

and change it to:

<?php
// get the stub name for the active blog, if there is one
if( $blog != '' )
{
$blogstub = getblogstub( $blog );
$blogstub = $baseurl."/".$blogstub;
} else {
// if there is no active blog then pick the default blog
$blogstub = getblogstub( 2 );
$blogstub = $baseurl."/".$blogstub;
}
?>
<div id="headfunctions">
<?php echo T_('Style:') ?>
<a href="#" onclick="setActiveStyleSheet('Variation'); return false;" title="Variation (Default)">V</a>&middot;<a href="#" onclick="setActiveStyleSheet('Desert'); return false;" title="Desert">D</a>&middot;<a href="#" onclick="setActiveStyleSheet('Legacy'); return false;" title="Legacy">L</a><?php if( is_file( dirname(__FILE__).'/custom.css' ) ) { ?>&middot;<a href="#" onclick="setActiveStyleSheet('Custom'); return false;" title="Custom">C</a><?php } ?>
&bull;
<a href="<?php echo $htsrv_url ?>/login.php?action=logout"><?php echo T_('Logout') ?></a>
&bull;
<a href="<?php echo $blogstub ?>"><?php echo T_('Exit to Active Blog') ?> <img src="img/close.gif" width="14" height="14" class="top" alt="" title="<?php echo T_('Exit to Active Blog') ?>" /></a><br />
</div>

The function "getblogstub()" looks like this:

function getblogstub( $whichstub )
{
global $DB, $tableblogs;
// get the blog stub name based on blog ID
$query = "SELECT blog_stub FROM $tableblogs WHERE blog_ID = $whichstub";
$blogstub = $DB->get_var( $query );
return $blogstub;
}

This should work for stubs, but will not work for blogs without stubs.

Contemporaneous Auditory Narcotics:
or, What my speakers are currently pumping...
Sham 69 - Borstal Breakout

2 comments

Comment from: Wool [Visitor]  
Wool

Nice, nice! thank you for this piece. I used in on my blog! Thanks!

11/03/09 @ 01:05
Comment from: silah oyunları [Visitor]  
silah oyunlar&#305;

Thank you, very nice site, your site would follow with interest from Turkey,
good work

05/08/11 @ 09:34