limit characters displayed

7 posts by 4 authors in: Forums > CMS Builder
Last Post: March 7, 2011   (RSS)

By s2smedia - July 26, 2010

is there a code I can add so it will only display a set number of characters or words?

<div id="reviews"><img src="images/reviews_header.jpg" width="217" height="27" alt="Customer Reviews" />

<table width="217" border="0" cellpadding="0" cellspacing="0">
<?php foreach ($customer_reviewsRecords as $record): ?>
<tr>
<td width="65" align="left" valign="top" style="padding:10px 15px 10px 0px"><img src="images/kixxlogo.gif" width="50" height="32" alt="Kixx" /></td>
<td width="152" align="left" valign="top" style="padding:10px 0px 10px 0px"><div class="white_caps"><?php echo $record['name'] ?></div>
<div class="grey_caps">THIS IS WHAT I NEED TO LIMIT-><?php echo $record['title'] ?></div></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top" style="padding:0px 8px 10px 8px"><div class="sm_whiteitalics"><?php echo $record['review'] ?></div></td>
</tr>
<?php endforeach ?>
<tr>
<td colspan="2" align="center" valign="top"><a href="customerreviews.php"><img src="images/view_more.jpg" alt="View More" width="200" height="20" border="0" /></a></td>
</tr>
</table>
</div>

Re: [s2smedia] limit characters displayed

By Jason - July 26, 2010

Hi,

Take a look at this post:
http://www.interactivetools.com/forum/gforum.cgi?post=77525#77525

Give this a try. If you run into any issues, just let me know.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] limit characters displayed

By sublmnl - February 26, 2011 - edited: February 27, 2011

Little more help guys.
I have talked to Jerry about this too.

I have a limit character-count on field inside a ForEach loop of records. (only one field in the loop needs the limit char)

Weird thing about it is any entry shorter than the number I have chosen in the function gets displayed but anything more than that number, only the first 3 characters of the entry gets displayed with the added ellipses.

Specifically I'm using website addresses in my records and am chopping them down to fit a specific width. (don't worry the link still has the full address [;)] )

I have tested this on the basic pages that the code generator spits out so I know its not any other special code on my page.
I changed the number in the function a few times and counted the resulting 'cutoffs' and came to the above conclusion.
Now maybe I am missing something or is this the desired result???
I thought that the letters would count until the function got its max, take away three letters and then add 3 dots (ellipses) to finish.

If this is not the case - someone wake me up or better yet provide some code that actually does this the right way similar to the max words counter that I'v borrowed from here. Thanks.


Thanks.
[sly]

Re: [sublmnl] limit characters displayed

Here's a little clarity:

Let's say it has a limit of 12. Anything 11 and under displays fully.
Anything 12 and over chars - only displays the first 3 chars plus
ellipses.


Gkornbluth and I have been discussing this and believe the issue is the web url is hacking up the Regex.

So when it finds a "/" or a "." thats what makes it hault and show the first three characters. (duh) because the first three chracters of most URL's are 'www' then the "."

So may I ask for a hand on this one to accomodate URL's in the text limiter function?

Thanks in advance.

[cool]

Re: [gkornbluth] limit characters displayed

By sublmnl - March 6, 2011 - edited: March 6, 2011

Talked to a buddy of mine who is a programmer. Not php but at least he can read the code and validate the Regex is working fine.
He put the same rules in hist regex tester, then put in a web address, with 'www.' and without as well as with the 'http://' - they all passed the test.
So it must be the other half of the function true|false.

I don't know how to write this so I am looking for help to solve this issue.
Anyone have any ideas on why when I put in a web address in the field, that the text limiter cuts it at the dot?

Re: [sublmnl] limit characters displayed

By Jason - March 7, 2011

Hi,

In order to do this, we'll need to create a custom function that will go beyond what we can handle in support. If you'd like us to look into doing this for you, please send and email to consulting@interactivetools.com and we can go over some options with you.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/