snip question, how to take it off

Discuss news styles, css code, and other Coranto customizations in here...the possibilities are endless, so have at it!

Moderator: Spunkmeyer

snip question, how to take it off

Postby Esstee » Wed Jun 01, 2005 12:40 pm

"I want to take it off"

:lol: That line always reminds me of the movie face off when the bad guy
was telling his drug induced gang buddies that he wanted to take his
enemies face - OFF! -

anyways my question is similar but not so bloody :P

I use the <snip:> function alot, in fact I use it in almost my entire
newsroom layout but in this one particular area I need to snip or
trim my news titles to lenth but without the ... at the end, it has to
be a clean break.

is there a modified <snip:> function to do this or do I need to
put in some bits of code?
User avatar
Esstee
 
Posts: 320
Joined: Thu Nov 25, 2004 4:13 pm
Location: Deep in some project

Postby Esstee » Wed Jun 01, 2005 4:12 pm

I found this (not easilly) but the link is not valid.

Cut off the contents of a field without the ending dots
By l0rdphi1 <Instructions>

anyone know whereI could find this?
User avatar
Esstee
 
Posts: 320
Joined: Thu Nov 25, 2004 4:13 pm
Location: Deep in some project

Postby kriko » Wed Jun 01, 2005 6:01 pm

Esstee wrote:I found this (not easilly) but the link is not valid.

Cut off the contents of a field without the ending dots
By l0rdphi1 <Instructions>

anyone know whereI could find this?

http://coranto.org/go/help/howto/EEEZyuluppDsjJfbZc

It appears that Sr. Nupsen had forgotten to post that howto item. It now has been posted and should solve your problems. :)
Kristjan aka. kriko
now a wireless expert
User avatar
kriko
 
Posts: 3328
Joined: Sat Feb 24, 2007 8:13 pm

Postby Esstee » Wed Jun 01, 2005 8:08 pm

FANTASTIC!

thx a mill. kriko
User avatar
Esstee
 
Posts: 320
Joined: Thu Nov 25, 2004 4:13 pm
Location: Deep in some project

Postby kriko » Fri Jun 03, 2005 10:04 am

Topic split: posts related to the missing things can now be found here: http://coranto.org/forum/viewtopic.php?p=58372#58372
Kristjan aka. kriko
now a wireless expert
User avatar
kriko
 
Posts: 3328
Joined: Sat Feb 24, 2007 8:13 pm

Postby Esstee » Thu Jun 16, 2005 1:56 pm

btw that code doesnt seem to work.

I checked everything over and over it all seems in place but all I get is
the usual snip effect with the ... afterwards :(


here is my code:

Code: Select all
<PerlCode>
*antiDotSnip = sub {
my ($text, $len) = @_;
$text = HTMLstrip($text);
return ($text =~ /([\s\S]{$len}\S*)/ ? $1 : $text);
} unless $aDSLoaded;
$aDSLoaded++;
</PerlCode>


<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="6" height="7" align="left" valign="bottom"><img src="/fcweb/images/headlines_bullet_red.gif"></td>
    <td height="7" align="left" valign="top"><a href="<MaginotURL: headline_fullstory>"><FONT face=verdana,arial,geneva color=#ee0000 size=1><If: Field: CustomField_condensed_title><Field: CustomField_condensed_title><If: Else><Snip 28: Field: Subject></If></a></td>
  </tr>
</table>

<PerlCode>
*antiDotSnip = sub {
my ($text, $len) = @_;
$text = HTMLstrip($text);
return ($text =~ /([\s\S]{$len}\S*)/ ? $1 : $text);
} unless $aDSLoaded;
$aDSLoaded++;
</PerlCode>
I went deeper into the belly of Coranto and look! I found maginot.
User avatar
Esstee
 
Posts: 320
Joined: Thu Nov 25, 2004 4:13 pm
Location: Deep in some project

Postby Lumberjack » Thu Jun 16, 2005 1:59 pm

I did this just the other day actually.. the example in the help section here seems too complicated for me. This is what I do (in the style):
Code: Select all
<PerlCode>
my $CustomSnip = SnipText($Subject,5);
while ($CustomSnip =~ s/\.$//) {};
</PerlCode>

And put <Field: CustomSnip> where you want it placed. SnipText is the subroutine that handles this, and 5 indicated the number of characters to snip at (but will go on to the end of the next word). This will actually also remove and '.....' that someone may have put at the end of the subject.
Lumberjack
 
Posts: 555
Joined: Wed Jan 10, 2007 7:22 pm
Location: Oxford, UK

Postby Esstee » Thu Jun 16, 2005 2:03 pm

Now that is nice!
small and efficient + it works :p

Thx Lumberjack ur a real winner in my books!
Last edited by Esstee on Thu Jun 16, 2005 2:29 pm, edited 1 time in total.
I went deeper into the belly of Coranto and look! I found maginot.
User avatar
Esstee
 
Posts: 320
Joined: Thu Nov 25, 2004 4:13 pm
Location: Deep in some project

Postby Lumberjack » Thu Jun 16, 2005 2:24 pm

I'm sure you mean winner so I'll take that as a compliment.
Lumberjack
 
Posts: 555
Joined: Wed Jan 10, 2007 7:22 pm
Location: Oxford, UK

Postby Esstee » Thu Jun 16, 2005 2:30 pm

how embarassing :?
I also didnt know how to spell winner lol till i saw you post it ;)
I went deeper into the belly of Coranto and look! I found maginot.
User avatar
Esstee
 
Posts: 320
Joined: Thu Nov 25, 2004 4:13 pm
Location: Deep in some project

Postby Parahead » Thu Jun 16, 2005 7:27 pm

Code: Select all
<PerlCode>
my $CustomSnip = SnipText($Subject,5);
while ($CustomSnip =~ s/\.$//) {};
</PerlCode>
Nice approach of solving this! :-D Although, isn't it better to do one regexp instead of many in a while loop from a performance perspective? Something like this maybe:
Code: Select all
<PerlCode>
my $CustomSnip = SnipText($Subject,5);
$CustomSnip =~ s/(\.*)$//;
</PerlCode>
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Postby Esstee » Thu Jun 16, 2005 8:19 pm

I am using Lumberjack's approach is that okay? or should I
use another piece of code?

it seems to work so far?
I went deeper into the belly of Coranto and look! I found maginot.
User avatar
Esstee
 
Posts: 320
Joined: Thu Nov 25, 2004 4:13 pm
Location: Deep in some project

Postby Parahead » Thu Jun 16, 2005 8:48 pm

Esstee wrote:it seems to work so far?
Yes, no problem with LJ's code, like I said, it was a question (of which I do not know the answer) about performance, not that the code did't work.
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Postby Lumberjack » Thu Jun 16, 2005 9:07 pm

Yes thanks Para, it would be better. I actually wrote the while loop part ages ago when I was perhaps less concious about quicker code. It should indeed be faster that way, but probably using + instead of * is a better idea (otherwise will also replace nothing with nothing).
EDIT: code tested with s/\.+$// and works the same, no noticeable change in build time but I'm only doing this on about 10 items anyway.
Code: Select all
<PerlCode>
my $CustomSnip = SnipText($Subject,5);
$CustomSnip =~ s/\.+$//;
</PerlCode>
Lumberjack
 
Posts: 555
Joined: Wed Jan 10, 2007 7:22 pm
Location: Oxford, UK


Return to Customization

Who is online

Users browsing this forum: No registered users and 4 guests

cron