Welcome to Geeklog, Anonymous Thursday, November 28 2024 @ 03:43 am EST

Geeklog Forums

Featured Story Hack


Status: offline

tmarquez

Forum User
Regular Poster
Registered: 06/17/03
Posts: 70
Wanted to share this. I like having my featured story display with a grey box around it to set it apart on from the rest of the stories when visitors hit my site. However, when they click read more, I want the featured story to be displayed like the other stories, black text on a white background.

What I noticed is that index.php and article.php would pass 'y' , and 'n' for the latter. So, I went to system/lib-story.php and made some changes. See, one of the passed variables the function STORY_renderArticle is waiting for is what the $index = ' ' value will be.

Here is the original part of the code I evaluated:
Text Formatted Code

if( $A['featured'] == 1 )
    {
        $article->set_var( 'lang_todays_featured_article', $LANG05[4] );
        $article->parse( 'story_bodyhtml', 'featuredbodytext', true );
        $article->parse( 'finalstory', 'featuredarticle' );
    }
 


I want the look to be different when displaying the entire article! So, I changed it to this:
Text Formatted Code

 if( $A['featured'] == 1 )
    {
        if($index == 'n' ) {
        $article->set_var( 'lang_todays_featured_article', $LANG05[4] );
        $article->parse( 'story_bodyhtml', 'bodytext', true );
        $article->parse( 'finalstory', 'article' );
        } else {
        $article->set_var( 'lang_todays_featured_article', $LANG05[4] );
        $article->parse( 'story_bodyhtml', 'featuredbodytext', true );
        $article->parse( 'finalstory', 'featuredarticle' );
    }
    }
 


The if($index == 'n'Wink catches if this is going to be displayed on the index page or not. So, based on that, I tell it which templates I want it to use, and in my case, I'm happy to use regular story templates.

If you want to add additional templates to choose from, you need to go to line 116 and add them in this array:
Text Formatted Code

 $article->set_file( array(
            'article'          => $storytpl,
            'bodytext'         => 'storybodytext.thtml',
            'featuredarticle'  => 'featuredstorytext.thtml',
            'featuredbodytext' => 'featuredstorybodytext.thtml',
            'archivearticle'   => 'archivestorytext.thtml',
            'archivebodytext'  => 'archivestorybodytext.thtml'
            ));
 


And of course, created the templates in your layout. Hope this helps someone. It took me a while to figure it out. Hope this hasn't already been posted ( I did search couldn't find anything like this).

NOTE: Always remember to back up your files before doing these kind of hacks.
T.Marquez Jr. -
Webmaster -
www.indianapolisfilm.net - Geeklog 1.4.0sr5-1
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by: tmarquezI like having my featured story display with a grey box around it to set it apart on from the rest of the stories when visitors hit my site. However, when they click read more, I want the featured story to be displayed like the other stories, black text on a white background.

Btw, in Geeklog 1.4.1 there's a new variable {story_display}, available in the story and article templates, that contains either 'index', 'article', or 'preview', depending on where the story is currently being displayed.

You can then use that to define CSS classes that change the display of the story accordingly.

E.g. h1.index { color: red; } and h1.article { color: green; } would let the article's title change color from red (index page) to green (article.php).

bye, Dirk
 Quote

All times are EST. The time is now 03: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