Uutiset:

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

Main Menu
Advertisement:

How to show last X topics on home page?

Aloittaja marco.panichi, marraskuu 02, 2013, 09:29:53 AP

« edellinen - seuraava »

marco.panichi

I'm using SFM 2.0.6.

I'd like to put into my home page the X last topics published in any boards.

I've tried to use the $context variable inside the "// Show lots of posts" section of BoardIndex.template.php file, but I've understood after some tests that these are POSTS and not TOPIC.

I've seen in other discussion that I could use a Portal to make this customization but I'd prefer to hard code my theme instead.

Thank you for every suggestion.

margarett

If your home page is not part of the forum you need to use SSI.
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

LainaaOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

emanuele

Did you already try: admin > configuration > current theme and change the "Number of recent posts to display on board index"?


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

marco.panichi

Hi guys, thank you for the quick reply, but it doesn't solve my problem.

LainaaIf your home page is not part of the forum you need to use SSI.

No, is the forum home page

LainaaDid you already try: admin > configuration > current theme and change the "Number of recent posts to display on board index"?

Yes I saw this setting but the problem is that I don't want POSTS, but TOPICS. I want to show the last (for example) 30 topics ordered by last update.

margarett

Ah, that.

Yeah, that's probably not existent right now, as that information isn't fetched anywhere, I believe.

This would require to add at least a DB query and show that information at BoardIndex.template.php
Something I can't do on the phone :P
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

LainaaOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair


marco.panichi

Thank you again. I'd prefer not to use a modification. I'll do some tests and I'll let you know.

emanuele

Of course you are not forced to use one, but you can use it to see what it does.

Out of curiosity: why don't you want to use a mod?


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

marco.panichi

Ciao Emanuele,

I don't want to use mods when I use a system for the first time, mainly for these reasons:
- security: I want to know how mods (and the system itself) work before using lots of them
- customization: Using a mod is surely a time saver at the beginning, but could be a problem if more customizations are needed
- learning: I can learn lots hardcoding some features

Regarding my initial problem, I've solved with this query:
SELECT
t.id_topic, t.is_sticky, t.id_board, t.id_first_msg, t.id_last_msg, t.id_member_started, t.id_member_updated, t.id_poll,
t.id_previous_board, t.id_previous_topic, t.num_replies, t.num_views, t.locked, t.unapproved_posts, t.approved,

mf.id_msg AS mf_id_msg, mf.id_topic AS mf_id_topic, mf.id_board AS mf_id_board, mf.poster_time AS mf_poster_time,
mf.id_member AS mf_id_member, mf.id_msg_modified AS mf_id_msg_modified, mf.subject AS mf_subject, mf.poster_name AS mf_poster_name,
mf.poster_email AS mf_poster_email, mf.poster_ip AS mf_poster_ip, mf.smileys_enabled AS smileys_enabled, mf.modified_time AS mf_modified_time,
mf.modified_name AS mf_modified_name, mf.body AS mf_body, mf.icon AS mf_icon, mf.approved AS mf_approved,

ml.id_msg AS ml_id_msg, ml.id_topic AS ml_id_topic, ml.id_board AS ml_id_board, ml.poster_time AS ml_poster_time,
ml.id_member AS ml_id_member, ml.id_msg_modified AS ml_id_msg_modified, ml.subject AS ml_subject, ml.poster_name AS ml_poster_name,
ml.poster_email AS ml_poster_email, ml.poster_ip AS ml_poster_ip, ml.smileys_enabled AS smileys_enabled, ml.modified_time AS ml_modified_time,
ml.modified_name AS ml_modified_name, ml.body AS ml_body, ml.icon AS ml_icon, ml.approved AS ml_approved
FROM
[PREFIX]topics AS t
INNER JOIN [PREFIX]messages AS mf ON (mf.id_msg = t.id_first_msg)
INNER JOIN [PREFIX]messages AS ml ON (ml.id_msg = t.id_last_msg)
ORDER BY t.id_last_msg DESC
LIMIT 20


Yes I know! It's not good to do this. But the client absolutly required that particular conditions are satisfied in spite of my suggestions and alerts... ::)

emanuele

Lainaus käyttäjältä: marco.panichi - marraskuu 04, 2013, 04:04:54 AP
- learning: I can learn lots hardcoding some features
That's the only good reason in your list. :P

Lainaus käyttäjältä: marco.panichi - marraskuu 04, 2013, 04:04:54 AP
- security: I want to know how mods (and the system itself) work before using lots of them
You can check security of mods too, just read the code.

