close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

limiting output

Thread began 6/05/2010 6:33 am by web364946 | Last modified 8/24/2010 9:11 am by web364946 | 4569 views | 23 replies

anonymous

I would actually do it like this:

First add this function at the top of your page:

php:
<?php

// CUTTEXT

function cutText($string$length) {

if(
$length<strlen($string)){

while (
$string{$length} != " ") {

$length--;
}

return 
substr($string0$length);

}else return 
$string;


?>



Then, where your content is:

php:
<?php 

include('cms102/WA_CMS/addtosite.php'); 

$content = (WA_getCMSContent($database_localhost$localhost'index.php' ,  'content');   

$content strip_tags($content'<p><a>');

$content cutText($content150);
    
echo 
$content;

?>



Now, I know this looks like a bit more code, but it will be better in the end because you will use the Strip Tags function to strip out any html tags - such as image tags or other tags that will actually eat up character length. The other problem if you don't strip tags is what happens when your substring ends in the middle of an open html tag such as an image.

In the example I provided, you'll notice after the strip tags command in the parenthesis, I have "<p><a>" as the second attribute. This means that all html tags EXCEPT the p and a tags will get stripped. I usually do this to leave the paragraphs and links in tact while getting rid of images and all other stuff for preview purposes.

After I strip the tags, I then call the custom Cut Text function to trim it down to what I want.

Regards,

Brian

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...