Subject: Want to create a BLOCK that displays content in the center.

Posted on: 02/04/05 01:59pm
By: Anonymous

I am somewhat skilled in PHP, and understand how to create blocks and add the function to the custom_lib.

What I am not good at is understanding templates.

I want to add blocks that display their output in the center column (or left/right etc.) of the geeklog mainpage.

Can someone point me at an example of how I would do this, or maybe give me a basic description?

Thank you for any help.

Want to create a BLOCK that displays content in the center.

Posted on: 02/04/05 02:08pm
By: Dirk

[QUOTE BY= Zewt] I want to add blocks that display their output in the center column (or left/right etc.) of the geeklog mainpage.[/QUOTE]
For the center column, use a static page (and select "centerblock" in the options).

For left/right blocks, just create a PHP block. See What are the different block types for?

bye, Dirk

Want to create a BLOCK that displays content in the center.

Posted on: 02/04/05 02:18pm
By: Anonymous

Ok. I understand about creation of static pages, so if I create a custom php page to say display a list of friends.

How do I reference that PHP page so that it will be executed into the static page?

Assume that the php page is friends.php.

Or do I past the php code into the static page?

Want to create a BLOCK that displays content in the center.

Posted on: 02/04/05 02:26pm
By: Dirk

[QUOTE BY= Zewt] Or do I past the php code into the static page?[/QUOTE]
That's how PHP in static pages works.

Or you could include your file from the static page's PHP.

bye, Dirk

Want to create a BLOCK that displays content in the center.

Posted on: 02/04/05 02:39pm
By: Anonymous

Thanks Dirk. After reading that page on static pages and doing some tests, it all becomes clearer.

Apparently I can use the PHP include(), and so forth if needed.

I am just trying to link to a much larger, complex, back-end database system, and some code pages are large.

Ok got one more question...

Posted on: 02/04/05 02:50pm
By: Anonymous

Ok I have one more question, I think.

I want to have a link on the left that displays the static page on clicking.

So I tried creating a custom block that had a link to the static page.

The link works, but only if the static page is set to be automatically displayed as centerblock.

I do not want the static page to be displayed unless the link is clicked. And as it is currently the static page is always there when the home page is first loaded.

Any tips on what I am missing to do this?

Want to create a BLOCK that displays content in the center.

Posted on: 02/04/05 03:01pm
By: Dirk

[QUOTE BY= Zewt] I do not want the static page to be displayed unless the link is clicked.[/QUOTE]
Hmm, I don't think that's possible at the moment.

You could do that with a side block, since the block would not be displayed when it returns an empty string (so the PHP code in the block could decide when it should be displayed or not). For static pages, however, Geeklog always adds the block header and footer, even if the page is empty.

Shouldn't be too hard to change, though (in the plugin's functions.inc).

bye, Dirk

Want to create a BLOCK that displays content in the center.

Posted on: 02/04/05 04:07pm
By: machinari

[QUOTE BY= Dirk]however, Geeklog always adds the block header and footer, even if the page is empty.
[/QUOTE]what if you unchecked the "wrap static page in a block" option in the staticpages editor. ...and then if you still want that look, just add similar html to the staticpage.

Want to create a BLOCK that displays content in the center.

Posted on: 02/04/05 04:45pm
By: jhk

[QUOTE BY= Zewt] I do not want the static page to be displayed unless the link is clicked. And as it is currently the static page is always there when the home page is first loaded.[/QUOTE]
What you need is DHTML.

Don't wrap the staticpage in a block, but make it active on all pages as a centerblock. Put a DIV with a unique ID around all of the centent and make your side-block link hide and un-hide the DIV via Javascript. You can even set a cookie to save the preference for each user/pc.

I do something slightly similar on one of my staticpages, which is currently not used as a centerblock. It will be in a week a so. There are 30-odd DIVs hidden in that staticpage. (The buttons read "Matches yesterday", "Matches today", and "Matches tomorrow". The football season has not yet started, so until it does the block is not used. The dropdown menu works like a charm, however).

/Jens

Want to create a BLOCK that displays content in the center.

Posted on: 02/04/05 05:01pm
By: machinari

here ya go. I did it for you and didn't use any java script.
I used one php enable static page (not wrapped in a block), which can include a range of blocks/pages depending upon the link that is clicked.
I inserted the block footer divider so that it still looks somewhat like it is wrapped in a block.

try it here. just look for the links in the left column--"display blocks"--and click accordingly. by default no centerblock is displayed and when you click, viola, content appears.

the links include a get parm and here is the staticpage php.
if (empty($_GET['blk'])){
    return '';
} else {
    $retval .= <div class="centerblock">
    $retval .= '<p>This is a static page centerblock set to display on the';
    $retval .= ' homepage only.  Using a bit of PHP, it should only be';

    $retval .= ' viewable when the appropriate link is clicked.  This';
    $retval .= ' block is designated ';
    if ($_GET['blk'] == 'st1'){
        //you can call other blocks here or just different code--whatever.
        $retval .= '<strong>BLOCK #1</strong>.';
    } elseif ($_GET['blk'] == 'st2'){
        //you can call other blocks here or just different code--whatever.
        $retval .= '<strong>BLOCK #2</strong>.';
    } elseif ($_GET['blk'] == 'st3') {
        //you can call other blocks here or just different code--whatever.
        $retval .= '<strong>BLOCK #3</strong>.';
    }
    $retval .= '  Click the other block links to see the block change.</p>';
    $retval .= '</div>';
    $retval .= '<table class="block-divider" align="center" cellpadding="0" cellspacing="0" width="100%"><tr><td><img src="http://themes.summitpages.ca/images/speck.gif" alt="" height="2" width="1"></td></tr></table>';

    return $retval;
}


Want to create a BLOCK that displays content in the center.

Posted on: 02/04/05 06:12pm
By: jhk

machinari,