Lainaus käyttäjältä: marco.panichi - marraskuu 04, 2013, 04:04:54 AP
- customization: Using a mod is surely a time saver at the beginning, but could be a problem if more customizations are needed
A "mod" is not a magic thing, it's just code to be placed "somewhere", what you do is grab the code and add it. The package manager is a support to the installation of mods, but is not mandatory at all. I'm not using it in most of the forums I support (despite the fact that if anyone else would pick the support would have to learn how to use git), I just apply changes by hands (changing what I don't like) and then commit the changes to a git repo. ;)

Lainaus käyttäjältä: marco.panichi - marraskuu 04, 2013, 04:04:54 AP
Regarding my initial problem, I've solved with this query:
SELECT
t.id_topic, t.is_sticky, t.id_board, t.id_first_msg, t.id_last_msg, t.id_member_started, t.id_member_updated, t.id_poll,
t.id_previous_board, t.id_previous_topic, t.num_replies, t.num_views, t.locked, t.unapproved_posts, t.approved,

mf.id_msg AS mf_id_msg, mf.id_topic AS mf_id_topic, mf.id_board AS mf_id_board, mf.poster_time AS mf_poster_time,
mf.id_member AS mf_id_member, mf.id_msg_modified AS mf_id_msg_modified, mf.subject AS mf_subject, mf.poster_name AS mf_poster_name,
mf.poster_email AS mf_poster_email, mf.poster_ip AS mf_poster_ip, mf.smileys_enabled AS smileys_enabled, mf.modified_time AS mf_modified_time,
mf.modified_name AS mf_modified_name, mf.body AS mf_body, mf.icon AS mf_icon, mf.approved AS mf_approved,

ml.id_msg AS ml_id_msg, ml.id_topic AS ml_id_topic, ml.id_board AS ml_id_board, ml.poster_time AS ml_poster_time,
ml.id_member AS ml_id_member, ml.id_msg_modified AS ml_id_msg_modified, ml.subject AS ml_subject, ml.poster_name AS ml_poster_name,
ml.poster_email AS ml_poster_email, ml.poster_ip AS ml_poster_ip, ml.smileys_enabled AS smileys_enabled, ml.modified_time AS ml_modified_time,
ml.modified_name AS ml_modified_name, ml.body AS ml_body, ml.icon AS ml_icon, ml.approved AS ml_approved
FROM
[PREFIX]topics AS t
INNER JOIN [PREFIX]messages AS mf ON (mf.id_msg = t.id_first_msg)
INNER JOIN [PREFIX]messages AS ml ON (ml.id_msg = t.id_last_msg)
ORDER BY t.id_last_msg DESC
LIMIT 20


Yes I know! It's not good to do this. But the client absolutly required that particular conditions are satisfied in spite of my suggestions and alerts... ::)
Ugly! :o :P
I'm pretty sure the next requirement will be attachments, so be ready for it. :P


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

margarett

I would suggest you pick one of the existing mods and "study" it. Being a package or not, custom coding also fits as a mod ;)
So, if you're coding yourself, you will also be making a MODification ;)

As for your code, you just need ID, first message ID+subject and poster name in order to build a link ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

LainaaOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

marco.panichi

First of all, thank you vey much for your support. I really appreciate your work and I'm starting to appreciate the SFM too.

Regarding the security I've studied some modification (in particular the http://custom.simplemachines.org/mods/index.php?mod=1414 modification  that I used to make the query above) and now I'm less "scared". You are right, cit. A "mod" is not a magic thing

I've also used the package manager and understood that I prefer not to use it, because copying and customizing the code by myself is more comfortable as you said.

LainaaUgly! :o :P
I made ​​a bet with myself about your comment on my query and I have to say that you were very nice compared to my predictions  :D But you know, I solved the client's problem and established with him that there will be no further changes (attachment problem: FIXED!  ;) )

LainaaAs for your code, you just need ID, first message ID+subject and poster name in order to build a link
I have these fields in my query: mf = message first / ml = message last.

Thank you again...!

Colin

Lainaa
I've also used the package manager and understood that I prefer not to use it, because copying and customizing the code by myself is more comfortable as you said.

I am glad that you got everything working, but I would really encourage you to use mods. The benefit of using mods is all of the code changes are accounted for and can be easily removed and readded if need be. The package manager is rather efficient. In terms of mod quality the customization team vets each modification on initial submission for compliance with the coding guidelines so it isn't a totally loose process. Rather than stray away from it because of some preconceptions, have a look around, ask, give it a try, and form your own opinion. I think it might be quite different from what it is now.
"If everybody is thinking alike, then somebody is not thinking." - Gen. George S. Patton Jr.

Colin

marco.panichi

Hi Colin,

I have no preconceptions, really. I've used the packet manager successfully to install three mods. I also want to consider the manual installation because I feel I have more consciousness on the entire project.

Advertisement: