phpBB.com     phpBB Academy     phpBB Modders     phpBB Weekly     ktuk     phpBB Hacks     Vlad Studio  

[FUNCTION] get_announcements

Pull latest X topic titles from a certain forum and diplay them on any page.

Not enough for a full proper MOD, but too useful not to share
Forum rules
Please read over our forum guidelines

[FUNCTION] get_announcements

Postby kenny » 09 Dec 2008, 22:19

In case anyone runs into the same issue I did with nothing showing (possibly after updating to 3.0.3)
Code: Select all
* @version $Id: functions_announce.php 0014 14:29 17/08/2008 kenny

Code: Select all
* @version $Id: functions_announce.php 0016 22:05 09/12/2008 kenny

FIND:
Code: Select all
        $result = $db->sql_query_limit($an_sql, $topic_limit);

        $db->sql_freeresult($result); 

REPLACE WITH:
Comment:
Essentially delete "$db->sql_freeresult($result);"

Code: Select all
        $result = $db->sql_query_limit($an_sql, $topic_limit);

FIND:
Code: Select all
          ));   

        
} 

REPLACE WITH:
Code: Select all
          ));   
        
}
        $db->sql_freeresult($result); 
|| 6 String Romance || Myspace || phpBB.com || Need Freelance Work? ||
If you need one of my MODs installed - click here


Are you a musician in the Glasgow area interested in acoustic events? The ArtBox
User avatar
kenny kenny is probably rawking out on RockBand \m/
Project Leader
Project Leader
 
Posts: 647
Joined: 06 Jun 2008, 11:38
Location: Airdrie, UK

Donate to 6 String MODs
If you like any of the work that I do here, please consider donating.
click the image on the left for a list of some of the advantages of donating



[FUNCTION] get_announcements

Postby Stoker » 22 Feb 2010, 14:46

Thanks for this snippet, working fine 8-)

I have to questions though:
How do we get post date on this? I would like it to appear like this:
12. feb 2010 - Topic title here


I want several individual boxes posting from several forums.
How do I do this?
User avatar
Stoker
Registered User
Registered User
 
Posts: 2
Joined: 22 Feb 2010, 14:30

Re: [FUNCTION] get_announcements

Postby kenny » 22 Feb 2010, 19:00

Pretty simple by the looks of it:
Add the topic_time to the SQL query
Code: Select all
$an_sql = SELECT topic_id, forum_id, topic_title, topic_time

And add it to the vars array
Code: Select all
'TOPIC_TIME'         => date("jS F Y, G:i:s", $announce['topic_time']), 

The output that to the HTML file wherever you want it to show (remember that it needs to be within the announce_row block)
Code: Select all
{announce_row.TOPIC_TIME}


Using that same logic, you can pretty much pull anything else from the topics table and output it. Note that I just used date() to format the time, if you want to use the user defined date format, you will need to global $user in the function and change that line to:
Code: Select all
'TOPIC_TIME'         => $user->format_date($announce['topic_time']), 
|| 6 String Romance || Myspace || phpBB.com || Need Freelance Work? ||
If you need one of my MODs installed - click here


Are you a musician in the Glasgow area interested in acoustic events? The ArtBox
User avatar
kenny kenny is probably rawking out on RockBand \m/
Project Leader
Project Leader
 
Posts: 647
Joined: 06 Jun 2008, 11:38
Location: Airdrie, UK

Re: [FUNCTION] get_announcements

Postby Stoker » 22 Feb 2010, 19:30

Thanks for the answer.

And how do I place several boxes with news from several forums?
Lets say that I want announcements from 4 different forums.
User avatar
Stoker
Registered User
Registered User
 
Posts: 2
Joined: 22 Feb 2010, 14:30

Re: [FUNCTION] get_announcements

Postby kenny » 22 Feb 2010, 19:36

Right now, it's not really possible to do that. Currently, you have to duplicate the function and html file
More info in this post :) viewtopic.php?p=136#p136
|| 6 String Romance || Myspace || phpBB.com || Need Freelance Work? ||
If you need one of my MODs installed - click here


Are you a musician in the Glasgow area interested in acoustic events? The ArtBox
User avatar
kenny kenny is probably rawking out on RockBand \m/
Project Leader
Project Leader
 
Posts: 647
Joined: 06 Jun 2008, 11:38
Location: Airdrie, UK

Re: [FUNCTION] get_announcements

Postby Pete » 24 Feb 2010, 10:56

So it wouldn't be a very efficient to have posts from different forums? would it be more possible with just one forum? this is extremely close to what I am after .. I kinda want something like what wordpress e-zine style templates handle their articles. '
Main featured article on top ( I have that taken care of ) and say, 3 other featured articles with snippet/maybe thumbnail with the article under the main featured article.
I guess the image would be taken care of with bbcode. Think i can come up with something similiar with the link you provided?
User avatar
Pete
Registered User
Registered User
 
Posts: 3
Joined: 24 Feb 2010, 10:40

Re: [FUNCTION] get_announcements

Postby kenny » 24 Feb 2010, 11:02

It's not that it's not efficient, it's just that this snippet does not have the ability to take posts from more than 1 forum. If you try and use the function more than once on a page, it breaks - I haven't been able to track the issue down yet.

There are some other MODs/Snippets out there that will do this for you. I'll have a poke about and see what I can find. in the mean time, you may want to have a browse through the MODs Database or Development forums on phpBB.com :)
|| 6 String Romance || Myspace || phpBB.com || Need Freelance Work? ||
If you need one of my MODs installed - click here


Are you a musician in the Glasgow area interested in acoustic events? The ArtBox
User avatar
kenny kenny is probably rawking out on RockBand \m/
Project Leader
Project Leader
 
Posts: 647
Joined: 06 Jun 2008, 11:38
Location: Airdrie, UK

Re: [FUNCTION] get_announcements

Postby Pete » 24 Feb 2010, 11:26

Thanks for the reply. Sometimes the mod request forum over at phpbb.com feels like a "dead-end".. especially with these types of requests. But worth a try. I know there are some portals out there that bring up news in thier main page... but I personally feel most portals do it very bulky-ish way.

Thanks!
User avatar
Pete
Registered User
Registered User
 
Posts: 3
Joined: 24 Feb 2010, 10:40

Previous



Return to Code Snippets

Who is online

Google [Bot], MSN [Bot]


cron