Welcome to Geeklog, Anonymous Thursday, March 28 2024 @ 05:24 am EDT

Geeklog Forums

Headlines block for ONE topic


Status: offline

xardoz

Forum User
Regular Poster
Registered: 02/24/04
Posts: 98
Hi,

I'm trying to create a block that would show just the headlines of stories for just one topic.

I've looked at the standard "headlines block" code, but I'm just not getting it.

Thanks.
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Text Formatted Code
$result = DB_query ("SELECT title,sid FROM {$_TABLES['stories']} WHERE tid = 'YourTopicIDhere' ORDER BY date DESC LIMIT 10");
$numrows = DB_numRows ($result);
$retval = '';
for ($i = 0; $i < $numrows; $i++) {
    $A = DB_fetchArray ($result);
    $retval .= '<a href="' . COM_buildUrl ($_CONF['site_url'] . '/article.php?story=' . $A['sid']) . '">' . $A['title'] . '</a><br>';
}
 


Something like this? I can almost write that in my sleep - which means that it may have a few typos or syntax errors - completely untested ...

It's also missing any permission checks.

bye, Dirk
 Quote

Status: offline

xardoz

Forum User
Regular Poster
Registered: 02/24/04
Posts: 98
Success!!!

I tried just using your code, and there were some errors, as you predicted. But this helped me understand what the standard "headlines" block is doing.

I copied the standard "headlines" code, gave it a new phpblock_name and added your
Text Formatted Code
tid = 'YourTopicIDhere'
 
as an AND () statement to the WHERE condition.

As always, Dirk comes through with the good stuff.

Thanks for all your help!
 Quote

All times are EDT. The time is now 05:24 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content