Categories > TinyButStrong general >

substr in template file ?

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Milop
Date: 2012-09-26
Time: 13:16

substr in template file ?

How can I use substr php function in template file ?
By: Skrol29
Date: 2012-09-27
Time: 01:16

Re: substr in template file ?

Can you give an example of what you're trying to do ?
By: Milop
Date: 2012-09-27
Time: 07:25

Re: substr in template file ?

So, in PHP file I load 10 latest posts (articles) from SQLite DB:

$TBS->MergeBlock('index_post',$db,'SELECT * FROM Articles where active=1 order by id desc limit ?,?',array($StartIndex,$PageSize));

In theme I display those 10 articles (Title and Full Article):

    [index_post;block=begin]
<h2 class="entry-title"><a href="single.php?id=[index_post.id]">[index_post.keyword;block=h2+div]</a></h2>
<div class="main entry-content group">[index_post.article]</div>   
    [index_post;block=end]


But what I would like to do is to display only 250 chars of [index_post.article]
So, how can I use PHP function substr in template ?

By: Skrol29
Date: 2012-09-29
Time: 00:25

Re: substr in template file ?

Hi,

You can use parameter "ope=max:250".
Nevertheless, this is rather a job for the database. You SQL query should return the column with a limited length.