Did you user a PHP block or a regular one? With PHP I think it would be possible to combine the links with previous parameters via $_SERVER[QUERY_STRING'] and similar variables.

/Jens

Want to create a BLOCK that displays content in the center.

Posted on: 02/04/05 06:18pm
By: Anonymous

yup, just a normal block for the sake of the example, but if i wanted to be more practical, then yes, a php block would be the way to go

Want to create a BLOCK that displays content in the center.

Posted on: 02/04/05 06:31pm
By: Anonymous

Very nice.

I am new to GL, and was hoping it had the flexibility without extra coding. It looks though as if I will be needing to dive in to modify for my wants.

Thank you for all the feedback. Im sure I will be needing to get all kinds of great help for future mods, nice to see all the great help here.

Want to create a BLOCK that displays content in the center.

Posted on: 02/04/05 06:34pm
By: Anonymous

Im not sure I understand how one static page can have multiple blocks

Can you post the code for that one static page?

Want to create a BLOCK that displays content in the center.

Posted on: 02/04/05 06:54pm
By: Anonymous

Cannot seem to find what is causing this error


Parse error: parse error in C:Websiteshackpackpluginsstaticpagesfunctions.inc(475) : eval()'d code on line 4

Want to create a BLOCK that displays content in the center.

Posted on: 02/04/05 07:02pm
By: Anonymous

Ok found the problem.

some single quotes and a semicolon are missing from a line, I think the code for this chat board is removing some of the code.

Want to create a BLOCK that displays content in the center.

Posted on: 02/04/05 07:16pm
By: Anonymous

Here I have modified the code to add a fourth item, that uses an INCLUDE

if (empty($_GET['blk'])){
    return '';
} else {
    $retval .= '<div class="centerblock">';
    $retval .= '<p>This is a static page centerblock set to display on the';
    $retval .= ' homepage only.  Using a bit of PHP, it should only be';
    $retval .= ' viewable when the appropriate link is clicked.  This';
    $retval .= ' block is designated ';
    if ($_GET['blk'] == 'st1'){
        //you can call other blocks here or just different code--whatever.
        $retval .= '<strong>BLOCK #1</strong>.';
    } elseif ($_GET['blk'] == 'st2'){
        //you can call other blocks here or just different code--whatever.
        $retval .= '<strong>BLOCK #2</strong>.';
    } elseif ($_GET['blk'] == 'st3') {
        //you can call other blocks here or just different code--whatever.
        $retval .= '<strong>BLOCK #3</strong>.';
    } elseif ($_GET['blk'] == 'st4') {
        //you can call other blocks here or just different code--whatever.
        include ($_CONF['site_url'].'/teetime.php');
    }
    $retval .= '  Click the other block links to see the block change.</p>';
    $retval .= '</div>';
    $retval .= '<table class="block-divider" align="center" cellpadding="0" cellspacing="0" width="100%"><tr><td</td></tr></table>';

    return $retval;
}


Notice the fix for line 4, using single quotes and a semicolon at the end of the line.

Thanks for the code work MACHINARI, it has helped me start to unravel how GL can work for my application.

Want to create a BLOCK that displays content in the center.

Posted on: 02/04/05 07:21pm
By: jhk

[QUOTE BY= Zewt] Im not sure I understand how one static page can have multiple blocks

Can you post the code for that one static page?[/QUOTE]
That particular page has 169 lines of php with an additional 133 lines in lib-custom.php and a further 102 lines of Javascript. I'm not sure posting the code is feasable - or even useful to you as there is a lot of site specific code there as well as some php caching (using PEAR Cache.php).

The key to the whole thing is a Switch Content script I downloaded and adapted for my own use. Take a look at that page for instructions and inspiration.

Want to create a BLOCK that displays content in the center.

Posted on: 02/04/05 07:43pm
By: Anonymous

Here is the code for the static page:
ID is blk.

if (empty($_GET['blk'])){
    return '';
} else {
    $retval .= '<div class="centerblock">';
    //$retval .= '<p>This is a static page centerblock set to display on the';
   // $retval .= ' homepage only.  Using a bit of PHP, it should only be';
   // $retval .= ' viewable when the appropriate link is clicked.  This';
    //$retval .= ' block is designated ';
    if ($_GET['blk'] == 'st1'){
        //you can call other blocks here or just different code--whatever.
        $retval .= '<strong>BLOCK #1</strong>.';
    } elseif ($_GET['blk'] == 'st2'){
        //you can call other blocks here or just different code--whatever.
        $retval .= '<strong>BLOCK #2</strong>.';
    } elseif ($_GET['blk'] == 'st3') {
        //you can call other blocks here or just different code--whatever.
        $retval .= '<strong>BLOCK #3</strong>.';
    } elseif ($_GET['blk'] == 'st4') {
        //you can call other blocks here or just different code--whatever.
        include ($_CONF['site_url'].'/teetime.php');
    }
    //$retval .= '  Click the other block links to see the block change.</p>';
    $retval .= '</div>';
    $retval .= '<table class="block-divider" align="center" cellpadding="0" cellspacing="0" width="100%"><tr><td</td></tr></table>';

    return $retval;
}


Here is the function I added to lib-custom.php

function phpblock_rapp_test2() {

    global $_CONF, $_TABLES, $_USER, $LANG01;

    $retval = '';

    $retval .= '<a href="'.$_CONF['site_url'].'/index.php?blk=st1">Mather Mon.</a>';
    $retval .= '<a href="'.$_CONF['site_url'].'/index.php?blk=st2">Landpark Tues.</a>';
    $retval .= '<a href="'.$_CONF['site_url'].'/index.php?blk=st3">Landpark Wednesday.</a>';
    $retval .= '<a href="'.$_CONF['site_url'].'/index.php?blk=st4">TEST</a>';
    
    return $retval;
}



you then need to create a BLOCK to call the custom function:
The BLOCK TYPE needs to be: PHP BLOCK
and the BLOCK FUNCTION needs to be: phpblock_rapp_test2


I'm setting up something to display tee times, sorry if my labels suck as decriptions.

Also for the blk=4 part, you need to create a basic php page called teetime.php.

you can use this code if you like:


<?php

// This is teetime.php

print "CUSTOM INCLUDED PAGE"

?>


Want to create a BLOCK that displays content in the center.

Posted on: 02/04/05 07:59pm
By: Anonymous

It is definitely better to use PHP vs. DHTML.

What the code listed above is doing is basic PHP. Basically passing a variable using the URL.

this part
index.php?blk=st4
that you see in the URL is where blk is being made a variable, and being assigned the value of st4.

The ? in
index.php?blk=st4
is telling PHP that the next characters will be a variable, and the = is assigning st4 to blk.

What happens next is in the PHP code of the static page.

this line:
if (empty($_GET['blk'])){

is looking at the variable blk. The
$_GET[***]
part is a PHP built in global variable function.

The $_GET['blk'] is the part that retrieves the value in
blk.

you could just get the value in BLK once by assigning it to a new variable.

such as
$testvar = $_GET['blk']

Now just use
$testvar
instead of
$_GET['blk']
everytime.

Want to create a BLOCK that displays content in the center.

Posted on: 03/04/05 05:06am
By: jhk

[QUOTE BY= Zewt] It is definitely better to use PHP vs. DHTML.[/QUOTE]
Is it?

A mix of the two is a very powerful combination. PHP to create dynamic DHTML and the DHTML itself to create fancy effects without contacting the server on each little click.

Two different tools for your webcoding toolbox.

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