1
Chainsaw
Truncate Story
  • 2003/10/30 7:07

  • Chainsaw

  • Quite a regular

  • Posts: 304

  • Since: 2003/9/28


Apologies for this enquiry. My PHP and HTML programming are not one of my strongest skillset.

Can someone please tell me how to change the "recent news" template to

substr({Story Title} <br>
{
Story Content}, 050)


See example on right side of this mock up.
http://www.octane.org.nz/htmlpages/idea_oct_03/home.htm

I see the following code in the news_block_new.html template

<ul>
  <{foreach 
item=news from=$block.stories}>
    <
a href="<{$xoops_url}>/modules/news/article.php?storyid=<{$news.id}>"><{$news.title}>a>
  <{/foreach}>
ul>


How do I add the Story content to this and then truncate it to 50 characters.

The site I am building (in beta mode) is at
http://202.89.43.124/www.albanycc.org.nz/xoops2/

Appreciate all your help.

Cheers.

2
Chainsaw
Re: Truncate Story
  • 2003/10/30 21:42

  • Chainsaw

  • Quite a regular

  • Posts: 304

  • Since: 2003/9/28


OK I've tried everything that I can think of (for now) but none of this worked

<{foreach item=news from=$block.stories}>
  <
p align="left">:: <a href="<{$xoops_url}>/modules/news/article.php?storyid=<{$news.id}>"><{$news.title}><br><{$news.text}>a><br>
p>
<{/foreach}>


I've tried replacing <{$news.text}> with <{$news.hometext}>

Any suggestions???




Please???

3
Venezia
Re: Truncate Story
  • 2003/10/30 23:11

  • Venezia

  • Just popping in

  • Posts: 36

  • Since: 2003/6/24


As it stands you cannot expose the news item's body text from within the block template because no variable has been passed to the XOOPS template.

The function that generates the values and passes them into the XOOPS template for this block is :

function b_news_top_show($options)

and it can be found in :

/news/blocks/news_top.php

You will have to edit this function, obtain the story text :-

1. Change line 32 - to include the "hometext" field in the db query
$sql = "SELECT storyid, title, published, hometext, expired, counter FROM ".$xoopsDB->prefix("sto... etc

2. Around line 42 add story text to the $news array as 'preview' or whatever
$news['preview'] =$myts->makeTboxData4Show($myrow["hometext"]);

3. Truncate $news['preview'] as you please.

3. In your block template reference the variable $news.preview as you please.

Good Luck
Venezia

4
TheFinni
Re: Truncate Story
  • 2004/4/5 10:20

  • TheFinni

  • Just popping in

  • Posts: 75

  • Since: 2003/11/25


I just found this post. Thanks a lot for the hack!

I don't know if anyone will see this post again since it's been a while...

But if anyone knows about this following question. I am trying to figure out why my text in the newsblock is not coming out as HTML. I have stored the hometext content in the database with HTML editor and I want to be able to show the formatting in the homepage.

Does anyone know the answer?

Login

Who's Online

352 user(s) are online (200 user(s) are browsing Support Forums)


Members: 0


Guests: 352


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits