How to 'Snip' by 'Paragraph'?

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

Moderator: Spunkmeyer

How to 'Snip' by 'Paragraph'?

Postby mark99 » Mon Apr 28, 2003 9:52 am

Well the documentation I need on Coranto Factory seems to be down and after having searched this forum I still can't find the exact command.

As the subject states, I'd like to SNIP using the paragraph command instead of characters:

<Snip 150: Field: Text>

Sadly I can't remember the exact command for snipping by the first paragraph of a news item and the word alone..:

<Snip paragraph: Field: Text>

..doesn't work.

Can somebody please fill in the blank, it's an easy question, although I'm surprised you don't mention this command on this sites own documentation.
mark99
 
Posts: 55
Joined: Sun Jan 12, 2003 10:43 am

Postby mark99 » Mon Apr 28, 2003 2:51 pm

Never mind, the page came back and I saw that it only works in PerlCode. Got it up and running now..
mark99
 
Posts: 55
Joined: Sun Jan 12, 2003 10:43 am

could you let me know how you did it?

Postby tarkin789 » Tue Jan 18, 2005 5:07 am

I am wondering how to do the same thing....could you fill me in on the solution you found? I couldn't find anything on the coranto factory site....I'd like to snip by paragraph.
tarkin789
 
Posts: 29
Joined: Fri May 28, 2004 8:48 pm

Re: could you let me know how you did it?

Postby Parahead » Tue Jan 18, 2005 7:23 am

tarkin789 wrote:I am wondering how to do the same thing....could you fill me in on the solution you found? I couldn't find anything on the coranto factory site....I'd like to snip by paragraph.
Just to understand what you want to do, if you have a text looking something like this:
Code: Select all
<P>This is the first paragraph you want to snip out</P><P>This is a second paragraph</P>
You only want to to snip out the first paragraph? Or am I missunderstanding what you want to achieve?
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 tarkin789 » Wed Jan 19, 2005 2:10 am

Basically, rather than snipping after x amount of characters, i want to snip at the first paragraph break.

This is primarily for use with headlines. I will have varying amount of content i want to show up as a headline...i want everything before the first paragraph break to appear as a headline...and everything afterwards to only be in the full article's text. the paragraphs will vary in length, so i can't snip by x number of characters.

does that make more sense? i think it's what you illustrated above....
tarkin789
 
Posts: 29
Joined: Fri May 28, 2004 8:48 pm

Postby Dale Ray » Wed Jan 19, 2005 7:09 am

tarkin789 wrote:Basically, rather than snipping after x amount of characters, i want to snip at the first paragraph break.

This is primarily for use with headlines. I will have varying amount of content i want to show up as a headline...i want everything before the first paragraph break to appear as a headline...and everything afterwards to only be in the full article's text. the paragraphs will vary in length, so i can't snip by x number of characters.

does that make more sense? i think it's what you illustrated above....


The easiest way to achieve what you want is to create a custom field for the teaser text. You can then enter whatever you want to be the teaser in that field and the remainder in the regular text field.

Another possible way to control where you "snip" is discused in this thread.
Dale Ray
User avatar
Dale Ray
 
Posts: 1001
Joined: Sun Jan 19, 2003 6:02 pm
Location: NW Indiana

Postby Parahead » Wed Jan 19, 2005 7:15 am

tarkin789 wrote:Basically, rather than snipping after x amount of characters, i want to snip at the first paragraph break.

This is primarily for use with headlines. I will have varying amount of content i want to show up as a headline...i want everything before the first paragraph break to appear as a headline...and everything afterwards to only be in the full article's text. the paragraphs will vary in length, so i can't snip by x number of characters.

does that make more sense? i think it's what you illustrated above....
One option would be to create a second textarea where you enter the ingress/headline of the story. This gives you the freedom to have another short text that is not used in the longer story. Otherwise something like this could be used in the style to filter out the first paragraph:
Code: Select all
<PerlCode>
($IngressText, $RestOfText) = /^<p>(.*?)<\/p>(.*)/i;
</PerlCode>
Headline (without the p-tags!!!): <Field: IngressText>
Rest of text: <Field: RestOfText>
Place at the top of your style. This is not tested so it might need tweaking to work exactly as you want.
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 InSAnE NiNjA » Wed Jan 19, 2005 8:08 am

Are you all keeping in mind that coranto doesnt actually use paragraph tags?

At least as far as i know. So wouldn't it be more like..

edit: updated, would this work?

<PerlCode>
($IngressText, , $RestOfText) = /^(.*?)(\s*<br[^>]*>){2,}(.*)/i;
</PerlCode>
..nuttier then a squirrel turd..
User avatar
InSAnE NiNjA
 
Posts: 1213
Joined: Sat Jan 25, 2003 6:35 am

Postby Parahead » Wed Jan 19, 2005 8:48 am

InSAnE NiNjA wrote:Are you all keeping in mind that coranto doesnt actually use paragraph tags?
Well, if you enter p-tags in the textarea and have set the "Disable HTML"-option to No the p-tags should stay in there? Or?

Anyway, I think that either having an extra textarea or using the [snip] discussed in the other thread (had forgotten about that thread) is the best choice... Gives better control and is less error prone.
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 LoneOwl » Tue Jun 07, 2005 10:38 pm

For something as simple as this, why use a regex? Just use substr and index. You could even use split.
User avatar
LoneOwl
 
Posts: 1465
Joined: Sun Mar 10, 2002 2:57 am
Location: That one place, you know?

Postby Lumberjack » Wed Jun 08, 2005 3:35 am

Different people think in different ways, perhaps?
Lumberjack
 
Posts: 555
Joined: Wed Jan 10, 2007 7:22 pm
Location: Oxford, UK

Postby LoneOwl » Wed Jun 08, 2005 11:49 am

Regexes can have a lot of uses, but in some situations it's quicker to write(and probably execute) to not use a regex. It's like in this case, there's really no need for the specific features regex are good for, or even necessary.

But of course, the perl motto is there's more than one way to do it. It's just some are less obsfucated.
User avatar
LoneOwl
 
Posts: 1465
Joined: Sun Mar 10, 2002 2:57 am
Location: That one place, you know?

Postby Lumberjack » Wed Jun 08, 2005 1:22 pm

I understand what you're saying, my point is that for some people (myself included I'm sure) the first thought would be regex. How about you suggest an alternative using split and be done with it.
Lumberjack
 
Posts: 555
Joined: Wed Jan 10, 2007 7:22 pm
Location: Oxford, UK

Postby LoneOwl » Wed Jun 08, 2005 1:43 pm

If you assume that the first part of the entry is a <p> tag, than something like `substr $Text, 0, index( $Text, '<p>', 1);` should provide the first portion of the new items.

But at the moment, I should mention that I am rather drunk, and I'm not consuluting the pod files to ensure accuracy.
User avatar
LoneOwl
 
Posts: 1465
Joined: Sun Mar 10, 2002 2:57 am
Location: That one place, you know?

Postby Parahead » Wed Jun 08, 2005 5:44 pm

LoneOwl wrote:For something as simple as this, why use a regex? Just use substr and index. You could even use split.
Thanks for pointing that out, I wasn't aware it was pick on Parahead's day today? ;-) I simply provided *one* solution, never said it was *the* solution... And I provided a working solution when he asked, not 5 months later? ;-)
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

Next

Return to Customization

Who is online

Users browsing this forum: No registered users and 3 guests

cron