Welcome to Geeklog Tuesday, June 25 2019 @ 07:40 am EDT

Geeklog Forums

story list


Status: offline

mrjeff

Forum User
Chatty
Registered: 28/01/04
Posts: 36
Hi, I would like to create a list of stories for a specific topic. The storyindex.php creates a list for all topics. How would I select the database to display all of the stories in a topic with story title and link to story?

Jeff
"friends don't help friends run windows"

Status: offline

geKow

Forum User
Full Member
Registered: 12/01/03
Posts: 445
I have a php block (from Dirk) which does that:

PHP Formatted Code
function phpblock_topicstories()
{
    global $_CONF, $_TABLES, $topic;
    if (empty ($topic)) {
        return '';
    }
    $result = DB_query ("SELECT sid,title FROM {$_TABLES['stories']} WHERE tid = '$topic'" . COM_getPermSQL ('AND') . " ORDER BY date DESC");
    $num = DB_numRows ($result);
    $retval = '<b>' . $topic . '</b><br>';
   
    for ($i = 0; $i < $num; $i++) {
        $A = DB_fetchArray ($result);
        $retval .= '» <a href="' . $_CONF['site_url'] . '/article.php?story='
                . $A['sid'] . '">' . stripslashes ($A['title']) . '</a><br>';
    }

    return $retval;
}
 


geKow

Status: offline

mrjeff

Forum User
Chatty
Registered: 28/01/04
Posts: 36
caffeinated
Thanks geKow, This helps out alot.

Jeff
"friends don't help friends run windows"

Status: offline

mack

Forum User
Newbie
Registered: 10/01/05
Posts: 8
Quote by geKow: I have a php block (from Dirk) which does that:

PHP Formatted Code
function phpblock_topicstories()
{
    global $_CONF, $_TABLES, $topic;
    if (empty ($topic)) {
        return '';
    }
    $result = DB_query ("SELECT sid,title FROM {$_TABLES['stories']} WHERE tid = '$topic'" . COM_getPermSQL ('AND') . " ORDER BY date DESC");
    $num = DB_numRows ($result);
    $retval = '<b>' . $topic . '</b><br>';
   
    for ($i = 0; $i < $num; $i++) {
        $A = DB_fetchArray ($result);
        $retval .= '» <a href="' . $_CONF['site_url'] . '/article.php?story='
                . $A['sid'] . '">' . stripslashes ($A['title']) . '</a><br>';
    }

    return $retval;
}

 


geKow


how do i setup this function so that i can display story lists for each topic on a static page?

Status: offline

zipstart

Forum User
Chatty
Registered: 13/09/04
Posts: 60
Drop this in a php (return) static page:

PHP Formatted Code
global $_CONF, $_TABLES;

$retval = '';

$topics = DB_query ("SELECT `tid`, `topic` FROM  {$_TABLES['topics']}  order by `sortnum`");
$numtopics = DB_numRows ($topics);

for ($t = 0; $t < $numtopics; $t++) {
    $B = DB_fetchArray ($topics);
    $topicID = $B['tid'];
    $topicname = $B['topic'];
    $result = DB_query ("SELECT `sid`,`title` FROM {$_TABLES['stories']} WHERE tid = '$topicID'" . COM_getPermSQL ('AND') . " ORDER BY date DESC");
    $num = DB_numRows ($result);
    $retval .= '<b>' . $topicname . '</b><br>';
   
    for ($i = 0; $i < $num; $i++) {
        $A = DB_fetchArray ($result);
        $retval .= '» <a href="' . $_CONF['site_url'] . '/article.php?story=' . $A['sid'] . '">' . stripslashes ($A['title']) . '</a><br>';
    }
}

 


Not elegant, no security, etc...just a quick starting point.

Status: offline

mack

Forum User
Newbie
Registered: 10/01/05
Posts: 8
you're the best! it works..... but why do you say its ont secure?

Status: offline

mack

Forum User
Newbie
Registered: 10/01/05
Posts: 8
Quote by mack: you're the best! it works..... but why do you say its ont secure?

Oops. Spoke too soon. The function is great except for one critical flaw. It lists out all the stories in every topic indiscriminately so even stories flagged as draft appear as part of the list. Any idea how to set a condition for it not to list stories flagged as draft?

Cheers!

Status: offline

zipstart

Forum User
Chatty
Registered: 13/09/04
Posts: 60
I say no security cuz it'll list out all stories, even drafts (as you've noticed) and stories and topics peeps don't have access to.

Status: offline

xavior

Forum User
Newbie
Registered: 24/08/05
Posts: 2
This is the closest topic I could find that relates to what I am trying to do. What I need to do is make it so when a topic is clicked it goes to a topic story list page. Of course, the list would only be listing stories from that specific topic in which it was placed. From there the specific story can be selected. It's sort of like a short description page that would list the title of the story and the date. My problem is that the stories are growing very fast and the only way to find the story you want is to use the search feature. I'd like to make it easier for people to find the story they want. I'm not going to ask if this is possible. because with PHP anything is possible. I just need to know if this has been or is being developed by someone.

Status: offline

mack

Forum User
Newbie
Registered: 10/01/05
Posts: 8
Quote by xavior: This is the closest topic I could find that relates to what I am trying to do. What I need to do is make it so when a topic is clicked it goes to a topic story list page. Of course, the list would only be listing stories from that specific topic in which it was placed. From there the specific story can be selected. It's sort of like a short description page that would list the title of the story and the date. My problem is that the stories are growing very fast and the only way to find the story you want is to use the search feature. I'd like to make it easier for people to find the story they want. I'm not going to ask if this is possible. because with PHP anything is possible. I just need to know if this has been or is being developed by someone.


In the interest of efficacy and efficiency, I manipulated the PHP strings for the Search feature in Geeklog and used them as URLs to list out the latest stories under the focused topic of interest.

You can check this out at Macriot.com

Not exactly elegant but gets the job done quickly and easily. Without having to overhaul the entire Geeklog engine.

Status: offline

xavior

Forum User
Newbie
Registered: 24/08/05
Posts: 2
That is exactly what I would like to have show when I click on a topic. I'm thinking static pages were the way to go and make my own topics linking to each but I think your idea is better. I just don't know the geeklog coding well enough yet to build what I need so a search link for the topics will work for now. BTW, that site looks great.

Status: offline

steffcip

Forum User
Newbie
Registered: 05/12/08
Posts: 13
anyone can make this to work with the latest version of geeklog?
I would really appreciate any help...even if I have to pay something

Status: offline

beewee

Forum User
Full Member
Registered: 05/08/03
Posts: 969
Location:The Netherlands, where else?
There's a story-by-topic block that does what you want: generate a list with the latest x stories of a topic. You can call the code of that block in a static page. Also replace the topics block with a regular block with links to that the corresponding static pages.

I believe the story-by-topic block also works with GL1.51
Dutch Geeklog sites about camping/hiking: www.kampeerzaken.nl | www.campersite.nl | www.caravans.nl | www.caravans.net

Status: offline

steffcip

Forum User
Newbie
Registered: 05/12/08
Posts: 13
thanks
works with 1.5.1
but it displays from newest story to oldest
I want to list them alphabetically
anyone can help modifying the code?

Status: offline

steffcip

Forum User
Newbie
Registered: 05/12/08
Posts: 13
friend helped me to modify the code to display stories in alphabetically order with no limit

so I'm sticking with this one until a better one appears Smile

All times are EDT. The time is now 07:40 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