Posted on: 04/26/04 12:52pm
By: jnordquist
This may be far-fetched, but is it possible to add code to a block (like a small .js) to refresh it's display at a selected interval?
This would be great for the Who's Online block in particular, especially if you have Blaine's
glMessenger[*1] or
FlashChat[*2] installed.
Dynamically refreshing block?
Posted on: 04/26/04 01:06pm
By: Turias
The problem is mixing Javascript with php. The who's online block is calculated using php, so the server does it before the page loads. Javascript is completely clientside. So, you can't easily use javascript to get new server-side info.
The best way to do it would be to put the contents of what you want to refresh in an iframe, and then have javascript reload that iframe at a specified interval.
Not as nice, but better than nothing, I guess.
Dynamically refreshing block?
Posted on: 04/26/04 02:02pm
By: Anonymous (Adrian)
Doesn't the Chatterblock have both a js and iframe refresh option? So it must be possible.
Adrian Crook[*3]
Dynamically refreshing block?
Posted on: 04/26/04 02:08pm
By: Turias
Sure it's possible to do with some blocks. I don't know much about the chatterblock. I was mainly referring to the Who's Online block.
Basically, you are going to have trouble with a block that needs to communicate with the system database.
Dynamically refreshing block?
Posted on: 04/26/04 04:06pm
By: Blaine
Yep - Chatterblock is the only example currently of a self-refreshing block. It access the tables and the concept could be used for other blocks.
In chatterblock, each user can specify their own refresh rate. Only that one block is updated, the rest of the page does not change.
Dynamically refreshing block?
Posted on: 04/26/04 04:27pm
By: Turias
[QUOTE BY= Blaine] Yep - Chatterblock is the only example currently of a self-refreshing block. It access the tables and the concept could be used for other blocks.
In chatterblock, each user can specify their own refresh rate. Only that one block is updated, the rest of the page does not change.[/QUOTE]
What does it use to access the tables?
Dynamically refreshing block?
Posted on: 04/26/04 04:37pm
By: Blaine
I use an iframe whose source is a php file that includes lib-common and does what it needs to do.
BTW: The forum does the same thing when you are posting a reply and I show the topic in a iframe window below the new-post window.
Dynamically refreshing block?
Posted on: 04/26/04 06:15pm
By: jnordquist
[QUOTE BY= Blaine] I use an iframe whose source is a php file that includes lib-common and does what it needs to do.[/QUOTE]
So doing the same in the who's online block shouln'd be impossible?
Dynamically refreshing block?
Posted on: 04/26/04 07:19pm
By: Blaine
Yep - very doable. Just a SMOP (Simple Matter Of Programming)
Dynamically refreshing block?
Posted on: 04/27/04 01:37am
By: samstone
Since we are on this topic. I created a random photo block (since I can't make the current RandomPhoto v1.2 to work with the new Gallery 1.4.3 final) using iframe and js and the block-random.php optained from
here[*4] . The code was written for stand alone Gallery, but it works fine with GL-Gallery integration.
The js was supposed to go to the header, but I put it in the block and it works. My question would be, is there any stupidity in so doing?
The following is the codes I put in the block:
<script language="JavaScript" type="text/javascript">
// document.domain='yourdomain.com'; // Uncomment and edit if "Access is Denied" runtime JavaScript error occurs
function iFrameHeight(obj) {
aID = obj.id; // if contentDocument exists, W3C compliant (Mozilla)
if (document.getElementById(aID).contentDocument){
obj.style.height = document.getElementById(aID).contentDocument.body.scrollHeight;
} else {
// IE
obj.style.height = document.frames(aID).document.body.scrollHeight;
}
}</script>
<table align="center"><tr><td align="center">
<iframe src="/gallery/block-random.php?size=150&target=_top" width="150" height="200"
onLoad="iFrameHeight(this);"
align=top scrolling=no frameborder=0 id="blockrandom1">
[This feature requires IFRAME.]
</iframe></td></tr></table>
Note: it works without the js, but having the js in it makes the block resize according to the picture's height.
Dynamically refreshing block?
Posted on: 05/01/04 12:29am
By: jnordquist
[QUOTE BY= Blaine] Yep - very doable. Just a SMOP (Simple Matter Of Programming)

[/QUOTE]
Bwahahahahaha! Therein lies the problem...
Dynamically refreshing block?
Posted on: 05/06/04 11:27am
By: jnordquist
Tried, failed, tried again, failed. This is why blocks and plugins are worth paying for.
Dynamically refreshing block?
Posted on: 05/06/04 12:11pm
By: Blaine
Send me an email describing what you need to do and I will see if I have some code that will work for you.