Jump to content

can someone FIX my messed up code?


Mikez

Recommended Posts

Hi,

I am using Geeklog (blogg program like php nuke) And I want to put feeds on my front page that are not in side blocks.

Geeklog lets you put feeds in side blocks but not in the center of the main page.

So what I am doing is trying to let the block pull the feed and hide the block.

I got it working somewhat with this code.

<?php
global $_TABLES;

$res = DB_query("SELECT * from {$_TABLES['blocks']} WHERE bid in (25)");
while ($row = DB_fetchArray($res)) {
        $display .= COM_formatBlock($row);
}

echo $display;
?>

 

But I don't know how to do more then one and keep it organized. Like in a table.

This is what I did so far.

 

        <table cellspacing="1" cellpadding="10" width="100%" align="center" summary="" border="1">
            <tbody>
                <tr>
                    <td>
<?php
global $_TABLES;

$res = DB_query("SELECT * from {$_TABLES['blocks']} WHERE bid in (25)");
while ($row = DB_fetchArray($res)) {
        $display .= COM_formatBlock($row);
}

echo $display;
?>
                   </td>
                    <td>
<?php
$res = DB_query("SELECT * from {$_TABLES['blocks']} WHERE bid in (24)");
while ($row = DB_fetchArray($res)) {
        $display .= COM_formatBlock($row);
}

echo $display; 
?>
               </td>
                    <td>
<?php
$res = DB_query("SELECT * from {$_TABLES['blocks']} WHERE bid in (24)");
while ($row = DB_fetchArray($res)) {
        $display .= COM_formatBlock($row);
}

echo $display; 
?>
               </td>

                </tr>
            </tbody>
        </table>

 

But it's all over the place.

It's adding lines that I don't want. And no there not part of the table.

Also there putting the code over and over in blocks.

 

He is a screen shot of how bad it is.

 

http://www.freakworld.com/albums/Freak-s-Pics/bad_php.jpg

 

Can someone please help me....  :'(

Link to comment
https://forums.phpfreaks.com/topic/105059-can-someone-fix-my-messed-up-code/
Share on other sites

I almost have my code to work!!!

But it's putting a line/border on the end of each table.

How do I get that out?

It's that the table doing it it's the PHP code.

 

?>
        <table cellspacing="1" cellpadding="10" width="100%" align="center" summary="" border="1">
            <tbody>
                <tr>
                    <td>
<?php
global $_TABLES;

$res = DB_query("SELECT * from {$_TABLES['blocks']} WHERE bid in (25)");
while ($row = DB_fetchArray($res)) {
        $display1 .= COM_formatBlock($row);
}

echo $display1;
?>
                   </td>
                    <td>
<?php
$res = DB_query("SELECT * from {$_TABLES['blocks']} WHERE bid in (24)");
while ($row = DB_fetchArray($res)) {
        $display2 .= COM_formatBlock($row);
}

echo $display2; 
?>
               </td>
                    <td>
<?php
$res = DB_query("SELECT * from {$_TABLES['blocks']} WHERE bid in (24)");
while ($row = DB_fetchArray($res)) {
        $display3 .= COM_formatBlock($row);
}

echo $display3; 
?>
               </td>

                </tr>
            </tbody>
        </table>

the only place I can find it is my lib-common.

If thats it is there not a way just to take it out?

 

/**
* Formats a Geeklog block
*
* This shows a single block and is typically called from
* COM_showBlocks OR from plugin code
*
* @param        array     $A          Block Record
* @param        bool      $noboxes    Set to true if userpref is no blocks
* @return       string    HTML Formated block
*
*/
function COM_formatBlock( $A, $noboxes = false )
{
    global $_CONF, $_TABLES, $_USER, $LANG21;

    $retval = '';
    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'] );
    }

    if( $A['type'] == 'phpblock' && !$noboxes )
    {
        if( !( $A['name'] == 'whosonline_block' AND DB_getItem( $_TABLES['blocks'], 'is_enabled', "name='whosonline_block'" ) == 0 ))
        {
            $function = $A['phpblockfn'];
            $blkheader = COM_startBlock( $A['title'], $A['help'],
                    COM_getBlockTemplate( $A['name'], 'header' ));
            $blkfooter = COM_endBlock( COM_getBlockTemplate( $A['name'],
                    'footer' ));

            if( function_exists( $function ))
            {
                $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'] );

I know were it comes from.

formatBlock is pulling up the code from lib-common. From there is calling up code from the CSS to make a block.

(Block: The boxes on the left and right of sights made by programs like post nuke and geeklog.)

What I don't know is how to take out formatBlock with out breaking the code.

The part in the CSS file that it is calling up "block-divider"will also change other themes that need the line.

So I can't just change the CSS.  :P

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.