Welcome to Geeklog, Anonymous Saturday, December 21 2024 @ 09:33 pm EST

Geeklog Forums

Autotags Functions - Adding [showBlock:blockname]


gdl

Anonymous
This has been a standard for a while for many GL installations for me. Though suprsidr has set it up in the past with some secret sauce. I have been unable to achieve the same effect and I don't understand his latest instructions so I am asking here hoping it can be dumbed down and I can refer to this post in the future for new installations. This feature allows you to put Blocks where ever you want. Thus helping with the whole left/right block limitation of the professional theme.

I am trying to add the autotag [showBlock:] to GL 1.6.1.

From Autotags Editor:

Replace using function?
You must set the $_AUTO_CONF['allow_php'] configuration setting to '1' and be in a group with the autotags.PHP feature in order to modify autotags that call a function to translate the tag.


I have added the function to the functions.inc in the autotags plugins directory.

Text Formatted Code
function phpautotags_showBlocks($p1, $p2, $fulltag)
{
        if(!isset($p2)){
                $p2 = '';
        }
        return COM_showBlocks( $p1, $p2, '' );
}

    function phpautotags_showBlock($p1, $p2, $fulltag) {
        global $_TABLES;
        $display = '';
        $result = DB_query("SELECT * FROM {$_TABLES['blocks']} WHERE (name = '$p1')");
        $A = DB_fetchArray($result);
        if (! empty($A)) {
            if ($p2 == $p1) {
                $p2 = '';
            }
            $display = AT_formatBlock($A, $p2);
            $display .= "\n";
        } else {
            if (SEC_inGroup('Root')) {
                $display .= COM_startBlock($p1);
                $display .= "<br><strong>Sorry, we cannot find the block you were requesting.</strong><br>";
                ;
                $display .= COM_endBlock();
            }
        }
        return $display;
    }

/**
* Formats a Geeklog block
*
* @param        array     $A          Block Record
* @param        string    $useTemplate    Force block template ie. 'left', 'right', 'list'...
* @param        bool      $noboxes    Set to true if userpref is no blocks
* @return       string    HTML Formated block
*
*/
        function AT_formatBlock( $A, $useTemplate, $noboxes = false ) {
        global $_CONF, $_TABLES, $_USER, $LANG21;
       
        $retval = '';
       
        //$lang = COM_getLanguageId();
        $lang = 'en';
        if (!empty($lang)) {
            $blocksql['mssql']  = "SELECT bid, is_enabled, name, type, title, tid, blockorder, cast(content as text) as content, ";
            $blocksql['mssql'] .= "rdfurl, rdfupdated, rdflimit, onleft, phpblockfn, help, owner_id, ";
            $blocksql['mssql'] .= "group_id, perm_owner, perm_group, perm_members, perm_anon, allow_autotags,UNIX_TIMESTAMP(rdfupdated) AS date ";
       
            $blocksql['mysql'] = "SELECT *,UNIX_TIMESTAMP(rdfupdated) AS date ";
       
            $commonsql = "FROM {$_TABLES['blocks']} WHERE name = '"
                       . $A['name'] . '_' . $lang . "'";
       
            $blocksql['mysql'] .= $commonsql;
            $blocksql['mssql'] .= $commonsql;
            $result = DB_query( $blocksql );
       
            if (DB_numRows($result) == 1) {
                // overwrite with data for language-specific block
                $A = DB_fetchArray($result);
            }
        }
        if(in_array($useTemplate, array('left', 'right', 'message', 'related', 'list', 'config'))){
            $position = '-' . $useTemplate;
        }else if( array_key_exists( 'onleft', $A ) ) {
            if( $A['onleft'] == 1 )
            {
                $position = '-left';
            } else {
                $position = '-right';
            }
        } else {
            $position = '';
        }
       
        if( $A['type'] == 'portal' ) {
            if( COM_rdfCheck( $A['bid'], $A['rdfurl'], $A['date'], $A['rdflimit'] )) {
                $A['content'] = DB_getItem( $_TABLES['blocks'], 'content',
                                            "bid = '{$A['bid']}'");
            }
        }
       
        if( $A['type'] == 'gldefault' ) {
            $retval .= COM_showBlock( $A['name'], $A['help'], $A['title'], $position );
        }
       
        if( $A['type'] == 'phpblock' && !$noboxes ) {
            if( !( $A['name'] == 'whosonline_block' AND DB_getItem( $_TABLES['blocks'], "name='whosonline_block'" ) == 0 )) {
                $function = $A['phpblockfn'];
                $matches = array();
                if (preg_match('/^(phpblock_\w*)\\((.*)\\)$/', $function, $matches) == 1) {
                    $function = $matches[1];
                    $args = $matches[2];
                }
                $blkheader = COM_startBlock( $A['title'], $A['help'],
                        'blockheader'.$position.'.thtml');
                $blkfooter = COM_endBlock( 'blockfooter'.$position.'.thtml');
       
                if( function_exists( $function )) {
                   if (isset($args)) {
                        $fretval = $function($A, $args);
                   } else {
                        $fretval = $function();
                   }
                   if( !empty( $fretval )) {
                        $retval .= $blkheader;
                        $retval .= $fretval;
                        $retval .= $blkfooter;
                   }
                } else {
                    // show error message
                    $retval .= $blkheader;
                    $retval .= sprintf( $LANG21[31], $function );
                    $retval .= $blkfooter;
                }
            }
        }
       
        if( !empty( $A['content'] ) && ( trim( $A['content'] ) != '' ) && !$noboxes ) {
            $blockcontent = stripslashes( $A['content'] );
       
            // Hack: If the block content starts with a '<' assume it
            // contains HTML and do not call nl2br() which would only add
            // unwanted <br> tags.
       
            if( substr( $blockcontent, 0, 1 ) != '<' ) {
                $blockcontent = nl2br( $blockcontent );
            }
       
            // autotags are only(!) allowed in normal blocks
            if(( $A['allow_autotags'] == 1 ) && ( $A['type'] == 'normal' )) {
                $blockcontent = PLG_replaceTags( $blockcontent );
            }
            $blockcontent = str_replace( array( '<?', '?>' ), '', $blockcontent );
       
            $retval .= COM_startBlock( $A['title'], $A['help'],
                           'blockheader'.$position.'.thtml')
                    . $blockcontent . LB
                    . COM_endBlock( 'blockfooter'.$position.'.thtml');
        }
       
        return $retval;
    }



I have adjusted the autotags config.

$_AUTO_CONF['allow_php'] = 1;

I have also checked to see if I am in the Autotag Group. Yes I am admin and I am in the groups.

After asking suprsidr what I am missing, he responded with,

edit autotags admin to enable autotags php


Can anyone tell me what I am missing? Is he meaning a file in the public_html/admin/plugins/autotags directory? Is he talking about the Autotags Admin panel? Is their another configuration panel that is missing? I don't understand what the direction means.

I found this post from Blaine in 2007. I assume that since I am using Autotags 1.2 that this has been address and it isn't causing problems.

Thanks for any help you can offer.

-gdl
 Quote

Status: offline

suprsidr

Forum User
Full Member
Registered: 12/29/04
Posts: 555
Location:Champaign, Illinois
Edit Autotag Admin group -> http://www.flashyourweb.com/media/index.php?g2_itemId=40929&amp;g2_imageViewsIndex=4

still

-s
FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com
 Quote

gdl

Anonymous
Ahhhh! The "Group Admin". Yes a screenshot is worth a thousand words.

Thanks for that. From now on, I will know where to go.

-gdl
 Quote

All times are EST. The time is now 09:33 pm.

  • 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