Displaying latest post on my homepage.

  • floridafishandhunt.com
  • Graduate
  • Graduate
  • User avatar
  • Posts: 130
  • Loc: Florida

Post 3+ Months Ago

I did a dearch and couldnt find anything topic that matched. Has this been discussed before?
Heres what I would like to know.
I would like to display the most recent posts on my homepage.

1. Is this a php deal?

2. Does my homepage have to be a .php page?
Here is a site that does it but it is an html page.
http://www.nodakoutdoors.com/
I have been considering changing my page over to a php page.
is this a bad idea? I write only in html and use dreamweaver, I have started to get indexed in google and am worried about changing the file
extension,because I dont want to get dropped. Is this dumb to worry about?

3. Can someone direct me to some code that will display the most current posts.

Thanks,
Doug
  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

1. Yup - well, any language that can access your MySQL database

2. Yup - see above :)

It's pretty easy to do... Basically you just connect to the database, and perform a commnd to pull the info for the most recently posted on topics, then display that info.

3....

Code: [ Select ]
SELECT t.forum_id, t.topic_id, t.topic_title, t.topic_replies, u.user_id AS user2, u2.user_id AS id2, p2.post_time FROM phpbb_topics t, phpbb_users u, phpbb_posts p, phpbb_posts p2, phpbb_users u2 WHERE t.topic_poster = u.user_id AND p.post_id = t.topic_first_post_id AND p2.post_id = t.topic_last_post_id AND u2.user_id = p2.poster_id ORDER BY p2.post_time desc LIMIT 10

You can exclude certain areas (mods forum, test forum, etc.) with a statement like this one...

Code: [ Select ]
SELECT t.forum_id, t.topic_id, t.topic_title, t.topic_replies, u.user_id AS user2, u2.user_id AS id2, p2.post_time FROM phpbb_topics t, phpbb_users u, phpbb_posts p, phpbb_posts p2, phpbb_users u2 WHERE t.topic_poster = u.user_id AND p.post_id = t.topic_first_post_id AND p2.post_id = t.topic_last_post_id AND u2.user_id = p2.poster_id and t.forum_id != '25' ORDER BY p2.post_time desc LIMIT 10

Simply change "25" to the number of the forum you want to exclude.. If you want to add more, simply add another "and t.forum_id != 'insert number here'" to the request directly before "ORDER BY".

Just store that in a variable like...

Code: [ Select ]
$sql = 'pick one of the examples above';

And you can get the data like this...
Code: [ Select ]
 $result=mysql_query($sql);
 while (list($tfid, $tid, $subject, $replies, $tposter_id, $lposter_id, $dateline) = mysql_fetch_row($result)) {
 $subject_long=stripslashes($subject);
 if(strlen($subject) > 50) { // Limit title length to avoid wrap
  $subject = stripslashes(substr($subject,0,47));
  $subject .= "...";
 }
 $output->Text('<a title="'.stripslashes($subject_long).'" href="viewtopic. php?t='.$tid.'">'.stripslashes($subject).'</a> ('.$replies.' Replies) '.date("m.d.Y",($dateline + 10800)).'<br>'."\n");
}
  1.  $result=mysql_query($sql);
  2.  while (list($tfid, $tid, $subject, $replies, $tposter_id, $lposter_id, $dateline) = mysql_fetch_row($result)) {
  3.  $subject_long=stripslashes($subject);
  4.  if(strlen($subject) > 50) { // Limit title length to avoid wrap
  5.   $subject = stripslashes(substr($subject,0,47));
  6.   $subject .= "...";
  7.  }
  8.  $output->Text('<a title="'.stripslashes($subject_long).'" href="viewtopic. php?t='.$tid.'">'.stripslashes($subject).'</a> ('.$replies.' Replies) '.date("m.d.Y",($dateline + 10800)).'<br>'."\n");
  9. }

You'll need to remove the space from "viewtopic. php?t=", I had to put it in there so the forum's auto-URL-doohicky didn't modify it :)
  • floridafishandhunt.com
  • Graduate
  • Graduate
  • User avatar
  • Posts: 130
  • Loc: Florida

Post 3+ Months Ago

Thanks axe.
I am going to have to look over all that and try and implement it.
Before I do I need to change my page to a php page.
I assume that yup meant dont worry about the search engines losing me.
I guess they go to look for the page and just make a note of the .html to .php change and thats it?
Lastly, will I be able to still edit my page just like I do now , as far as creating deleting and moving tables text images.
Or is a php page the same as an html page as far as this stuff is concerned?

THANKS,
Doug
  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

the search engines won't lose you... In fact, if anything, adding the most recent posts to your front page may help your PR a lil bit on other pages on your site - especially if you have that section linking to other parts of your forum.

All my sites are in PHP these days, and Google loves them (or at least it has a slight affection for them, heh).

All my PHP based sites are PR5 or higher as of the latest index.

They probably won't even notice a .html to .php change. Just instead of having your links go to /index.html or /index.php, just have them go to /

That way, it sees more links going to your actual domain name (rather than a page on your site), and increases your main domain's PR.

If thre's 500 links going to / instead of 100 links going to / and 400 going to /index.php, then / is going to start getting a higher pagerank.
  • floridafishandhunt.com
  • Graduate
  • Graduate
  • User avatar
  • Posts: 130
  • Loc: Florida

Post 3+ Months Ago

dand I just realized all thoose people that have links to my site will have to repoint those links.
Sigh what a pain. I might have to reconsider.
Doug
Also I am having trouble setting up a testing server in dreamweaver.
Doug
  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

You could always setup the .html file with a redirect to forward them to the .php
  • floridafishandhunt.com
  • Graduate
  • Graduate
  • User avatar
  • Posts: 130
  • Loc: Florida

Post 3+ Months Ago

hey I converted the page and it said I need to set up a testing server.
I tried but got this error.
Its dreamweaver.
Image
any suggestions?
Doug
  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

I honestly have no idea... That was PHP code I pasted, not JavaScript, and dreamweaver says it's a JavaScript error :)

I don't use Dreaweaver myself, I just edit the code myself.
  • coolkid
  • Newbie
  • Newbie
  • User avatar
  • Posts: 9
  • Loc: in front of monitor

Post 3+ Months Ago

are you using dreamweaver dynamic menus?
if so, try removing them and test out the php first?

btw to set up a testing server, you must hav either Apache or IIS installed and working.

hope it helps :)

Post Information

  • Total Posts in this topic: 9 posts
  • Users browsing this forum: Liamw411 and 69 guests
  • 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 post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.