Welcome to Geeklog, Anonymous Friday, April 26 2024 @ 12:11 am EDT

Geeklog Forums

Need a Hack for Body Text


Status: offline

orfilms

Forum User
Regular Poster
Registered: 08/02/05
Posts: 70
I need a hack that will allow me to add some html before the body text. This is not something I want to appear on the front page (index.php) and there is no way to add this into the article.thtml file I don't think. I want it only to appear in the article pages themselves, and after the intro text, before the body text (and only if there is a body text).

Can anyone help me out on this one?
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
in lib-story.php (in your system dir) starting at about line 188, find the following:
Text Formatted Code
    if( $index == 'n' )
    {
        $article->set_var( 'story_title', stripslashes( $A['title'] ));
        if( empty( $A['bodytext'] ))
        {
            $article->set_var( 'story_introtext', $introtext );
            $article->set_var( 'story_text_no_br', $introtext );
        }
        else
        {
            $bodytext = stripslashes( $A['bodytext'] );
            $bodytext = PLG_replacetags($bodytext);   // Replace any plugin autolink tags
            $article->set_var( 'story_introtext', $introtext . '<br><br>'
                               . $bodytext );
            $article->set_var( 'story_text_no_br', $introtext . $bodytext );
        }
    }


 

and now add your content where you see the $putYourContentHere variable as you see it in the following (notice that the variable appears twice):
Text Formatted Code
    if( $index == 'n' )
    {
        $article->set_var( 'story_title', stripslashes( $A['title'] ));
        if( empty( $A['bodytext'] ))
        {
            $article->set_var( 'story_introtext', $introtext );
            $article->set_var( 'story_text_no_br', $introtext );
        }
        else
        {
            $bodytext = stripslashes( $A['bodytext'] );
            $bodytext = PLG_replacetags($bodytext);   // Replace any plugin autolink tags
            $article->set_var( 'story_introtext', $introtext . '<br>' . $putYourContentHere . '<br>'
                               . $bodytext );
            $article->set_var( 'story_text_no_br', $introtext . $putYourContentHere . $bodytext );
        }
    }


 


This is just showing you where you need to get you content in order for it to appear between your intro and body text. How you actually get your content there can be done in a number of ways:

-you could just add content to the variable, which would be defined earlier and then just included as above.

-If it was me, I would separate the $introtext and the $bodytext into separate template variables. At the same time I would add another that represents my special content. Add all three variables to the proper template file, e.g., storytext.thtml, and your off and running. The special content and bodytext template variables will only be replaced by actual content on the article page (the one that displays the whole article) because of where the variables are set in lib-story.php.

hope that is what you were looking for.
 Quote

Status: offline

orfilms

Forum User
Regular Poster
Registered: 08/02/05
Posts: 70
I don't know much about php so please excuse me Razz

I added the code I wanted in the possition of the varriable, which works. I don't know how I'd even begin to do the things you listed below the code.

However the code does what I want it to do BUT the code I'm adding appears when there is no body text. I want to somehow make it so that the code will not be added if there is no bodytext. How would I do this?

Thanks
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
The way i've positioned the variable ensures that it will only appear when bodytext is not empty--I just tested it and it works as you want it to.

Ensure that your special content is in the "else" part of the above code.
 Quote

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