Owen Lees
|
Posted: 01/30/2003, 5:08 PM |
|
CCS2 + PHP Templates
I wish to limit the amount of characters returned into a label (ie:30) so
that I can produce "snippetts" of a news story....
In other words I need to take the output from a dlookup and then truncate
the output to about 30 chars in a label.
"The pony went past the gate and then..." - sort of thing, when the full
dump is about 1000 chars ( a full story)
Please help? or point me to somewhere with a soilution!
Owen
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.449 / Virus Database: 251 - Release Date: 29/01/2003
|
|
|
Sixto Luis Santos
|
Posted: 01/31/2003, 6:14 AM |
|
Hello Owen,
The important thing here is to ensure that you get a snippet not truncated
in the middle of a word. You could use function similar to this one (add it
to your Common.php or wherever you prefer):
// -------------------------------------------------
function smart_truncate($str2cut, $trig_val=30){
$newstr="";
if(strlen($str2cut) <= $trig_val)
return $str2cut;
$newlen=strrpos(substr($str2cut,0,$trig_val)," ");
if($newlen>0)
$newstr=substr($str2cut,0,$newlen);
else
$newstr=substr($str2cut,0,$trig_val);
return $newstr."...";
}
// -------------------------------------------------
Set the $str2cut parameter to the story you want to get a snip from, and
optionally set $trig_val to the maximum length of the resulting string
(defaults to 30 chars.)
To use:
$full_story=CCDLookUp("content_field", "news_table", "id_field=xxx", $db);
$snip_story=smart_truncate($full_story);
Regards,
Sixto
"Owen Lees" <owen@modelracer.com> wrote in message
news:b1ciae$6ks$1@news.codecharge.com...
> CCS2 + PHP Templates
>
> I wish to limit the amount of characters returned into a label (ie:30) so
> that I can produce "snippetts" of a news story....
>
> In other words I need to take the output from a dlookup and then truncate
> the output to about 30 chars in a label.
>
> "The pony went past the gate and then..." - sort of thing, when the full
> dump is about 1000 chars ( a full story)
>
> Please help? or point me to somewhere with a soilution!
>
> Owen
>
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.449 / Virus Database: 251 - Release Date: 29/01/2003
>
>
|
|
|
Owen Lees
|
Posted: 02/03/2003, 12:37 AM |
|
Thanks Sixto
I'll go away and try all this. Much appreciated
Oo
"Sixto Luis Santos" <ccs@tecnoapoyo.com> wrote in message
news:b1e0c4$81d$1@news.codecharge.com...
> Hello Owen,
>
> The important thing here is to ensure that you get a snippet not truncated
> in the middle of a word. You could use function similar to this one (add
it
> to your Common.php or wherever you prefer):
>
> // -------------------------------------------------
> function smart_truncate($str2cut, $trig_val=30){
> $newstr="";
>
> if(strlen($str2cut) <= $trig_val)
> return $str2cut;
>
> $newlen=strrpos(substr($str2cut,0,$trig_val)," ");
> if($newlen>0)
> $newstr=substr($str2cut,0,$newlen);
> else
> $newstr=substr($str2cut,0,$trig_val);
>
> return $newstr."...";
> }
>
> // -------------------------------------------------
>
> Set the $str2cut parameter to the story you want to get a snip from, and
> optionally set $trig_val to the maximum length of the resulting string
> (defaults to 30 chars.)
>
> To use:
>
> $full_story=CCDLookUp("content_field", "news_table", "id_field=xxx", $db);
> $snip_story=smart_truncate($full_story);
>
>
> Regards,
>
> Sixto
>
> "Owen Lees" <owen@modelracer.com> wrote in message
>news:b1ciae$6ks$1@news.codecharge.com...
> > CCS2 + PHP Templates
> >
> > I wish to limit the amount of characters returned into a label (ie:30)
so
> > that I can produce "snippetts" of a news story....
> >
> > In other words I need to take the output from a dlookup and then
truncate
> > the output to about 30 chars in a label.
> >
> > "The pony went past the gate and then..." - sort of thing, when the
full
> > dump is about 1000 chars ( a full story)
> >
> > Please help? or point me to somewhere with a soilution!
> >
> > Owen
> >
> >
> >
> > ---
> > Outgoing mail is certified Virus Free.
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.449 / Virus Database: 251 - Release Date: 29/01/2003
> >
> >
>
>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.449 / Virus Database: 251 - Release Date: 01/02/2003
|
|
|
Owen Lees
|
Posted: 02/04/2003, 1:18 PM |
|
I think I must be thick!
I get errors...when I run the ccs project.
Is there a suitable reference aywhere to help me understand what parameters
to put where to make this work perhaps?
Owen
"Owen Lees" <owen@modelracer.com> wrote in message
news:b1l9np$fju$1@news.codecharge.com...
> Thanks Sixto
>
> I'll go away and try all this. Much appreciated
>
> Oo
>
> "Sixto Luis Santos" <ccs@tecnoapoyo.com> wrote in message
>news:b1e0c4$81d$1@news.codecharge.com...
> > Hello Owen,
> >
> > The important thing here is to ensure that you get a snippet not
truncated
> > in the middle of a word. You could use function similar to this one (add
> it
> > to your Common.php or wherever you prefer):
> >
> > // -------------------------------------------------
> > function smart_truncate($str2cut, $trig_val=30){
> > $newstr="";
> >
> > if(strlen($str2cut) <= $trig_val)
> > return $str2cut;
> >
> > $newlen=strrpos(substr($str2cut,0,$trig_val)," ");
> > if($newlen>0)
> > $newstr=substr($str2cut,0,$newlen);
> > else
> > $newstr=substr($str2cut,0,$trig_val);
> >
> > return $newstr."...";
> > }
> >
> > // -------------------------------------------------
> >
> > Set the $str2cut parameter to the story you want to get a snip from, and
> > optionally set $trig_val to the maximum length of the resulting string
> > (defaults to 30 chars.)
> >
> > To use:
> >
> > $full_story=CCDLookUp("content_field", "news_table", "id_field=xxx",
$db);
> > $snip_story=smart_truncate($full_story);
> >
> >
> > Regards,
> >
> > Sixto
> >
> > "Owen Lees" <owen@modelracer.com> wrote in message
> >news:b1ciae$6ks$1@news.codecharge.com...
> > > CCS2 + PHP Templates
> > >
> > > I wish to limit the amount of characters returned into a label (ie:30)
> so
> > > that I can produce "snippetts" of a news story....
> > >
> > > In other words I need to take the output from a dlookup and then
> truncate
> > > the output to about 30 chars in a label.
> > >
> > > "The pony went past the gate and then..." - sort of thing, when the
> full
> > > dump is about 1000 chars ( a full story)
> > >
> > > Please help? or point me to somewhere with a soilution!
> > >
> > > Owen
> > >
> > >
> > >
> > > ---
> > > Outgoing mail is certified Virus Free.
> > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > Version: 6.0.449 / Virus Database: 251 - Release Date: 29/01/2003
> > >
> > >
> >
> >
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.449 / Virus Database: 251 - Release Date: 01/02/2003
>
>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.449 / Virus Database: 251 - Release Date: 02/02/2003
|
|
|
|