Posted on: 11/28/02 07:13am
By: Robin
I was asked whether it is possible to display stories (titles) from a particular section in a separate block. I ain't no expert in php but I managed to write something like this:
function phpblock_whateveryoucallit()
{
global $_CONF;
$siteurl = $_CONF['site_url'];
$sql = "select sid,tid,title from gl_stories where tid='YourSectionName'";
$mysql_result = mysql_query($sql);
while($row = mysql_fetch_row($mysql_result)) {
$display .= "<a href=$siteurl/article.php?story=$row[0]>$row[2]</a><br>";
}
return $display;
}
It works fine however I'm aware the code could be improved. Waiting for your feedback.
Displaying Articles per Section Block
Posted on: 12/09/02 01:21pm
By: Anonymous (Anonymous)
I have one problem - I don't know much about php but after installing this the block is appearing with all the articles. I need to decrease this number to some certain number like 5 or 10 newest.
Also I want to ask a question how can I put such a block in the other geeked site?
ex. news from mycompany.com will be shown on myothercompany.com
J.
Displaying Articles per Section Block
Posted on: 12/09/02 04:47pm
By: Anonymous (Anonymous)
I'm not a SQL expert either, but I think the query goes like this:
$sql = "SELECT sid,tid,title,date FROM gl_stories WHERE tid='YourSectionName" ORDER BY date DESC LIMIT 0,4";
This should return only 5 stories ordered with the most current first. If you want more, change the "4" to whatever. You might be able to get the same results sorting on the sid too, but I'm not really sure how that is number generated. The first part is the date but I don't know what the basis is for the remaining numbers.