Welcome to Geeklog, Anonymous Saturday, November 23 2024 @ 09:43 am EST
Geeklog Forums
Article Navigation
Status: offline
ByteEnable
Forum User
Full Member
Registered: 10/20/03
Posts: 138
I wanted a article nav similar to mambo, so here it is:
Add the new code to lib-story.php. Its in the STORY_renderArticle function, around line 126.
if( $index == 'n' )
{
// START NEW CODE
$result = DB_query("SELECT `sid` FROM `gl_stories` WHERE `tid` = '" . $A['tid'] . "' AND `sid` < '" . $A['sid'] . "' ORDER BY `sid` DESC LIMIT 1");
$PrevStory = DB_fetchArray($result);
$result = DB_query("SELECT `sid` FROM `gl_stories` WHERE `tid` = '" . $A['tid'] . "' AND `sid` > '" . $A['sid'] . "' ORDER BY `sid` LIMIT 1");
$NextStory = DB_fetchArray($result);
$StoryNavTopic = ucfirst($A['tid']);
if ( $PrevStory[0] == '' ) {
$article->set_var('PrevStory','<td class="StoryNav"></td>');
}
else {
$article->set_var('PrevStory','<td class="StoryNav"><BR><A title="Read previous article in “'. $StoryNavTopic . '”" class="PageNav" href="/article.php/'. $PrevStory[0] . '">«Prev</a></td>');
}
if ( $NextStory[0] == '' ) {
$article->set_var('NextStory','<td class="StoryNav"></td>');
}
else {
$article->set_var('NextStory','<td class="StoryNav"><BR><A title="Read next article in “' . $StoryNavTopic . '”" class="PageNav" href="/article.php/'. $NextStory[0] . '">Next»</a></td>');
}
//END NEW CODE
$article->set_var( 'story_title', stripslashes( $A['title'] ));
Next update your theme (storytext.thtml) with the PrevStory and NextStory variables.
</tr>
{story_bodyhtml}
{PrevStory}{NextStory}
</table>
You will also need to edit your CSS with your own style. If anyone knows how to optimize those two MySQL queries, please share. You can see this in action at LinuxElectrons.
Add the new code to lib-story.php. Its in the STORY_renderArticle function, around line 126.
Text Formatted Code
if( $index == 'n' )
{
// START NEW CODE
$result = DB_query("SELECT `sid` FROM `gl_stories` WHERE `tid` = '" . $A['tid'] . "' AND `sid` < '" . $A['sid'] . "' ORDER BY `sid` DESC LIMIT 1");
$PrevStory = DB_fetchArray($result);
$result = DB_query("SELECT `sid` FROM `gl_stories` WHERE `tid` = '" . $A['tid'] . "' AND `sid` > '" . $A['sid'] . "' ORDER BY `sid` LIMIT 1");
$NextStory = DB_fetchArray($result);
$StoryNavTopic = ucfirst($A['tid']);
if ( $PrevStory[0] == '' ) {
$article->set_var('PrevStory','<td class="StoryNav"></td>');
}
else {
$article->set_var('PrevStory','<td class="StoryNav"><BR><A title="Read previous article in “'. $StoryNavTopic . '”" class="PageNav" href="/article.php/'. $PrevStory[0] . '">«Prev</a></td>');
}
if ( $NextStory[0] == '' ) {
$article->set_var('NextStory','<td class="StoryNav"></td>');
}
else {
$article->set_var('NextStory','<td class="StoryNav"><BR><A title="Read next article in “' . $StoryNavTopic . '”" class="PageNav" href="/article.php/'. $NextStory[0] . '">Next»</a></td>');
}
//END NEW CODE
$article->set_var( 'story_title', stripslashes( $A['title'] ));
Next update your theme (storytext.thtml) with the PrevStory and NextStory variables.
Text Formatted Code
</tr>
{story_bodyhtml}
{PrevStory}{NextStory}
</table>
You will also need to edit your CSS with your own style. If anyone knows how to optimize those two MySQL queries, please share. You can see this in action at LinuxElectrons.
7
11
Quote
Status: offline
ByteEnable
Forum User
Full Member
Registered: 10/20/03
Posts: 138
Yeah, I looked at the date. But wouldn't I have convert that ASCII back to unix time format? If so, how easy is that?
5
10
Quote
Status: offline
Dirk
Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Nope, MySQL already does that for you. To quote from index.php:
This is how the stories are sorted on the index page. No conversion necessary.
bye, Dirk
Text Formatted Code
$sql .= "ORDER BY featured DESC, date DESC";This is how the stories are sorted on the index page. No conversion necessary.
bye, Dirk
6
8
Quote
Status: offline
ByteEnable
Forum User
Full Member
Registered: 10/20/03
Posts: 138
Thanks for the tip Dirk. I've already implemented it. I just replaced all the 'sid' with date.
8
9
Quote
Status: offline
ByteEnable
Forum User
Full Member
Registered: 10/20/03
Posts: 138
Here is an update for the database queries for those that have used this code.
$result = DB_query("SELECT `sid` FROM `gl_stories` WHERE `tid` = '" . $A['tid'] . "' AND `date` < '" . $A['date'] . "' ORDER BY `date` DESC LIMIT 1");
$PrevStory = DB_fetchArray($result);
$FutureDate = date( "Y-m-d H:i:s", time() );
$result = DB_query("SELECT `sid` FROM `gl_stories` WHERE `tid` = '" . $A['tid'] . "' AND `date` > '" . $A['date'] . "' AND `date` < '" . $FutureDate . "'ORDER BY `date` LIMIT 1");
$NextStory = DB_fetchArray($result);
Text Formatted Code
$result = DB_query("SELECT `sid` FROM `gl_stories` WHERE `tid` = '" . $A['tid'] . "' AND `date` < '" . $A['date'] . "' ORDER BY `date` DESC LIMIT 1");
$PrevStory = DB_fetchArray($result);
$FutureDate = date( "Y-m-d H:i:s", time() );
$result = DB_query("SELECT `sid` FROM `gl_stories` WHERE `tid` = '" . $A['tid'] . "' AND `date` > '" . $A['date'] . "' AND `date` < '" . $FutureDate . "'ORDER BY `date` LIMIT 1");
$NextStory = DB_fetchArray($result);
8
8
Quote
All times are EST. The time is now 09:43 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