Subject: staticpages.php and block function

Posted on: 05/06/06 10:44pm
By: ivy

staticpages php is very usefull.
example...

Portal blocks
echo DB_getItem( 'gl_blocks', 'content',"bid = '**'");
  bid is block id.



phpblock:
echo phpblock_polls();
echo phpblock_themetester();
and so on...




user_block
echo COM_showBlock('user_block');




admin_block
echo COM_showBlock('admin_block');




section_block
echo COM_showBlock('section_block');




events_block
echo COM_showBlock('events_block');




whats_new_block
echo COM_showBlock('whats_new_block');



staticpages.php and block function

Posted on: 19/08/06 01:48pm
By: koalasoft

as I can see block customized, to if?
echo DB_getItem( 'gl_blocks', 'content',"bid = 'My_block'");

ond
echo COM_showBlock('My_block');

this last one does not show anything



Greetings !!

staticpages.php and block function

Posted on: 19/08/06 02:03pm
By: samstone

The bid is found on the url when you are editing the block. It's not something you can name.

Sam

staticpages.php and block function

Posted on: 19/08/06 02:28pm
By: koalasoft

and where I look for the URL of block, single I see when publishing the name of block customized. for example:
echo COM_showBlock('block_name_customized');



Greetings!!

staticpages.php and block function

Posted on: 07/11/06 11:57am
By: LWC

This portal staticpage presents a problem - it just takes information from the current real portal block - with an emphasis on "current". So although it allows you to hide the real block and yet bypass its permissions and get its feed to the staticpage, if you want to keep the feed updated, it means one thing:
you must have the same feed both in a staticpage and in the left/right block around it - and who would want to do that?

If it isn't hidden, the way I see it there are 2 solutions: make a staticpage that implements its own version of COM_rdfImport or...

Steps to make a staticpage portal for BOTH hidden and none hidden portal blocks:
  1. Build yourself a real portal block.

  2. If you want the actual portal block to be hidden (so the feed would only show up in the staticpage), do the following:
    1. Disable the portal block (this makes it hidden).
    2. You might as well leave its topic on "All" since I shall totally ignore it anyway (staticpages [when used as centerblocks] have their own topic setting).

  3. Write the following in your PHP enabled staticpage:
    // http://lior.weissbrod.com presents...
    // A staticpage frontend for portal blocks
    // Version 0.1
    
    // Needed paramters - start
    // Enter Your Portal Block's ID
    // (configurable in the block editor)
    $bid = 'test';
    // Needed paramters - end
    
    // If it's disabled/hidden, do its job for it
    if (DB_getItem( $_TABLES['blocks'], 'is_enabled',
                                            "bid = '$bid'")) {
    // Gather parameters for the portal block
        $sql = "SELECT type, content, rdfur, date, rdflimit
    WHERE bid = '$bid'";
        $result = DB_query( $sql );
        $A = DB_fetchArray( $result );
        $A['bid'] = $bid;
    
    // Since COM_formatBlock completely ignores its $noboxes
    // (set to true below) paramter and takes it directly
    // from $_USER['noboxes']...
        $userboxes_backup = $_USER['noboxes'];
        $_USER['noboxes'] = true;
    
    // Update the hidden block if needed
        COM_formatBlock($A, true);
    
    // Again, because the above true was ignored
        $_USER['noboxes'] = $userboxes_backup;
    } else
        $A['bid'] = $bid;
    
    // Finally, paste the feed
                $A['content'] = DB_getItem( $_TABLES['blocks'], 'content',
                                            "bid = '{$A['bid']}'");
    echo $A['content'];
    


I haven't tested it yet - can anybody try and report back?

Re: staticpages.php and block function

Posted on: 03/12/06 06:09pm
By: tmarquez

I was able to take what you have LWC and make it work, how ever the one SQL statement was wrong:

PHP Formatted Code

$sql = "SELECT type, content, rdfur, date, rdflimit
WHERE bid = '$bid'"
;
 


I corrected it to this:

PHP Formatted Code

// Gather parameters for the portal block
    $sql = "SELECT type, content, rdfurl, rdfupdated , rdflimit FROM $_TABLES[blocks]
WHERE bid = $bid"
;
 


Also, it should be noted that the field bid is going to be a numeric value, so $bid = 'test' should be $bid = 123 for example. Thanks, I couldn't do the RSS feed without you!

Also, if you want to format it, to keep a consistent look with the rest of your geek log blocks, do this before you go into the RSS code :

PHP Formatted Code

$display .= COM_startBlock('RSS FEED', '','blockheader-left.thtml');
 


Or of course, come with a completely different template to use for the news feed!!! Love this geeklog! Now if I could only post engough so that my title on these forums wasn't "chatty"!

Re: staticpages.php and block function

Posted on: 15/04/08 09:43am
By: LWC

Alright, I've fixed all the problems that tmarquez raised with my portal staticpage, and even allowed format options.
Also, now you just need to know the block's name and not its bid.

PHP Formatted Code

// http://lior.weissbrod.com presents...
// A portal staticpage (that bases itself on a user created proper portal block)
// Version 0.5

    global $_TABLES;

$display = '';

// Needed parameters - start

// Enter your Portal Block's unique name (configurable in the block editor)
$name = 'test';
// Do you want to embed the feed inside a block - true/false?
$block_embed = 1;
// If so, choose which block - left/right or blank for a general block.
$block_type = '';
// Also if so, choose a title for the block
$block_title = "RSS Feed";

// Needed parameters - end

if ($block_embed && ($block_type == "left" || $block_type == "right")) {
$block_header = "blockheader-{$block_type}.thtml";
$block_footer = "blockfooter-{$block_type}.thtml";
}

$bid = DB_getItem( $_TABLES['blocks'], 'bid',
                                        "name = '$name'");

// If it's disabled/hidden, do its job for it
if (!DB_getItem( $_TABLES['blocks'], 'is_enabled',
                                        "bid = '$bid'")) {
// Gather parameters for the portal block
    $sql = "SELECT type, bid, rdfurl, rdfupdated as date, rdflimit FROM {$_TABLES['blocks']} WHERE bid = '$bid'";
    $result = DB_query( $sql );
    $A = DB_fetchArray( $result );

// Update the hidden block if needed
    COM_formatBlock($A, true);

} else
    $A['bid'] = $bid;

// Finally, paste the feed
            $A['content'] = DB_getItem( $_TABLES['blocks'], 'content',
                                        "bid = '{$A['bid']}'");

if ($block_embed) {
if (isset($block_header)) $display .= COM_startBlock($block_title, '',$block_header);
else $display .= COM_startBlock($block_title, '');
}
$display .= $A['content'];
if ($block_embed) {
if (isset($block_header)) $display .= COM_endBlock($block_footer);
else $display .= COM_endBlock();
}

echo $display;
 

Re: staticpages.php and block function

Posted on: 26/02/11 11:45am
By: koalasoft

Hi!!

This Working in Geeklog 1.7.2 ??

How??

this example NOT working
PHP Formatted Code
echo DB_getItem( 'gl_blocks', 'content',"bid = '**'");
  bid is block id.
 


but, this yes ..
PHP Formatted Code
echo COM_showBlock('user_block');
 


all in staticpages and enabled php

Greetings!! Mr. Green

Re: staticpages.php and block function

Posted on: 27/02/11 01:04pm
By: ::Ben

Hi,

This is working:
PHP Formatted Code
echo DB_getItem( 'gl_blocks', 'content',"bid = '105'");
 

Where 105 is my block id.

Do not include bid is block id. in your code.

::Ben

Geeklog - Forum
https://www.geeklog.net/forum/viewtopic.php?showtopic=67396