boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[Hacks] Very Simple Headlines Hack
Goto page 1, 2  Next
 
Post new topic   Reply to topic    boardom Forum Index -> Hacks
View previous topic :: View next topic  
Author Message
GamerZ



Joined: 15 May 2002
Posts: 537
Location: Singapore

PostPosted: Sat Aug 17, 2002 7:04 pm    Post subject: [Hacks] Very Simple Headlines Hack Reply with quote

Here is a very simple i made to display the latest 10 headlines. Create a file called b2headlines.php, and put the code below in it. Remember to modify the table name. If you want to have only 5 headlines change the LIMIT 10 to LIMIT 5. =)
[php:1:ce617f477a]
<?
include ("blog.header.php");
dbconnect();
$query = "SELECT ID, post_title FROM gamerz_b2posts ORDER BY post_date DESC LIMIT 10";
$result = mysql_query($query);
while ($data = mysql_fetch_row($result)) {
echo "<a href=\"http://www.url.com/index.php?p=$data[0]\">$data[1]</a><br>\n";
}
?>
[/php:1:ce617f477a]
To include the headlines, just use the php include function
[php:1:ce617f477a]
<?
include "b2headlines.php";
?>
[/php:1:ce617f477a]
_________________

++ GamerZ.Per.Sg - Complex Simplicity


Last edited by GamerZ on Sun Jan 05, 2003 4:42 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Mafia



Joined: 23 Mar 2002
Posts: 68

PostPosted: Sun Aug 18, 2002 8:42 am    Post subject: Reply with quote

Hi!,

Check the lastest blogs per category... :D

Its in www.undernews.com/scripts
Back to top
View user's profile Send private message
GamerZ



Joined: 15 May 2002
Posts: 537
Location: Singapore

PostPosted: Sun Aug 18, 2002 10:05 am    Post subject: Reply with quote

nice job LOL
_________________

++ GamerZ.Per.Sg - Complex Simplicity
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
smikwily



Joined: 11 Mar 2002
Posts: 45
Location: Ohio, USA

PostPosted: Tue Aug 20, 2002 2:35 pm    Post subject: Reply with quote

Anyway to show only the posts from a certain category with either of these? (My php is about as good as my Spanish )
Back to top
View user's profile Send private message Visit poster's website AIM Address
Coldcutt



Joined: 31 Aug 2002
Posts: 6

PostPosted: Sat Aug 31, 2002 3:28 pm    Post subject: Error Reply with quote

Have you any idea why I get this error when I include this code?

Fatal error: Cannot redeclare addslashes_gpc() in /usr/local/psa/home/vhosts/site/httpdocs/blog.header.php on line 35

I dont know enough about php to know what this is.

thanks, and great simple hack.
Just a shame I am not simple enough to understand how it works.

CC
Back to top
View user's profile Send private message
GamerZ



Joined: 15 May 2002
Posts: 537
Location: Singapore

PostPosted: Sat Aug 31, 2002 3:33 pm    Post subject: Reply with quote

hmm what version of php u using?
_________________

++ GamerZ.Per.Sg - Complex Simplicity
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Coldcutt



Joined: 31 Aug 2002
Posts: 6

PostPosted: Sat Aug 31, 2002 3:35 pm    Post subject: Reply with quote

It is erm...

PHP Version 4.1.0
Back to top
View user's profile Send private message
Coldcutt



Joined: 31 Aug 2002
Posts: 6

PostPosted: Sat Aug 31, 2002 3:37 pm    Post subject: Reply with quote

In fact I have just noticed the actual posts, which I have changed to show 5 of, are on the desired page.

So the script has worked, but then the error follows on the next page and the rest of the site does not load.
Back to top
View user's profile Send private message
macshack



Joined: 17 Jul 2002
Posts: 1204
Location: Phoenix, Az

PostPosted: Sat Aug 31, 2002 5:11 pm    Post subject: Reply with quote

Coldcut,

My guess is that you are attempting to 'include' this hack in your current blog page. Is so, things are going to break. Notice that the hack includes the file blog.header.php. If this is as I suspect, you already have included that file at the top of your file. And thus the function addslashes_gpc tries to get defined again. Not good.

And maybe more important, the hack places is query result in $result replacing anything that was there before. This could be a big issue depending on where the hack is included in your file. If its is before the 'b2 loop engine' then things will get messed up. Variable scope is very important. Note: blog.header.php is responsible for setting up $result for use by the rest of the code based on what is required for this instance of the page.

Michael e
Back to top
View user's profile Send private message Send e-mail
kulai



Joined: 27 Apr 2002
Posts: 6
Location: Dipolog City, Philippnes

PostPosted: Sat Sep 14, 2002 2:44 pm    Post subject: blogscategoria.php Reply with quote

i tried the hack blogscategoria.php but nothing shows on my page. i'm using b2-pre2. any idea?

thnx[/b]
Back to top
View user's profile Send private message Visit poster's website
Coldcutt



Joined: 31 Aug 2002
Posts: 6

PostPosted: Mon Sep 23, 2002 8:53 pm    Post subject: Reply with quote

Hi guys.

I got this working ok now, just a bit of messing about on my part stopped it working.

But I am wanting to know how easy it would be to incorporate the include for the date the post was made?
I would,like to show this just under the Title for the post so it is in this format:

'Example Title'
Posted on 21.09.02

'Next Post Example'
Posted on 20.09.02

Could you possibly tell me what code I would have to add, and where to make this work please?

The only other thing is how do I chose the size of the font, although I know html well, this seems to beat me when it comes to altering something as small as size in the text...

I hope you can help...

Thanks

CC.
Back to top
View user's profile Send private message
Eggatron



Joined: 25 Jan 2002
Posts: 55
Location: Aberdeen, Scotland

PostPosted: Tue Sep 24, 2002 12:15 am    Post subject: Reply with quote

this lists the last 10 posts with the date underneath:[php:1:f9a8cac634]<?
include ("blog.header.php");
dbconnect();
$result = mysql_query("select ID, DATE_FORMAT(post_date, '%d.%m.%Y'), post_title FROM b2posts ORDER BY post_date DESC LIMIT 10");
while(list($ID, $date, $title) = mysql_fetch_row($result))
{
echo "<a href=\"index.php?p=$ID\"><font face=\"verdana\" size=\"2\">$title</a></font><br>\n<font face=\"verdana\" size=\"1\">posted on $date</font><br>\n";
}
?>[/php:1:f9a8cac634]
_________________
eggatron.net
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Coldcutt



Joined: 31 Aug 2002
Posts: 6

PostPosted: Tue Sep 24, 2002 1:05 am    Post subject: Reply with quote

That is excellent thanks.

I have learnt alot from that, I now know how to alter the text layout with php.

Now I know it is cheeky, but how could you also add the time to that.

I presume it means calling the database field, but how do you call it?
I am slowly learning, but bear with me please.

CC.
Back to top
View user's profile Send private message
Eggatron



Joined: 25 Jan 2002
Posts: 55
Location: Aberdeen, Scotland

PostPosted: Tue Sep 24, 2002 1:38 am    Post subject: Reply with quote

the date and time are stored in the same field (post_date). All you have to do is set how you want it to output (much in the same way as in the b2options, but with a % before the letter)
Code:
DATE_FORMAT(post_date, '%d.%m.%Y %H:%i:%S')

_________________
eggatron.net
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Coldcutt



Joined: 31 Aug 2002
Posts: 6

PostPosted: Tue Sep 24, 2002 1:45 am    Post subject: Reply with quote

Cheers m8.

That has done just the trick.

Your a star!

CC.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> Hacks All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2 © 2001, 2002 phpBB Group