Uutiset:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu
Advertisement:

Adding Top 10 Topics to html home page

Aloittaja edchapman, elokuu 29, 2007, 07:27:35 IP

« edellinen - seuraava »

edchapman

Could someone please share how one could go about adding a Top 10 Topics (by Views) on my HTML home page? Is there some kind of script for doing so?

edchapman

#1
ok.. I did some more searching and found out how to pull from the ssi_examples.shtml file.

Is there a way to do this without changing your file from .html to .shtml?

Also... how would I go about making it board specific. I want to show the top ten viewed from two different boards.

Wal-Mart Security

It's not possible to do it from more then one board at the moment, perhaps SMF 2.0 will have that feature.  There would not be any easy way to use PHP in an ordinary .html file.  You could try using an iframe but it's really not that big of a deal to change a file extension.  You can read my guide about index action arrays right here and if you wanted to go all the way and change your site to .php extensions it would REALLY save you the trouble of updating multiple files for small changes.

Not only that, but it makes SSI a LOT easier to use.  An index action array isn't really as complicated or complex as it sounds, and my guide explains it in such a way that even a total n00b can figure out how to do it with minimal trouble.

If you have any more questions feel free to message me or email me, or even PM me right here on SMF.
Achilleus Technologies
Ace Gaming Syndicate
PART TIME SMF CHARTER MEMBER 4LIFE

SMF slays phpbb, puts it in an IPB coffin, and buries them both with the ashes of vBulletin.


edchapman

I think I found a solution... I did not want to change the file extension because I use a program that will not export anything other than .html.
So what I did was added both extensions (.shtml and .html) by naming the file home.shtml. .html gets added on export. leaving the file named home.shtml.html.
I tested this out and it works.
My question, before converting my site over is...... Do you foresee any problems doing this?

codenaught

As far as I know, the .shtml is just being part of the name. Some hosting configurations would allow you to use php and/or shtml in a .html file. Try to see if when it is just .html if it works. .shtml.html will look rather strange to many people.
Dev Consultant
Former SMF Doc Coordinator

edchapman

no... it only works if I have .shtml.html

edchapman

Lainaus käyttäjältä: Achilleus - elokuu 29, 2007, 11:56:20 IP
It's not possible to do it from more then one board at the moment, perhaps SMF 2.0 will have that feature. 

What I mean by this is....
Can I have a top 10 list just from board=1.0?

codenaught

#8
You can change the query in SSI.php to allow this.

Open SSI.php.

Find:

WHERE num" . ($type != 'replies' ? 'Views' : 'Replies') . " != 0

Change to:

WHERE num" . ($type != 'replies' ? 'Views' : 'Replies') . " != 0
AND ID_BOARD = 1

Find:

AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "

Change to:

AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
AND b.ID_BOARD = 1


How do I modify files?

You could also use:

First one:


WHERE num" . ($type != 'replies' ? 'Views' : 'Replies') . " != 0
                " . (isset($_REQUEST['board']) ? "AND ID_BOARD = " . (int) $_REQUEST['board'] . "" : '') . "


Second one:

AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
                         " . (isset($_REQUEST['board']) ? "AND b.ID_BOARD = " . (int) $_REQUEST['board'] . "" : '') . "


If you think you may want to change the ID someday or even remove the ID completely.

And right before you call the SSI function, add:

$_REQUEST['board'] = 1;
Dev Consultant
Former SMF Doc Coordinator

edchapman

Wow... thanks!.. I need to run to work right now... But I'll play with this later.

edchapman

ok... as you can tell... I'm a bit slow. :)
Sorry...

I understand (or so I think) this much...

There are two options above for me.
Both include editing the same lines in the SSI.php file.

What I do not get... is...
Lainaus käyttäjältä: akabugeyes - elokuu 30, 2007, 01:33:25 IP
And right before you call the SSI function, add:

$_REQUEST['board'] = 1;



codenaught

I forgot that you were using shtml and not php to call SSI. So ignore the line you quoted of mine and instead of using something like this:

<!--#include virtual="./SSI.php?ssi_function=topTopicsViews" -->

Try using this:

<!--#include virtual="./SSI.php?ssi_function=topTopicsViews;board=1" -->

The other code changes to SSI.php that I posted still need to be made.
Dev Consultant
Former SMF Doc Coordinator

edchapman



It returns nothing.
It also knocks out the "Top Topics by Replies Function" too.

edchapman

nevermind that.... I know why now... there is nothing there for it to grab.
I have everything under childboards.

So this presents my next challenge.. Ho do I get it to see just the child boards under board=1.0?

codenaught

Revert the change you made for the first one.

So this:

WHERE num" . ($type != 'replies' ? 'Views' : 'Replies') . " != 0
AND ID_BOARD = 1

Or:

WHERE num" . ($type != 'replies' ? 'Views' : 'Replies') . " != 0
                " . (isset($_REQUEST['board']) ? "AND ID_BOARD = " . (int) $_REQUEST['board'] . "" : '') . "


Becomes just this:

WHERE num" . ($type != 'replies' ? 'Views' : 'Replies') . " != 0

Then change the second one to be:

AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
                         " . (isset($_REQUEST['board']) ? "AND b.ID_PARENT = " . (int) $_REQUEST['board'] . "" : '') . "


Notice that the only thing changed is the b.ID_BOARD became b.ID_PARENT.
Dev Consultant
Former SMF Doc Coordinator

edchapman

ingenious!

That works great. I'm always blown away at the friendly help I get here. I hope someone else can use this too.

Thanks!!!

edchapman

#16
btw... If anyone wants to see this working on my site, the link is at --->Christian Guitar Charts.
You can see the "welcome" embedded into the home page.
I iframed the top 20 Christian chord charts by artist and songs.

Advertisement: