Jump to the post that solved this thread.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Solved: 8 Years, 10 Months, 3 Weeks ago Display latest threads on index
#1
Solved: 8 Years, 10 Months, 3 Weeks ago
hi

i want to fetch only the thread titles and its link from the portal page and display them on the index page inside a marquee...

can anyone guide me the right hooks and codes to be used to achieve this....

i guess the following quesry will fetch me the latest threads from the db, where $max will the number of threads i want to display...
$latest = $db->query("SELECT * FROM ".TABLE_PREFIX."threads ORDER BY `tid` DESC LIMIT $max");

but i am not sure how to incorporate this code to the index page... Huh


thanks in advance Smile
We can't help everyone, but everyone can help someone - Ronald Reagan
Did you know? Your question has already been answered. But you haven't searched it yet.
Don’t  Forget to “Mark as Solved” after the fix
#2
Solved: 8 Years, 10 Months, 3 Weeks ago
you can try code from here or here (see also replies on the threads)

there are more threads on this community with the guidance for your above requirement
plugins also exist (eg. Recent Topics on Index page)
#3
Solved: 8 Years, 10 Months, 3 Weeks ago
yes i have seen quite a few TUTs and plugins regarding this, but most of them fetches the latest posts rather than latest threads...

for ex, i post a new thread tid=100 and another member posts another new tid=101 and another member posts a reply to an existing tid=20... now i want only the tid100 and 101 to be displayed and not the reply to old thread...

i do not want the replies to be fetched as a new topic... i want only the new threads to be displayed
We can't help everyone, but everyone can help someone - Ronald Reagan
Did you know? Your question has already been answered. But you haven't searched it yet.
Don’t  Forget to “Mark as Solved” after the fix
#4
Solved: 8 Years, 10 Months, 3 Weeks ago
tid will fetch the threads only, not replies. Replies are called referring pid.

The hook to include is "index_start". Example:

$plugins->add_hook("index_start", "threadlist_function");
#5
Solved: 8 Years, 10 Months, 3 Weeks ago
here is a simple plugin like code for your requirement.
.php   latestthreads.php (Size: 1.11 KB / Downloads: 252)
you can add latestthreads.php in plugins folder, activate and add {$latestthreads} on index template

 $max = 10;
	
	$query = $db->query("SELECT * FROM ".TABLE_PREFIX."threads ORDER BY `tid` DESC LIMIT $max"); 
    $latestthreads = '<marquee scrollamount=3>';
	while($result = $db->fetch_array($query))
		{
        $latestthreads .= "*&nbsp;<a href=\"showthread.php?tid={$result['tid']}\">".htmlspecialchars_uni($result['subject'])."</a>";
        $latestthreads .= "&nbsp;&nbsp;";
    	}
		$latestthreads .= '</marquee>';
		
		return $latestthreads;
#6
Solved: 8 Years, 10 Months, 3 Weeks ago
(2013-06-29, 09:58 AM).m. Wrote: here is a simple plugin like code for your requirement.
you can add latestthreads.php in plugins folder, activate and add {$latestthreads} on index template

HeartHeartHeart

works like a charm on localhost... will do some modifications and css additions before taking it to live Smile thanks again Smile

its now added to my site... works perfectly Heart

follow my siggy to check it Big Grin
We can't help everyone, but everyone can help someone - Ronald Reagan
Did you know? Your question has already been answered. But you haven't searched it yet.
Don’t  Forget to “Mark as Solved” after the fix
#7
Solved: 8 Years, 10 Months, 3 Weeks ago
(2013-06-29, 09:58 AM).m. Wrote: here is a simple plugin like code for your requirement.
you can add  latestthreads.php in plugins folder, activate and add {$latestthreads} on index template



 $max = 10;
 
 $query = $db->query("SELECT * FROM ".TABLE_PREFIX."threads ORDER BY `tid` DESC LIMIT $max"); 
    $latestthreads = '<marquee scrollamount=3>';
 while($result = $db->fetch_array($query))
 {
        $latestthreads .= "*&nbsp;<a href=\"showthread.php?tid={$result['tid']}\">".htmlspecialchars_uni($result['subject'])."</a>";
        $latestthreads .= "&nbsp;&nbsp;";
     }
 $latestthreads .= '</marquee>';
 
 return $latestthreads;

Mybb 1.8.1

Where do I add this code

How do I get to be like that here in a ?

http://thegame-zone.com/index.php
Jump to the post that solved this thread.


Forum Jump:


Users browsing this thread: 1 Guest(s)