Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 4255
Latest: andreios
New This Month: 3
New This Week: 1
New Today: 0
Stats
Total Posts: 43259
Total Topics: 7518
Most Online Today: 297
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 1
Guests: 283
Total: 284

Author Topic: Recent comments  (Read 5692 times)

0 Members and 1 Guest are viewing this topic.

Offline vkot

  • Full Member
  • ***
  • Posts: 136
    • View Profile
Recent comments
« on: August 14, 2008, 05:24:44 am »
I'd like to have a list of recent comments on the classifieds' first page (and maybe on the SMF's 1st page too). This is because sometimes there are discussions going on under a listing, and everyone should be able to see if someone said something new.

I would prefer a list like the one in the 1st page of SMF, with only the catecory, listing title, comment sender, date

Just for a quick try, I started with an SQL statement like this:

Code: [Select]
SELECT i.ID_LISTING, i.commenttotal, i.title, i.ID_CAT,
m.approved, m.date, m.comment, m.ID_COMMENT
FROM class_listing AS i, class_comment AS m
WHERE i.commenttotal >0 AND m.ID_LISTING = i.ID_LISTING AND i.removed =0 AND i.approved =1 AND m.approved =1
ORDER BY m.date DESC LIMIT 4

but I don't know how/where I should embed it in the classifieds.template.php file

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16436
    • View Profile
Re: Recent comments
« Reply #1 on: August 14, 2008, 07:24:38 pm »
That's the right query but you would need to write a function to get the results of each row and then format them. Classifieds.template.php is the right place but you need to look inside i belive the template_main function since that shows the main page and the category listing for the classifieds.
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline vkot

  • Full Member
  • ***
  • Posts: 136
    • View Profile
Re: Recent comments
« Reply #2 on: December 12, 2008, 02:00:15 am »
This is my implementation of "recent comments". It adds an extra block after Featured Listings, Recent, Most Viewed, Most commented. I attach an image capture for you to see how it looks like. Feel free to change the layout and/or the code to suit your needs.

In classifieds.template.php,
add BEFORE:
Code: [Select]
// See if they are allowed to add catagories Main Index only
if ($g_manage)
{

the following:
Code: [Select]
//vkot Recent Comments
$query = "SELECT i.ID_LISTING as iID_LISTING, i.commenttotal, i.title as ititle, i.ID_CAT as iID_CAT,
          m.approved, m.date, m.comment, m.ID_COMMENT
          FROM class_listing AS i, class_comment AS m
          WHERE i.commenttotal >0 AND m.ID_LISTING = i.ID_LISTING AND i.removed =0 AND i.approved =1 AND m.approved =1
          ORDER BY m.date DESC LIMIT 8";

$dbresult = db_query($query, __FILE__, __LINE__);
echo '<table cellspacing="0" cellpadding="2" border="0" align="center" width="90%" class="tborder"><th class="titlebg" colspan=2>Recent comments</th>';
while($row = mysql_fetch_assoc($dbresult))
{
      echo '<tr class="windowbg2"><td align="left">Re: <a href="', $scripturl, '?action=classifieds;sa=view;id=', $row['iID_LISTING'], '">', $row['ititle'], '</a> <span class=smalltext><i>"',preg_replace ("@</?[^>]*>*@", "", substr($row['comment'],0,100)),'..."</i></span>';
echo '</td><td align="right"><span class="smalltext">';
      echo timeformat($row['date']).'<br />';
echo '</span></td></tr>';
}
echo '</table><br />';

// Free the Mysql Resoruces
mysql_free_result($dbresult);
///vkot end Recent Comments

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16436
    • View Profile
Re: Recent comments
« Reply #3 on: February 16, 2010, 02:54:15 pm »
Added recent comments/recent bids options to homepage of the classifieds
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

 

Related Topics

  Subject / Started by Replies Last post
1 Replies
4730 Views
Last post March 02, 2008, 08:16:45 pm
by SMFHacks
4 Replies
8216 Views
Last post May 19, 2008, 09:35:20 pm
by Adalla
7 Replies
5424 Views
Last post September 25, 2011, 11:35:12 am
by cosmicx
1 Replies
2918 Views
Last post October 16, 2011, 03:01:51 pm
by SMFHacks
2 Replies
2866 Views
Last post October 08, 2013, 09:35:34 am
by insider

+- Recent Topics

No thumbnails on new uploads by SMFHacks
March 27, 2024, 02:10:41 pm

Display the Contact Page for guests by SMFHacks
March 27, 2024, 10:55:43 am

is it possible to add support for odysee.com by fvlog19
March 21, 2024, 08:47:51 am

Request for admin notification by davejo
March 10, 2024, 01:31:59 am

I need help with torrent upload by Ineedsmfhelp
March 09, 2024, 10:01:13 pm

an idea for new mod (( content type with different display )) by SMFHacks
February 27, 2024, 01:36:27 pm

[Mod] RSS Feed Poster by SMFHacks
February 27, 2024, 11:57:18 am

find duplicate pictures by fvlog19
February 14, 2024, 02:22:40 pm

Error uploading video. by SMFHacks
February 08, 2024, 02:04:16 pm

Gallery icon as last added image by fvlog19
February 01, 2024, 01:04:56 pm

Powered by EzPortal