Welcome to Geeklog, Anonymous Wednesday, October 09 2024 @ 08:47 am EDT

Geeklog Forums

staticpages.php and block function


Status: offline

ivy

Forum User
Full Member
Registered: 11/25/04
Posts: 314
Location:Tokyo Japan
angelic
staticpages php is very usefull.
example...

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

 


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


 


user_block
Text Formatted Code
echo COM_showBlock('user_block');


 


admin_block
Text Formatted Code
echo COM_showBlock('admin_block');


 


section_block
Text Formatted Code
echo COM_showBlock('section_block');


 


events_block
Text Formatted Code
echo COM_showBlock('events_block');


 


whats_new_block
Text Formatted Code
echo COM_showBlock('whats_new_block');


 
Wink Wink
Geeklog Japan https://www.geeklog.jp
 Quote

Status: offline

koalasoft

Forum User
Full Member
Registered: 03/09/05
Posts: 242
Location:Mexico
as I can see block customized, to if?
Text Formatted Code

echo DB_getItem( 'gl_blocks', 'content',"bid = 'My_block'");
 

ond
Text Formatted Code
echo COM_showBlock('My_block');
 

this last one does not show anything Sad

Question Question

Greetings !! Mr. Green
**Cuando el Alumno esta listo, el Maestro Aparece **
::Geeklog support in Spanish::
 Quote

Status: offline

samstone

Forum User
Full Member
Registered: 09/29/02
Posts: 820
The bid is found on the url when you are editing the block. It's not something you can name.

Sam
 Quote

Status: offline

koalasoft

Forum User
Full Member
Registered: 03/09/05
Posts: 242
Location:Mexico
and where I look for the URL of block, single I see when publishing the name of block customized. for example:
Text Formatted Code
echo COM_showBlock('block_name_customized');
 

Giving it a try

Greetings!! Mr. Green
**Cuando el Alumno esta listo, el Maestro Aparece **
::Geeklog support in Spanish::
 Quote

Status: offline

LWC

Forum User
Full Member
Registered: 02/19/04
Posts: 818
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:
    Text Formatted Code
    // 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?
 Quote

Status: offline

tmarquez

Forum User
Regular Poster
Registered: 06/17/03
Posts: 70
I was able to take what you have LWC and make it work, how ever the one SQL statement was wrong:

Text Formatted Code

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


I corrected it to this:

Text 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 :

Text 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"!
T.Marquez Jr. -
Webmaster -
www.indianapolisfilm.net - Geeklog 1.4.0sr5-1
 Quote

Status: offline

LWC

Forum User
Full Member
Registered: 02/19/04
Posts: 818
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.

Text 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;
 
 Quote

Status: offline

koalasoft

Forum User
Full Member
Registered: 03/09/05
Posts: 242
Location:Mexico
Hi!!

This Working in Geeklog 1.7.2 ??

How??

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


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


all in staticpages and enabled php

Greetings!! Mr. Green
**Cuando el Alumno esta listo, el Maestro Aparece **
::Geeklog support in Spanish::
 Quote

Status: offline

::Ben

Forum User
Full Member
Registered: 01/14/05
Posts: 1569
Location:la rochelle, France
Hi,

This is working:
Text 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
I'm available to customise your themes or plugins for your Geeklog CMS
 Quote

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