bplumb Posted August 29, 2010 Share Posted August 29, 2010 Hi all, I am relatively new to coding but wondered if someone can helpe me with this. I currently have a PHP file which outputs text that has been entered into a text box and saved. The original output code was this: if ( $this->theme->conf->item_description AND $this->doc->data->dmdescription ) : <?php echo $this->doc->data->dmdescription;?> but I want the text that shows to be truncated to say, 100 characters plus '...' so I came up with the following... <?php $someText = ($this->doc->data->dmdescription);?> <?php echo(substr($someText, 0,100)).'...'; ?> However it shows nothing. I guess $someText is bing linked to dmdescription rather than the text within dmdescription? Any ideas greatly appreciated! bplumb Quote Link to comment Share on other sites More sharing options...
Shp0ngl3 Posted August 29, 2010 Share Posted August 29, 2010 This should do the trick <?php echo substr($someText, 0,100).'...'; ?> Quote Link to comment Share on other sites More sharing options...
bplumb Posted August 29, 2010 Author Share Posted August 29, 2010 Thanks for the suggestion. Unfortunately I feel we are close but not close enough yet! Here is the error returned... Savant2: template source file not found ( code :-7 ) Catchable fatal error: Object of class Savant2_Error_docman could not be converted to string in (directory address)/list.tpl.php on line 59 Line 59 on this other PHP file is... include $this->loadTemplate('documents/list_item.tpl.php'); (where list_item.tpl.php is the file we are currently trying to add the truncate text to) Quote Link to comment Share on other sites More sharing options...
bplumb Posted August 29, 2010 Author Share Posted August 29, 2010 Scrap that, it works a treat! Thank you so much! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.