Posted on: 06/29/04 02:22am
By: machinari
Posted on: 06/29/04 03:34am
By: machinari
Posted on: 06/29/04 07:14am
By: drshakagee
Posted on: 06/29/04 03:30pm
By: machinari
// If the theme implemented this for us then call their version instead. $function = $_CONF['theme'] . '_siteHeader'; if( function_exists( $function )) { return $function( $what ); }what do you think?
Posted on: 07/12/04 04:38pm
By: Demonhood
Posted on: 07/15/04 02:37am
By: machinari
here's the deal with loading right blocks from the header.
It isn't a problem to load right blocks from the header--it's a can do. It isn't even a problem to extend the center column (remember we are talking about CSS-P here) when the right blocks aren't supposed to show up.
The problem is that unless you modify the GL core, you will not be able to say, "i want rightblocks on this page, but not that one." You will either have blocks, or you won't--across the board. This is because the parameter passed to COM_siteFooter is not passed to COM_siteHeader. Even that is not a big hurdle to overcome.
The big hurdle is this: whereas COM_siteFooter() either passes a parameter or not, calling rightblocks or not, throughout GL core pages, COM_siteHeader does not pass a parameter anywhere, by default. You have to go in and edit GL core files. You can do this of course and it won't affect other themes that call the right blocks from the footer, but it sure is a hasle and when you upgrade, well, good luck.
so here is what you can do to load the rightblocks from the header:
First, in an attempt to modify the GL core as little as possible, I copied the function COM_siteHeader to my theme's function.php file. From there I made a few adjustments including passing an extra parameter to the function. Here is that function:
/** * Returns the site header * * @param string $what If 'none' then no left blocks are returned, if 'menu' (default) then right blocks are returned * @param boolean $rightblock Whether or not to show blocks on right hand side default is no * @return string This returns formated HTML containing the site header * */ // This function loads the rightblocks from the header. be sure to remove or comment out // your {rightblocks} from your footer.thtml, or you'll probably get something you don't expect. // By default, the rightblocks are not displayed. // This function is a modified copy of COM_siteheader from lib-common.php and is called from COM_siteheader. // The COM_siteheader will be looking for "$_CONF['theme'] . '_siteHeader'" thus the theme // name replaces "COM" in the function name. // If you have no particular need to load the rightblocks from the header then DON'T! // terry is the name of this theme, incase you were wondering. function terry_siteHeader( $what = 'menu' , $rightblock = false ) { global $_CONF, $_USER, $LANG01, $_COM_VERBOSE, $topic, $LANG_BUTTONS, $LANG_CHARSET; global $_TABLES, $HTTP_POST_VARS, $HTTP_GET_VARS; $header = new Template( $_CONF['path_layout'] ); $header->set_file( array( 'header' => 'header.thtml', 'menuitem' => 'menuitem.thtml', 'menuitem_last' => 'menuitem_last.thtml', 'menuitem_none' => 'menuitem_none.thtml', 'leftblocks' => 'leftblocks.thtml', 'rightblocks' => 'rightblocks.thtml' )); $pagetitle = ''; if( isset( $_CONF['pagetitle'] )) { $pagetitle = $_CONF['pagetitle']; } if( empty( $pagetitle )) { $pagetitle = $_CONF['site_slogan']; } if( !empty( $pagetitle )) { $pagetitle = ' - ' . $pagetitle; } $header->set_var( 'page_title', $_CONF['site_name'] . $pagetitle ); $header->set_var( 'background_image', $_CONF['layout_url'] . '/images/bg.gif' ); $header->set_var( 'site_url', $_CONF['site_url'] ); $header->set_var( 'layout_url', $_CONF['layout_url'] ); $header->set_var( 'site_mail', "mailto:{$_CONF['site_mail']}" ); $header->set_var( 'site_name', $_CONF['site_name'] ); $header->set_var( 'site_slogan', $_CONF['site_slogan'] ); $rdf = substr_replace( $_CONF['rdf_file'], $_CONF['site_url'], 0, strlen( $_CONF['path_html'] ) - 1 ); $header->set_var( 'rdf_file', $rdf ); $header->set_var( 'rss_url', $rdf ); $msg = $LANG01[67] . ' ' . $_CONF['site_name']; if( !empty( $_USER['username'] )) { $msg .= ', ' . $_USER['username']; } $curtime = COM_getUserDateTimeFormat(); $header->set_var( 'welcome_msg', $msg ); $header->set_var( 'datetime', $curtime[0] ); $header->set_var( 'site_logo', $_CONF['layout_url'] . '/images/logo.gif' ); $header->set_var( 'css_url', $_CONF['layout_url'] . '/style.css' ); $header->set_var( 'theme', $_CONF['theme'] ); if( empty( $LANG_CHARSET )) { $charset = $_CONF['default_charset']; if( empty( $charset )) { $charset = "iso-8859-1"; } } else { $charset = $LANG_CHARSET; } $header->set_var( 'charset', $charset ); // Now add variables for buttons like e.g. those used by the Yahoo theme $header->set_var( 'button_home', $LANG_BUTTONS[1] ); $header->set_var( 'button_contact', $LANG_BUTTONS[2] ); $header->set_var( 'button_contribute', $LANG_BUTTONS[3] ); $header->set_var( 'button_links', $LANG_BUTTONS[4] ); $header->set_var( 'button_polls', $LANG_BUTTONS[5] ); $header->set_var( 'button_calendar', $LANG_BUTTONS[6] ); $header->set_var( 'button_sitestats', $LANG_BUTTONS[7] ); $header->set_var( 'button_personalize', $LANG_BUTTONS[8] ); $header->set_var( 'button_search', $LANG_BUTTONS[9] ); $header->set_var( 'button_advsearch', $LANG_BUTTONS[10] ); // Now add nested template for menu items // contribute link if( empty( $topic )) { $contributelink = $_CONF['site_url'] . '/submit.php?type=story'; $header->set_var( 'current_topic', '' ); } else { $contributelink = $_CONF['site_url'] . '/submit.php?type=story&topic=' . $topic; $header->set_var( 'current_topic', '&topic=' . $topic ); } $allowedCounter = 0; $header->set_var( 'menuitem_url', $contributelink ); $header->set_var( 'menuitem_text', $LANG01[71] ); $header->parse( 'menu_elements', 'menuitem', true ); if(( isset( $_USER['uid'] ) && ( $_USER['uid'] > 1 )) || (( $_CONF['loginrequired'] == 0 ) && ( $_CONF['submitloginrequired'] == 0 ))) { $header->parse( 'allowed_menu_elements', 'menuitem', true ); $allowedCounter++; } // links link $header->set_var( 'menuitem_url', $_CONF['site_url'] . '/links.php' ); $header->set_var( 'menuitem_text', $LANG01[72] ); $header->parse( 'menu_elements', 'menuitem', true ); if(( isset( $_USER['uid'] ) && ( $_USER['uid'] > 1 )) || (( $_CONF['loginrequired'] == 0 ) && ( $_CONF['linksloginrequired'] == 0 ))) { $header->parse( 'allowed_menu_elements', 'menuitem', true ); $allowedCounter++; } // polls link $header->set_var( 'menuitem_url', $_CONF['site_url'] . '/pollbooth.php' ); $header->set_var( 'menuitem_text', $LANG01[73] ); $header->parse( 'menu_elements', 'menuitem', true ); if(( isset( $_USER['uid'] ) && ( $_USER['uid'] > 1 )) || (( $_CONF['loginrequired'] == 0 ) && ( $_CONF['pollsloginrequired'] == 0 ))) { $header->parse( 'allowed_menu_elements', 'menuitem', true ); $allowedCounter++; } // calendar link $header->set_var( 'menuitem_url', $_CONF['site_url'] . '/calendar.php' ); $header->set_var( 'menuitem_text', $LANG01[74] ); $header->parse( 'menu_elements', 'menuitem', true ); if(( isset( $_USER['uid'] ) && ( $_USER['uid'] > 1 )) || (( $_CONF['loginrequired'] == 0 ) && ( $_CONF['calendarloginrequired'] == 0 ))) { $header->parse( 'allowed_menu_elements', 'menuitem', true ); $allowedCounter++; } // Get plugin menu options $plugin_menu = PLG_getMenuItems(); if( $_COM_VERBOSE ) { COM_errorLog( 'num plugin menu items in header = ' . count( $plugin_menu ), 1 ); } if( count( $plugin_menu ) == 0 ) { $header->parse( 'plg_menu_elements', 'menuitem_none', true ); } else { for( $i = 1; $i <= count( $plugin_menu ); $i++ ) { $header->set_var( 'menuitem_url', current( $plugin_menu )); $header->set_var( 'menuitem_text', key( $plugin_menu )); if( $i == count( $plugin_menu )) { $header->parse( 'plg_menu_elements', 'menuitem_last', true ); } else { $header->parse( 'plg_menu_elements', 'menuitem', true ); } next( $plugin_menu ); } } // Search link $header->set_var( 'menuitem_url', $_CONF['site_url'] . '/search.php' ); $header->set_var( 'menuitem_text', $LANG01[75] ); $header->parse( 'menu_elements', 'menuitem', true ); if(( isset( $_USER['uid'] ) && ( $_USER['uid'] > 1 )) || (( $_CONF['loginrequired'] == 0 ) && ( $_CONF['searchloginrequired'] == 0 ))) { $header->parse( 'allowed_menu_elements', 'menuitem', true ); $allowedCounter++; } // Stats link $header->set_var( 'menuitem_url', $_CONF['site_url'] . '/stats.php' ); $header->set_var( 'menuitem_text', $LANG01[76] ); $header->parse( 'menu_elements', 'menuitem_last', true ); if(( isset( $_USER['uid'] ) && ( $_USER['uid'] > 1 )) || (( $_CONF['loginrequired'] == 0 ) && ( $_CONF['statsloginrequired'] == 0 ))) { $header->parse( 'allowed_menu_elements', 'menuitem', true ); $allowedCounter++; } if( $allowedCounter == 0 ) { $header->set_var( 'allowed_menu_elements', '' ); } if( $what <> 'none' ) { // Now show any blocks -- need to get the topic if not on home page if( !isset( $HTTP_GET_VARS['topic'] )) { if( isset( $HTTP_GET_VARS['story'] )) { $sid = COM_applyFilter( $HTTP_GET_VARS['story'] ); } elseif( isset( $HTTP_GET_VARS['sid'] )) { $sid = COM_applyFilter( $HTTP_GET_VARS['sid'] ); } elseif( isset( $HTTP_POST_VARS['story'] )) { $sid = COM_applyFilter( $HTTP_POST_VARS['story'] ); } if( !empty( $sid )) { $topic = DB_getItem( $_TABLES['stories'], 'tid', "sid='$sid'" ); } } else { $topic = COM_applyFilter( $HTTP_GET_VARS['topic'] ); } $header->set_var( 'geeklog_blocks', COM_showBlocks( 'left', $topic )); $header->parse( 'left_blocks', 'leftblocks', true ); } else { $header->set_var( 'geeklog_blocks', '' ); $header->set_var( 'left_blocks', '' ); } //call the right blocks if( $rightblock ) { $rblocks = COM_showBlocks( 'right', $topic ); } if( $rightblock && !empty( $rblocks )) { $header->set_var( 'geeklog_blocks', $rblocks ); $header->parse( 'right_blocks', 'rightblocks', true); } else { $header->set_var( 'geeklog_blocks', '' ); $header->set_var( 'right_blocks', '' ); } // Call any plugin that may want to include Extra Metatags or Javascript functions $header->set_var( 'plg_headercode', PLG_getHeaderCode()); // The following line allows users to embed PHP in their templates. This // is almost a contradition to the reasons for using templates but this may // prove useful at times...don't use PHP in templates if you can live without it $tmp = $header->parse( 'index_header', 'header' ); ob_start(); eval( '?>' . $tmp ); $retval = ob_get_contents(); ob_end_clean(); return $retval; }
Second, because this function is called from COM_siteHeader in lib-common.php, the parameter being passed to theme_siteHeader is done from COM_siteHeader. So here is GL core modified a little as I could get away with--these are the default lines that I am going to edit:
function COM_siteHeader( $what = 'menu' ) { global $_CONF, $_USER, $LANG01, $_COM_VERBOSE, $topic, $LANG_BUTTONS, $LANG_CHARSET; global $_TABLES, $HTTP_POST_VARS, $HTTP_GET_VARS; // If the theme implemented this for us then call their version instead. $function = $_CONF['theme'] . '_siteHeader'; if( function_exists( $function )) { return $function( $what ); }
Here are the modified lines:
function COM_siteHeader( $what = 'menu' , $rightblock = false ) { global $_CONF, $_USER, $LANG01, $_COM_VERBOSE, $topic, $LANG_BUTTONS, $LANG_CHARSET; global $_TABLES, $HTTP_POST_VARS, $HTTP_GET_VARS; // If the theme implemented this for us then call their version instead. $function = $_CONF['theme'] . '_siteHeader'; if( function_exists( $function )) { return $function( $what , $rightblock ); }
Third and last, if you want right blocks anywhere you need to pass the parameter to COM_siteHeader, for example, in your core file index.php, calling COM_siteHeader with blocks enabled would look like this: COM_siteHeader('',true);
If you don't want rightblocks on a particular page, just leave COM_siteHeader the way it is, ie, COM_siteHeader();
...and that's the way it is.
oh yeah, don't forget to actually write {right_blocks} into your header.thtml.
Posted on: 08/07/04 04:14am
By: machinari
Posted on: 08/08/04 03:22am
By: machinari
//call the right blocks $clicked = "http://"; $clicked .= $_SERVER['HTTP_HOST']; $clicked .= $_SERVER['REQUEST_URI']; $siteurl = $_CONF['site_url']."/"; $address = array($_CONF['site_url'].'/index.php', 'otherPagesFromWhichToLoadRightBlocks',); //default vars $header->set_var( 'geeklog_blocks', '' ); $header->set_var( 'right_blocks', '' ); //loads rightblocks if site url is called. if (( $siteurl != '') && ( $siteurl == $clicked )){ $rightblock = true; if( $rightblock ) { $rblocks = COM_showBlocks( 'right', $topic ); } if( $rightblock && !empty( $rblocks )) { $header->set_var( 'geeklog_blocks', $rblocks ); $header->parse( 'right_blocks', 'rightblocks', true); } else { $header->set_var( 'geeklog_blocks', '' ); $header->set_var( 'right_blocks', '' ); } } //loads rightblocks if address from array is called. elseif (!empty( $address )){ $rightblock = true; foreach ($address as $val){ if (eregi($val, $clicked)) { if( $rightblock ) { $rblocks = COM_showBlocks( 'right', $topic ); } if( $rightblock && !empty( $rblocks )) { $header->set_var( 'geeklog_blocks', $rblocks ); $header->parse( 'right_blocks', 'rightblocks', true); } else { $header->set_var( 'geeklog_blocks', '' ); $header->set_var( 'right_blocks', '' ); } } } }