close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

limiting the number of characters

Thread began 9/14/2012 5:49 am by JamieEff | Last modified 10/24/2012 10:49 am by JamieEff | 1496 views | 7 replies |

JamieEff

limiting the number of characters

Hi Jason

Is there a way to do this without using a recordset?

Ie, at the moment to limit the number of characters in a panel I am using a recordset:

php:
<?php

include('WA_CMS/addtosite.php');
echo 
str_replace(array("<p>","</p>"),"",WA_getCMSContent($database_PowerCMSConnection$PowerCMSConnection'Events''Latest Event Content'false$row_EventsRS['ContentPageSetOrder'],350));
?>



I have tried playing around with it like this (and a variety of permutations along these lines) but clearly with no luck

php:
<?php echo str_replace(array("<p>","</p>"),"",WA_getCMSContent($database_PowerCMSConnection$PowerCMSConnection'Events''Latest Event Content'),55); ?>



Is it possible to do it this way and if so, how please?

Thanks

Jamie

Sign in to reply to this post

Jason ByrnesWebAssist

you would need to use substr() to limit the number of characters:



php:
echo str_replace(array("<p>","</p>"),"",substr(WA_getCMSContent($database_PowerCMSConnection, $PowerCMSConnection, 'Events', 'Latest Event Content', false),0,55));
Sign in to reply to this post

JamieEff

Many thanks and have a great weekend

Sign in to reply to this post

JamieEff

how would I get the "..." put after the last character in that format please Jason?

Sign in to reply to this post

Jason ByrnesWebAssist

php:
echo(str_replace(array("<p>","</p>"),"",substr(WA_getCMSContent($database_PowerCMSConnection, $PowerCMSConnection, 'Events', 'Latest Event Content', false),0,55))."...");
Sign in to reply to this post

JamieEff

thanks Jason

Sign in to reply to this post

SPT

Nice one guys...just what I was looking for... :)

Sign in to reply to this post

JamieEff

seek and ye shall find..... :)

Sign in to reply to this post

JamieEff

Hey Jason

How would I make this

<?php echo substr($row_NewsNav['NewsTitle'],0,150)."..."; ?>

only show the "..." if there are more than 150 characters?

Thanks

Jamie

Sign in to reply to this post

Jason ByrnesWebAssist

use the strlen() function:
function.strlen.php


php:
<?php echo substr($row_NewsNav['NewsTitle'],0,150); ?>

<?php 
if(strlen($row_NewsNav['NewsTitle']) > 150) echo "..."?>
Sign in to reply to this post
loading

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...