Posted on: 11/25/07 12:15pm
By: jcz
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[*1]
Any thoughts?
Re: A static page of blocks?
Posted on: 11/25/07 12:29pm
By: jcz
Re: A static page of blocks?
Posted on: 11/25/07 03:20pm
By: jmucchiello
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.
Re: A static page of blocks?
Posted on: 11/26/07 08:23pm
By: jcz
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)
Re: A static page of blocks?
Posted on: 11/26/07 08:36pm
By: jcz
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?
Re: A static page of blocks?
Posted on: 11/26/07 09:22pm
By: jmucchiello
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.
Re: A static page of blocks?
Posted on: 11/27/07 08:30am
By: jcz
Oh, sorry. Clearly I'm not coder.
Could you please provide a complete example?
Re: A static page of blocks?
Posted on: 11/27/07 01:36pm
By: jmucchiello
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");
Re: A static page of blocks?
Posted on: 11/27/07 08:33pm
By: jcz
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.