SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Neat script

Started by NIAB, July 22, 2013, 12:01:08 AM

Previous topic - Next topic


Hey guys,

I wanted it so my topTopics box on my front page (index) could show it by Views or by Replies, so I googled around and found this handy peice of code

Code ("Handy") Select


The way I have used it is so when you click a link (which in this case I have both Views and Replies) It reloads a specified file within a set div id.

Here's how I have used it
Code ("So what") Select

<script src="">
    $("#topTopic").load('Page Containing Views Stuff.php');;
    $("#topTopic").load('Page Containing Replies Stuff.php');
<a id="Views">Views</a>
<a id="Replies"">Replies</a>';
echo'<div id="WhatsHot">';
ssi_topTopics('replies', '8', 'array');

All it does is make it so when you click either "Views" or "Replies", it loads in the requested file. Of course if you just want to change a small line of text, or html. you can simply use .text or .html rather than .load.

Make sure you have the <?php ?> tags included in the loaded file, or it just loads the text from it. As well as including your SSI file :)

I'm sure most of you have found other methods of doing this, I just thought it was great and wanted to share.


What mine looks like.


NIAB would you like this to be moved to the Tips and Tricks board?

The Craw

Might also suggest a title that more accurately depicts the content of the post. "neat script" made me think it was a support question.

Biology Forums

Is this essentially AJAX-based?


It's completely AJAX based. The use of .load() shows that.


The elegance of jQuery :)
"If everybody is thinking alike, then somebody is not thinking." - Gen. George S. Patton Jr.



Quote from: Grumpy Old Sod on July 23, 2013, 07:15:20 PM
NIAB would you like this to be moved to the Tips and Tricks board?

Duly moved.

Biology Forums

I'm trying this myself, but I can't seem to get it to work. Could you provide the whole code?