1 (edited by CodeXP 2006-11-24 14:03)

Topic: AJAX meets extern.php: Active topics etc.

EDIT: Updated script to fix a problem with Firefox. If you downloaded before this edit, download it again and just overwrite the old javascript.

So, the other day I was playing around with Ajax for the first time, and decided that I quite like it. As a result, I made a "active topics" box for PunBB that updates in real-time without having to refresh the page.

Installation is about as simple as can be. Just upload the included files, then add <pun_include "ajax_extern.php"> in your mail.tpl where you want to display it. This provides a simple way to stay up-to-date on what's going on in your forums:)

By default, the box refreshes every 15 seconds, but that's easy to edit by changing the timer variable at the top of the supplied .js.


Installation:

1. Unzip the archive into your PunBB root directory, keeping the folder structure ( uploads ajax_extern.js into ./include/js/ , and ajax_extern.php into ./include/user/ )
2. Open ./include/template/main.tpl and add <pun_include "ajax_extern.php"> where you want the box to show up. Under <pun_announcement> might be a good place..
3. Enjoy.

Note: if there is any pages you don't want the box to show up on, just add the page name to the array at line 3 in ajax_extern.php. Also, seeing as you won't be editing any of PunBB's source code, this will probably work just fine with sites like mypunbb etc. as well smile

Note 2: If you'd like to change the number of topics, just get topics from specific forums etc., change line 25 of the javascript.

[DOWNLOAD HERE]

Re: AJAX meets extern.php: Active topics etc.

Cheers will have a look at this over the weekend.

Next question... What you working on next wink ?

Re: AJAX meets extern.php: Active topics etc.

StevenBullen wrote:

Cheers will have a look at this over the weekend.

Next question... What you working on next wink ?

Hehe, I have absolutely no idea..yet wink Was thinking about perhaps trying to get the quick post feature to use ajax, similar to how the later versions of vBulletin works, but I'm just getting started with javascripting, so we'll have to see...

Re: AJAX meets extern.php: Active topics etc.

I just tried it with firefox 1.5.0.1  (with adblock and greasemonkey turned off) and it doesn't work.  Works in IE on my machine.  Anyone else with this problem?

Re: AJAX meets extern.php: Active topics etc.

cytexone wrote:

I just tried it with firefox 1.5.0.1  (with adblock and greasemonkey turned off) and it doesn't work.  Works in IE on my machine.  Anyone else with this problem?

Same problem ...

Re: AJAX meets extern.php: Active topics etc.

cytexone wrote:

I just tried it with firefox 1.5.0.1  (with adblock and greasemonkey turned off) and it doesn't work.  Works in IE on my machine.  Anyone else with this problem?

Re-download the archive, and overwrite old javascript. The reason for the failure in Firefox was how I had ordered the execution of the commands. It worked in Opera & IE, but not FF. That has now been fixed smile

This applies for everyone downloading before I made this post: re-download.

Re: AJAX meets extern.php: Active topics etc.

sweet - thanks!

Re: AJAX meets extern.php: Active topics etc.

Thanks ... It work with FF now, but I have problem with accentuated characters

Directly from extern.php I have no problem (http://forum.windows.free.fr/forum/exte … length=100) :

* panne d'enregistrement depuis la mise en veille
* récupérer tous les pilotes de son ordi
* photo
* FREE ADSL : retour à la normale le 17 mars en zone non dégroupée
* windows xp
* Freebox Haute Définition chez Free avant la rentrée 2006
* Problème synchronisation profil
* Mots chinois
* installation du SP2 impossible
* FAT 32 ou NTFS?

But with AJAX Active public topics it looks like :

* panne d'enregistrement depuis la mise en veille
* r?cup?rer tous les pilotes de son ordi
* photo
* FREE ADSL : retour ? la normale le 17 mars en zone non d?group?e
* windows xp
* Freebox Haute D?finition chez Free avant la rentr?e 2006
* Probl?me synchronisation profil
* Mots chinois
* installation du SP2 impossible
* FAT 32 ou NTFS?

I have "?" instead of "é" ... probably the same thing with other accentuated characters, I don't have  made other tests.

Can you help me ?

Thanks

Re: AJAX meets extern.php: Active topics etc.

FxPatrice wrote:

Thanks ... It work with FF now, but I have problem with accentuated characters

Directly from extern.php I have no problem (http://forum.windows.free.fr/forum/exte … length=100) :

* panne d'enregistrement depuis la mise en veille
* récupérer tous les pilotes de son ordi
* photo
* FREE ADSL : retour à la normale le 17 mars en zone non dégroupée
* windows xp
* Freebox Haute Définition chez Free avant la rentrée 2006
* Problème synchronisation profil
* Mots chinois
* installation du SP2 impossible
* FAT 32 ou NTFS?

But with AJAX Active public topics it looks like :

* panne d'enregistrement depuis la mise en veille
* r?cup?rer tous les pilotes de son ordi
* photo
* FREE ADSL : retour ? la normale le 17 mars en zone non d?group?e
* windows xp
* Freebox Haute D?finition chez Free avant la rentr?e 2006
* Probl?me synchronisation profil
* Mots chinois
* installation du SP2 impossible
* FAT 32 ou NTFS?

I have "?" instead of "é" ... probably the same thing with other accentuated characters, I don't have  made other tests.

Can you help me ?

Thanks

That's because javascript have problems handling it without any specific headers (in this case, utf-8).

To fix, do the following:
1. Open extern.php, and find on line 245:

        $result = $db->query('SELECT t.id, t.subject FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL'.$forum_sql.' ORDER BY '.$order_by.' DESC LIMIT '.$show) or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());

Below add:

        if(isset($_GET['utf-8'])) @header("Content-type: text/html; charset=utf-8"); // Needed for accented characters w. JS/Ajax

2. Open ./include/js/ajax_extern.js, and fine on line 25:

var extern_query = 'extern.php?action=active&show=10&length=100&rnd='+rnd;

Replace with:

var extern_query = 'extern.php?action=active&show=10&length=100&utf-8=1&rnd='+rnd;

3. Save, upload and enjoy accented characters that looks correct smile

10 (edited by FxPatrice 2006-03-17 20:18)

Re: AJAX meets extern.php: Active topics etc.

Thanks for your help ... It now works for me with your modification (with "iso-8859-1" instead of "utf-8" in my case)

Nice Mod' smile I'm using it in a private area of my forum for that time ...

11

Re: AJAX meets extern.php: Active topics etc.

FxPatrice wrote:

Thanks for your help ... It now works for me with your modification (with "iso-8859-1" instead of "utf-8" in my case)

Nice Mod' smile I'm using it in a private area of my forum for that time ...

Glad to hear it's working smile

Re: AJAX meets extern.php: Active topics etc.

This is pretty smooth. smile Great job!

I don't HAVE a signature, ok?

13

Re: AJAX meets extern.php: Active topics etc.

creaturecorp wrote:

This is pretty smooth. smile Great job!

Thanks, hope you'll find a use for it smile

14

Re: AJAX meets extern.php: Active topics etc.

I'm unable to download this, is the server down?

if anyone can email it to me, I'd be happy smile
endre@princefams.com

Re: AJAX meets extern.php: Active topics etc.

@CodeXP

Can you make this available again please?

16

Re: AJAX meets extern.php: Active topics etc.

StevenBullen wrote:

@CodeXP

Can you make this available again please?

Just uploaded it to punres.org, so that people can grab it even if my server is down smile

Topic: http://www.punres.org/viewtopic.php?id=1494

Re: AJAX meets extern.php: Active topics etc.

Many thanks

18

Re: AJAX meets extern.php: Active topics etc.

Thanks.
3 small requests.

1. the length of topic names , i change it from 200 to 1000 but still the topic names are short, i want to show the full name
2. adding the small icons before the topic names would make it much more fun to look, where i can add this in the code
3. how to change to longer the time that script refresh

Thanks again for simple and nice mod.

19

Re: AJAX meets extern.php: Active topics etc.

coxis wrote:

Thanks.
3 small requests.

1. the length of topic names , i change it from 200 to 1000 but still the topic names are short, i want to show the full name
2. adding the small icons before the topic names would make it much more fun to look, where i can add this in the code
3. how to change to longer the time that script refresh

Thanks again for simple and nice mod.

My mod doesn't actually affect the data output as such. All output are fetched from the standard PunBB extern.php. If you'd like to change point 1 & 2, you'd have to make the changes to that file (see line 104).

As for #3, it's quite easy. Just open ./include/js/ajax_extern.js and change line 7 (var timer = 15;) to whatever you'd like smile

20

Re: AJAX meets extern.php: Active topics etc.

Ok thanks. Uuups i didn't see that sad

The mod is great but it would great to make it more elegant look with this icons.

21

Re: AJAX meets extern.php: Active topics etc.

coxis wrote:

Ok thanks. Uuups i didn't see that sad

The mod is great but it would great to make it more elegant look with this icons.

What you could do, is just style it using CSS. The container block got an id with the name of "rssbox", so it should be quite simple.

Just do something like:

#rssbox li {
   padding-left: 16px;
   background: url('path/to/icon.gif') left center no-repeat
}

This would be suitable for 16x16px icons, but of course, just style as you see fit. I would never mix the styling with code, seeing as that's the whole reason we got style sheets wink

22 (edited by coxis 2006-05-22 18:37)

Re: AJAX meets extern.php: Active topics etc.

Hey man thanks alot smile
See it yourself: http://guistyles.com/forum/index.php

One more. Maybe you know how to make Announcement and Active public topics in the same line , near themself.
A table with two columns. One column will be Announcement and second Active public topics.
smile

23

Re: AJAX meets extern.php: Active topics etc.

Hey i really don't know how to handle this. Can somebody helps me ?

Re: AJAX meets extern.php: Active topics etc.

Is there a way you can display the topics horizontally, instead of verticly?

Right now they display like:

Topic 1
Topic 2
Topic 3
Topic 4


I'd like it to display like

Topic 1 / Topic 2 / Topic 3

Or use anything inplace of "/" that is just an example. The main thing is getting it to display horiztontally

25

Re: AJAX meets extern.php: Active topics etc.

viperjosh wrote:

Is there a way you can display the topics horizontally, instead of verticly?

Right now they display like:

Topic 1
Topic 2
Topic 3
Topic 4


I'd like it to display like

Topic 1 / Topic 2 / Topic 3

Or use anything inplace of "/" that is just an example. The main thing is getting it to display horiztontally

Just use CSS to style it. Example:

.pun #rssbox li { display: inline; margin: 0 }
.pun #rssbox li:first-child:before { content: "" }
.pun #rssbox li:before { content: " / "  }

* Note that the :before & :first-child selector won't work in IE (or older browsers in general), but there are many different ways you could use instead (background-image etc.). Alternatively, edit your extern.php to add in the "/"