The Official Website of AgoraCart and Agora.cgi
AgoraCart.com Demos Download AgoraCart User Manuals & Wiki Gold Members Forum Go Gold Now! Gold Version Memberships

AgoraCart.com

About
Features
Download
Payment Gateways
Send a Donation
Founders Club
BLOG: News & Updates

Showcases & Demos

AgoraCart Demos
Shop Live Stores

Downloads & Add-ons

Gold Version Downloads
DBwizz Database Mgr.
AgoraCart.com Store

Help & Support

User Manuals
Gold Version Users Forum
Gold Version Chat
Tech Support
Certified Agora Pros
Certified Designers
Hire a Freelancer

Gold Version Members

Member Benefits
Join Today!
Gold Members Home
Gold Version Users Forum
Gold Version Chat Rooms
Gold Version Downloads

For Store Owners

Merchant Accounts
Cool Resources
Advertise Here
"Powered by" Logos
Web Hosting Search

Misc.

Contact Us
MEET's Talking Guide
The Ancient Greek Agora






AgoraCart Free User Forums

This is the official FAQ and Cool Tips guide For the AgoraCart shopping Cart software


Official Sponsors of the AgoraCart Project:

       


RegisterSearchFAQLog in
Reply to topic Page 1 of 1
Search Description Truncation
Author Message
Reply with quote
Post Search Description Truncation 
I was just wondering if it were possible to truncate a description of an item after a certain number of words. Well, I know how to write the perl to do it, just how would I install it into the item/search template? Thanks!!

View user's profile Send private message
Reply with quote
Post  
<!--agorascript-post

{
$mystring = "%%description%%";
local ($size, @bob, $x);
@bob=split / /, $mystring;
$mystring="";
$size=@bob;
if($size>75){
$size=75;
}

for($x=0;$x<$size;$x++){
$mystring .="$bob[$x] ";
}
if($size>75){
$mystring .="... (read more)";
}

$mystring; # return this value, it is the last statement executed
}
-->


Is what I have so far, but it's not working... it always shows me an error page saying "We're sorry, an error has occured. Please hit the browser back button, change what was done in error, and try again." I've tried changing the post to pre, but then the description doesn't get shortened...

View user's profile Send private message
Reply with quote
Post  
nevermind, I just took the data directly using the database and keys and fixed it that way. Sorry to be a bother

View user's profile Send private message
Reply with quote
Post  
Please feel free to post your solution as there may be others who may like to take advantage of it.


_________________
God Bless!
Bonnie - AgoraCart Moderator

Get a Gold Membership
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger ICQ Number
Reply with quote
Post  
It's far from elegant, but:

Quote:

<!--agorascript-post
{
local $mystring = $database_fields[5]; #gets the 5th field of the database, in this case is the description
$mystring =~ s/<(?:[^>'"]*|(['"]).*?\1)*>//gs; #remove all HTML tags from the description
local ($size, @splitSpace, $x);
@splitSpace=split / /, $mystring;
$mystring="";
$size=@splitSpace;
if($size>75){
$size=75;
}
for($x=0;$x<$size;$x++){
$mystring .="$splitSpace[$x] ";
}
$mystring .="... (<a href=agora.cgi?p_id=".$database_fields[0]."&xm=on>read more</a>)";
$mystring; # return this value, it is the last statement executed
}
-->


View user's profile Send private message
Reply with quote
Post  
Thanks for posting that!!


_________________
God Bless!
Bonnie - AgoraCart Moderator

Get a Gold Membership
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger ICQ Number
Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum