Welcome to Geeklog, Anonymous Friday, March 29 2024 @ 11:01 am EDT

Geeklog Forums

Show Any Block on right side for article views


Status: offline

ByteEnable

Forum User
Full Member
Registered: 10/20/03
Posts: 138
Here is a easy way to show blocks on the right side during article views.

Files to edit:

lib-custom.php
article.php
article.thtml

This function goes in lib-custom.php
Text Formatted Code

function COM_showOneBlock( $logical_blk_name )
{
        global $_TABLES, $_USER;

        $retval = '';

        $result = DB_query("SELECT * FROM {$_TABLES['blocks']} WHERE name = '{$logical_blk_name}' AND is_enabled = 1");
        $A = DB_fetchArray( $result );

        if( SEC_hasAccess( $A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm _anon']) > 0 )
        {
                $retval .= COM_formatBlock( $A, $_USER['noboxes'] );
        }
return $retval;
}

 


Now you need to add your blocks to article.php as shown around line 187
You can get the logical block name from the block editor.
Text Formatted Code

//START NEW CODE
$My_Block = COM_showOneBlock("logical_block_name");
//END NEW CODE
$story_template->set_var ('whats_related', $related);
$story_template->set_var ('story_options', $optionsblock);
//START NEW CODE
$story_template->set_var ('show_custom_block', $My_Block);
//END NEW CODE
$story_template->set_var ('whats_related_story_options', $related . $optionsblock );

 


Add this to your /layout/your_theme/article/article.thtml
Text Formatted Code

<td valign="top">{show_custom_block}</td>

 


You can add as many blocks as you want. I thought about editing the static page block function in lib-common.php for
the COM_showOneBlock, but I would have to edit lib-common.php again, and I'm tired of doing that on upgrades. See LinuxElectrons to see how it looks.
 Quote

All times are EDT. The time is now 11: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