Jump to content

Truncating text within a field


bplumb

Recommended Posts

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

 

 

 

 

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.