Welcome to Geeklog, Anonymous Saturday, April 20 2024 @ 01:25 am EDT

Geeklog Forums

Dynamically refreshing block?


Status: offline

jnordquist

Forum User
Full Member
Registered: 03/14/03
Posts: 129
Location:Kenosha
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 or FlashChat installed.



John Nordquist,
Applications Specialist, medical Technologies
 Quote

Status: offline

Turias

Forum User
Full Member
Registered: 10/20/03
Posts: 807
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.
 Quote

Adrian

Anonymous
Doesn't the Chatterblock have both a js and iframe refresh option? So it must be possible.

Adrian Crook
 Quote

Status: offline

Turias

Forum User
Full Member
Registered: 10/20/03
Posts: 807
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.
 Quote

Status: offline

Blaine

Forum User
Moderator
Registered: 07/16/02
Posts: 1232
Location:Canada
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.
Geeklog components by PortalParts -- www.portalparts.com
 Quote

Status: offline

Turias

Forum User
Full Member
Registered: 10/20/03
Posts: 807
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.


What does it use to access the tables?
 Quote

Status: offline

Blaine

Forum User
Moderator
Registered: 07/16/02
Posts: 1232
Location:Canada
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.
Geeklog components by PortalParts -- www.portalparts.com
 Quote

Status: offline

jnordquist

Forum User
Full Member
Registered: 03/14/03
Posts: 129
Location:Kenosha
Quote by Blaine: I use an iframe whose source is a php file that includes lib-common and does what it needs to do.


So doing the same in the who's online block shouln'd be impossible?
John Nordquist,
Applications Specialist, medical Technologies
 Quote

Status: offline

Blaine

Forum User
Moderator
Registered: 07/16/02
Posts: 1232
Location:Canada
Yep - very doable. Just a SMOP (Simple Matter Of Programming) Cool
Geeklog components by PortalParts -- www.portalparts.com
 Quote

Status: offline

samstone

Forum User
Full Member
Registered: 09/29/02
Posts: 820
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. 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:

Text Formatted Code
<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.
 Quote

Status: offline

jnordquist

Forum User
Full Member
Registered: 03/14/03
Posts: 129
Location:Kenosha
Quote by Blaine: Yep - very doable. Just a SMOP (Simple Matter Of Programming) Cool



Bwahahahahaha! Therein lies the problem...
John Nordquist,
Applications Specialist, medical Technologies
 Quote

Status: offline

jnordquist

Forum User
Full Member
Registered: 03/14/03
Posts: 129
Location:Kenosha
Tried, failed, tried again, failed. This is why blocks and plugins are worth paying for.
John Nordquist,
Applications Specialist, medical Technologies
 Quote

Status: offline

Blaine

Forum User
Moderator
Registered: 07/16/02
Posts: 1232
Location:Canada
Send me an email describing what you need to do and I will see if I have some code that will work for you.
Geeklog components by PortalParts -- www.portalparts.com
 Quote

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