Welcome to Geeklog, Anonymous Saturday, April 20 2024 @ 09:01 am EDT

Geeklog Forums

right_blocks in different file


Stu

Anonymous
Hello, As part of a site I'm doing I'm css-ifying the geeklog theme I'm using, however when I try and move {right_blocks} into header.php I just get the text {right_blocks}
How can I get it to allow me to put this into that file?
 Quote

Status: offline

beewee

Forum User
Full Member
Registered: 08/05/03
Posts: 969
Location:The Netherlands, where else?
{right_blocks} is only allowed in the footer, so you'll have to adjust your design I'm afraid.

Also have a look here
Dutch Geeklog sites about camping/hiking:
www.kampeerzaken.nl | www.campersite.nl | www.caravans.nl | www.caravans.net
 Quote

Status: offline

drshakagee

Forum User
Full Member
Registered: 10/01/03
Posts: 231
If it is truly a must, there is ways around that. I have the right blocks in the header on this site: mentalstout.com (you might want to check it in firefox or something else, I don't have time to make it work in IE right now).

It is kind of a long process, but you have to create your own version of the COM_siteHeader function in your theme's functions.php file (name your new function "yourthemename_siteHeader"), and add the right blocks to a variable there.

Here is my custom siteHeader function for that mentalstout page:
Text Formatted Code

function csstest_siteHeader( $what = 'menu', $pagetitle = '', $headercode = '' )
{
     global $_CONF, $_TABLES, $_USER, $LANG01, $LANG_BUTTONS, $LANG_CHARSET,
           $_IMAGE_TYPE, $topic, $_COM_VERBOSE;

   
    $centerblockid = 'centerblocks-noblocks';
    $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'
        ));

    // get topic if not on home page
    if( !isset( $_GET['topic'] ))
    {
        if( isset( $_GET['story'] ))
        {
            $sid = COM_applyFilter( $_GET['story'] );
        }
        elseif( isset( $_GET['sid'] ))
        {
            $sid = COM_applyFilter( $_GET['sid'] );
        }
        elseif( isset( $_POST['story'] ))
        {
            $sid = COM_applyFilter( $_POST['story'] );
        }
        if( !empty( $sid ))
        {
            $topic = DB_getItem( $_TABLES['stories'], 'tid', "sid='$sid'" );
        }
    }
    else
    {
        $topic = COM_applyFilter( $_GET['topic'] );
    }

    $feed_url = '';
    if( $_CONF['backend'] == 1 ) // add feed-link to header if applicable
    {
        $feedpath = $_CONF['rdf_file'];
        $pos = strrpos( $feedpath, '/' );
        $feed = substr( $feedpath, 0, $pos + 1 );
        $baseurl = substr_replace( $feed, $_CONF['site_url'], 0,
                                   strlen( $_CONF['path_html'] ) - 1 );

        $sql = 'SELECT format, filename, title FROM '
             . $_TABLES['syndication'] . " WHERE (header_tid = 'all')";
        if( !empty( $topic ))
        {
            $sql .= " OR (header_tid = '" . addslashes( $topic ) . "')";
        }
        $result = DB_query( $sql );
        $numRows = DB_numRows( $result );
        for( $i = 0; $i < $numRows; $i++ )
        {
            $A = DB_fetchArray( $result );
            if ( !empty( $A['filename'] ))
            {
                $format = explode( '-', $A['format'] );
                $format_type = strtolower( $format[0] );
                $format_name = ucwords( $format[0] );

                $feed_url .= '<link rel="alternate" type="application/'
                          . $format_type . '+xml" title="' . $format_name
                          . ' Feed: ' . $A['title'] . '" href="' . $baseurl
                          . $A['filename'] . '">' . LB;
            }
        }
    }
    $header->set_var( 'feed_url', $feed_url );

    if( empty( $pagetitle ) && isset( $_CONF['pagetitle'] ))
    {
        $pagetitle = $_CONF['pagetitle'];
    }
    if( empty( $pagetitle ))
    {
        if( empty( $topic ))
        {
            $pagetitle = $_CONF['site_slogan'];
        }
        else
        {
            $pagetitle = stripslashes( DB_getItem( $_TABLES['topics'], 'topic',
                                                   "tid = '$topic'" ));
        }
    }
    if( !empty( $pagetitle ))
    {
        $pagetitle = ' - ' . $pagetitle;
    }
    $header->set_var( 'page_title', $_CONF['site_name'] . $pagetitle );

    if (isset ($_CONF['advanced_editor']) && ($_CONF['advanced_editor'] == 1) &&
        file_exists ($_CONF['path_layout'] . 'advanced_editor_header.thtml')) {
        $header->set_file( 'editor'  , 'advanced_editor_header.thtml');
        $header->parse( 'advanced_editor', 'editor' );

    } else {
         $header->set_var( 'advanced_editor', '' );
    }
    $header->set_var( 'background_image', $_CONF['layout_url']
                                          . '/images/bg.' . $_IMAGE_TYPE );
    $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.' . $_IMAGE_TYPE );
    $header->set_var( 'css_url', $_CONF['layout_url'] . '/style.css' );
    $header->set_var( 'layout_url', $_CONF['layout_url'] );
    $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_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] );
    $header->set_var( 'button_directory', $LANG_BUTTONS[11] );

    // Get plugin menu options
    $plugin_menu = PLG_getMenuItems();

    if( $_COM_VERBOSE )
    {
        COM_errorLog( 'num plugin menu items in header = ' . count( $plugin_menu ), 1 );
    }

    // Now add nested template for menu items
    COM_renderMenu( $header, $plugin_menu );

    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 );
        }
    }


    if( $_CONF['left_blocks_in_footer'] == 1 )
    {
        $header->set_var( 'geeklog_blocks', '' );
        $header->set_var( 'left_blocks', '' );
    }
    else
    {
        $lblocks = '';

        /* Check if an array has been passed that includes the name of a plugin
         * function or custom function
         * This can be used to take control over what blocks are then displayed
         */
        if( is_array( $what ))
        {
            $function = $what[0];
            if( function_exists( $function ))
            {
                $lblocks = $function( $what[1], 'left' );
            }
        }
        else if( $what <> 'none' )
        {
            // Now show any blocks -- need to get the topic if not on home page
            $lblocks = COM_showBlocks( 'left', $topic );
        }

        if( empty( $lblocks ))
        {
            $header->set_var( 'geeklog_blocks', '' );
            $header->set_var( 'left_blocks', '' );
        }
        else
        {
            $header->set_var( 'geeklog_blocks', $lblocks );
            $header->parse( 'left_blocks', 'leftblocks', true );
            $centerblockid = 'centerblocks-leftblocks';
        }
       
       
       
    }
   //call the right blocks
    $clicked = "http://";
    $clicked .= $_SERVER['HTTP_HOST'];
    $clicked .= $_SERVER['REQUEST_URI'];
    $siteurl = $_CONF['site_url']."/";
   
    // add something unique in the url of pages you DON'T want the right blocks to appear on right blocks will be on every other page. For instance put 'article.php' to not show the right blocks on article pages, put "search.php?query=" if you want the blocks to show on the main search page but not on the results page.
   
    $address = array('admin', 'article.php', 'gus', 'comment.php', '/music/', 'inmemoriam');
        //default vars
    $header->set_var( 'geeklog_blocks', '' );
    $header->set_var( 'right_blocks', '' );
    $header->set_var( 'centerblockid', $centerblockid );
   
        // loads rightblocks if the url isn't in the array address
    if (!empty( $address )){
        $rightblock = true;
        foreach ($address as $val){
            if (eregi($val, $clicked)) {
               $showrightblocks = 'false';
           }else if($showrightblocks != 'false') {
               $showrightblocks = 'true';
             }
         }
                if( $rightblock && $showrightblocks=='true') {
                    $rblocks = COM_showBlocks( 'right', $topic );
                }
                if( $rightblock && !empty( $rblocks )) {
               
                    if ($centerblockid == 'centerblocks-leftblocks'){
                    $centerblockid = 'centerblocks-bothblocks';
                    }else{
                    $centerblockid = 'centerblocks-rightblocks';
                    }
                    $header->set_var( 'centerblockid', $centerblockid );
                    $rblocks = '<div id="rightblocks">' . $rblocks . '</div>';
                    $header->set_var( 'geeklog_blocks', $rblocks );
                    $header->parse( 'right_blocks', 'rightblocks', true);
                   
                    //break;
                } else {  
                    $header->set_var( 'geeklog_blocks', '' );
                    $header->set_var( 'right_blocks', '' );
                }
           
       
    }
   

    // Call any plugin that may want to include extra Meta tags
    // or Javascript functions
    $header->set_var( 'plg_headercode', $headercode . PLG_getHeaderCode() );

    // Call to plugins to set template variables in the header
    PLG_templateSetVars( 'header', $header );

    // The following lines allow 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;
}


 


No guarantees that it will work on your site and you will have to adjust the part where it sets the $address variable to make the right blocks not show on some pages.

Good luck :-)
Yes I am mental.
 Quote

Status: offline

jetshack

Forum User
Full Member
Registered: 06/29/04
Posts: 122
Location:Texas
hey drshakagee

I love this... how'd you do it?

http://mentalstout.com/source/directory.php
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by jetshack: I love this... how'd you do it?

http://mentalstout.com/source/directory.php

That's a 1.3.12 feature. The good doctor seems to be running the CVS version.

bye, Dirk
 Quote

Status: offline

jetshack

Forum User
Full Member
Registered: 06/29/04
Posts: 122
Location:Texas
Almost enough to make me try it out...

the only other thing on my want list is the ability to assign a story to more than 1 topic.
 Quote

Status: offline

drshakagee

Forum User
Full Member
Registered: 10/01/03
Posts: 231
Yeah that directory page is really sweet, it is one of many great additions to the cvs version you should try it out. Actually if I remember correctly that directory page works fine with 1.3.11 just grab it from the cvs version upload to your 1.3.11 public_html add a link and your good to go.
Yes I am mental.
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by drshakagee: Actually if I remember correctly that directory page works fine with 1.3.11 just grab it from the cvs version upload to your 1.3.11 public_html add a link and your good to go.

Grab version 1.1 of the script then. 1.2 expect the text strings in the language file.

bye, Dirk
 Quote

Stu

Anonymous
Cheers... after some fiddling in lib-common.php I managed to get it working... I might be on a slightly different version so I looked in lib-common.php at the siteFooter stuff to find the info about right blocks, cheers for pointing me in the right direction!
Big Celebration
 Quote

All times are EDT. The time is now 09:01 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content