Welcome to Geeklog, Anonymous Saturday, December 21 2024 @ 11:04 am EST

Geeklog Forums

A static page of blocks?


Status: offline

jcz

Forum User
Chatty
Registered: 01/29/02
Posts: 39
I did a little snooping but didn't see a post that directly addresses what I'm after.

I really want to have a page of blocks (like a portal site such as iGoogle). For now it would just show all of the RSS blocks I've created that are bloating my right and left columns.

Of course to be really useful they'd all have to be AJAX'd so the page itself doesn't take a gazzilion years to load.

This post looks for creating an RSS static page, but we already have RSS reading libraries in GL that I want to appear in the same page.
http://www.geeklog.net/forum/viewtopic.php?showtopic=66832

Any thoughts?

 Quote

Status: offline

jcz

Forum User
Chatty
Registered: 01/29/02
Posts: 39
Here are some related posts:
Chatterblock static page?
http://www.geeklog.net/forum/viewtopic.php?showtopic=56245

GL-Friendly feed aggregator?
http://www.geeklog.net/forum/viewtopic.php?showtopic=62592

The chatterblock option is more what I'm after. But, that is for a third party block. How do I access the Portal Block functions within GL itself?
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
In the blocks section, disable the blocks you want to include on the static page but don't want on you left/right columns. Don't delete them, just disable them.

In your staticpage do something like this:
Text Formatted Code
    $res = DB_query("SELECT * from {$_TABLES['blocks']} WHERE bid in (some list of bids)");
    while ($row = DB_fetchArray($res)) {
        $display .= COM_formatBlock($row);
    }
    return /*or echo*/ $display;
How you generate your list of bids is up to you.
 Quote

Status: offline

jcz

Forum User
Chatty
Registered: 01/29/02
Posts: 39
Hmm. Looks easy. Here is the results of my first try. My DB has portal blocks with BIDs from 16 to 23. All are disabled.

So I put the following into a static page and tried the page with both "Execute PHP" and "Execute PHP(return)" options selected in the static page editor.

Text Formatted Code

    $res = DB_query("SELECT * from {$_TABLES['blocks']} WHERE bid in (17,18)");
    while ($row = DB_fetchArray($res)) {
        $display .= COM_formatBlock($row);
    }
    return /*or echo*/ $display;
 


I got the following,

An SQL error has occurred. Please see error.log for details.


Here is the error log entry

Text Formatted Code

Mon 26 Nov 2007 08:16:30 EST - 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE bid in (17,18)' at line 1. SQL in question: SELECT * from  WHERE bid in  (17,18)
 
 Quote

Status: offline

jcz

Forum User
Chatty
Registered: 01/29/02
Posts: 39
I'll add this to this thread: I had to disable the blocks earlier because they were dragging down the rendering of the whole homepage. It was taking nearly a minute (I was surprised PHP or my browser didn't time out). This makes perfect sense: I had like 6 portal blocks all trying to update and waiting for their feeds to finish before the whole page on my end would render.

Of course what is really needed is to make blocks be AJAX'd so they load independently of the page a la iGoogle.

But until then I could live with forcing the blocks to load only say once an hour, and then I'll ping the site every so often with a wget request to force update them to not penalize users.

Question is: how do I tune how often the blocks update? I can only find this post which no one responded to.

http://www.geeklog.net/forum/viewtopic.php?showtopic=42610

Thoughts?
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
Quote by: jcz
Here is the error log entry

Text Formatted Code

Mon 26 Nov 2007 08:16:30 EST - 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE bid in (17,18)' at line 1. SQL in question: SELECT * from  WHERE bid in  (17,18)
 
[/p]
You need to add global $_TABLES; to the beginning of your static page source. I didn't say my solution was complete. I said try something like this.

Likewise it says "return /* or echo */" because I didn't know if you were using "Execute PHP" or "Execute PHP (return)". If return, then you can remove the "or echo" and vice versa.

If you need more explicit instructions, let me know and I'll actually try to do this on a running copy of Geeklog.
 Quote

Status: offline

jcz

Forum User
Chatty
Registered: 01/29/02
Posts: 39
Oh, sorry. Clearly I'm not coder.Oops!

Could you please provide a complete example?
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
Create a static page with Execute PHP (return) type. You probably want to turn off putting the page inside a block as well.
Text Formatted Code
global $_TABLES;

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

Alternatively, you might make sure all the blocks have a similar name (not title) such as portal_1, portal_2, portal_3, etc. Then you could use this sql:

Text Formatted Code
$res = DB_query("SELECT * from {$_TABLES['blocks']} WHERE name like 'portal_%' order by title");
 Quote

Status: offline

jcz

Forum User
Chatty
Registered: 01/29/02
Posts: 39
Thank you so much.

I used your last option and it worked like a champ... except with 2 feeds the page takes about 30 seconds to load.

With 6 feeds you have to go get a cup of coffee.
 Quote

All times are EST. The time is now 11:04 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