Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2004-11-08 00:56:38

philipashlock
Member
From: Bellingham, Washington - USA
Registered: 2004-06-20
Posts: 58
Website

Re: Plugin: pfa_beginning - excerpt generation based on length attribute

I’ve made a few little improvements with this plugin. Pretty much, I just made it so that you can specify a style class in a div tag that wraps around the permanent link. You can see the included documentation for examples. Enjoy.

***

Name: pfa_beginning
Version: 0.3
Author: Philip Ashlock
Author URL: http://web.philitopia.com
Modified: 2004-11-07
Download URL
Discussion Thread URL

Offline

#14 2004-11-21 15:54:55

Andrew
Plugin Author
Registered: 2004-02-23
Posts: 730

Re: Plugin: pfa_beginning - excerpt generation based on length attribute

Philip, you should update the download links on your first post of this thread just so people aren’t downloading the old version of the plugin. I think that the first post is typically maintained as the “current/stable” release.

Offline

#15 2004-11-29 04:58:35

aslsw66
Member
From: Canberra, Australia
Registered: 2004-08-04
Posts: 342
Website

Re: Plugin: pfa_beginning - excerpt generation based on length attribute

I’m not sure if I have the latest version of this plug-in or what!

When I use it, it grabs the beginning of my article regardless of whether or not I have explicitly given the article an excerpt. Also, it doesn’t wrap the result with a <pre><DIV></pre>, any ‘styleclass’ attribute is ignored.

This is what I’m using in a form:
<pre>
<div class = “latest”>
<h2><txp:title /></h2>
<txp:beginning limit=“500” styleclass = “excerpt” />
<p class = “more”>Posted <txp:posted /> | <txp:permlink>Read more</txp:permlink></p>
</div>
</pre>
I’m new to TextPattern, so it just might be me! Any idea why I am failing with my first plugin?

Thanks,

AS

Last edited by aslsw66 (2004-11-29 05:04:03)

Offline

#16 2004-11-29 08:28:39

philipashlock
Member
From: Bellingham, Washington - USA
Registered: 2004-06-20
Posts: 58
Website

Re: Plugin: pfa_beginning - excerpt generation based on length attribute

First of all, sorry about the problem with the plugin creating an excerpt when one already exists. It seems like there was a bug in my code, so I’ve fixed it and released a new version of the plugin. You can download it here

The styleclass attribute is used to define a class name for the div tag that is used to wrap around the permanent link to your full article, it doesn’t wrap around the excerpt text, just the link that follows it.

Last edited by philipashlock (2004-11-29 08:32:56)

Offline

#17 2004-11-29 08:29:57

philipashlock
Member
From: Bellingham, Washington - USA
Registered: 2004-06-20
Posts: 58
Website

Re: Plugin: pfa_beginning - excerpt generation based on length attribute

This release just covers the bug fix mentioned in the previous post

***

Name: pfa_beginning
Version: 0.4
Author: Philip Ashlock
Author URL: http://web.philitopia.com
Modified: 2004-11-29
Download URL
Discussion Thread URL

Offline

#18 2004-11-29 23:34:45

aslsw66
Member
From: Canberra, Australia
Registered: 2004-08-04
Posts: 342
Website

Re: Plugin: pfa_beginning - excerpt generation based on length attribute

> philipashlock wrote:

“The styleclass attribute is used to define a class name for the div tag that is used to wrap around the permanent link to your full article, it doesn’t wrap around the excerpt text, just the link that follows it.”

Personally, I think there should be a way to style the paragraph generated for the excerpt with a class. Also, I think outputting the permanent link in a block level element like a div can be dangerous, because you might want the link inline with some other text rather than in its own block.

So, I have hacked the plugin to make the styleclass attribute apply to the p tag – I’m not using the plugin to generate a permanent link so nothing gets disturbed. By the way, this is the first time I have hacked or done anything in PHP so I’m well pleased with myself!

Offline

#19 2004-11-29 23:44:46

aslsw66
Member
From: Canberra, Australia
Registered: 2004-08-04
Posts: 342
Website

Re: Plugin: pfa_beginning - excerpt generation based on length attribute

Not so pleased now. My hack only works if there is already an excerpt in the article. If not, it fails to put a style in the paragraph, I guess because the body of the article already contains a starting paragraph tag.

More investigation… or could someone more knowledgeable have a go?

Edit: Fixed it. It’s still a hack to a plugin of course.

Last edited by aslsw66 (2004-11-30 00:36:43)

Offline

#20 2004-12-07 08:17:12

philipashlock
Member
From: Bellingham, Washington - USA
Registered: 2004-06-20
Posts: 58
Website

Re: Plugin: pfa_beginning - excerpt generation based on length attribute

I’m contemplating improvements based on the past few comments…

First of all, I think I should probably change the default tag to wrap around the permalink to a span tag rather than a div tag. I say this because it’s probably more likely that people would have an inline link but if they want it to be displayed as a block they can define so in the stylesheet. Then again, the same could be done for specifying inline when using the div tag, I’m just trying to figure out what is a more likely usage.

What would you say, do you think permalinks are more likely displayed inline or as a block?

Also, should I wrap the entries in a div tag, or would it make more sense to just do so yourself in a form? The one advantage of doing this in this plugin is that i could define a div tag that wraps around the body, but not the permalink. Does this seem necessary?

Offline

#21 2004-12-07 22:07:49

aslsw66
Member
From: Canberra, Australia
Registered: 2004-08-04
Posts: 342
Website

Re: Plugin: pfa_beginning - excerpt generation based on length attribute

Well, the way I have used it (and hacked it to make it work) is that I have the excerpt wrapped in a paragraph tag with a style applied to it ie. a specific style for displaying the excerpt only.

I haven’t used the link function yet, but my view is that you don’t need a span tag around the link. To apply a style to the link it should just be applied to the link tag itself – a span is unnecessary.

So, this implies that the plugin can accept (1) a style for the excerpt paragraph (2) the link text and (3) a style for the link.

Offline

#22 2004-12-08 04:56:47

philipashlock
Member
From: Bellingham, Washington - USA
Registered: 2004-06-20
Posts: 58
Website

Re: Plugin: pfa_beginning - excerpt generation based on length attribute

Response & Plans:

It wouldn’t make sense to have the excerpt wrapped in a paragraph tag because the exercpt may be several paragraphs (which are each already wrapped with their own paragraph tags). I can however see good reason to wrap the entire excerpt in a div tag, you could then style any paragraphs inside that div tag just as easily.

I think I will take out the div that wraps around the link and apply the linktext to the anchor tag itself as I see no reason why not – it would allow for the same effect and eliminate extra coding.

Sound good?

Offline

#23 2004-12-08 21:51:26

aslsw66
Member
From: Canberra, Australia
Registered: 2004-08-04
Posts: 342
Website

Re: Plugin: pfa_beginning - excerpt generation based on length attribute

Of course you are right. In my hacking around with the plugin I did discover the issue of multiple paragraphs. So, yes, an enclosing div for the entire excerpt would be the right way to go.

Thinking some more about the anchor tag itself, if it is within the excerpt div then there is no need to have a style for the anchor. We can use descendant selectors, based on the div, to style the link. For example, if we give the div a class of “.excerpt”, then a style of “div.excerpt a” could be applied to anchor tags within the excerpt. This just removes the need for extra coding.

Offline

Board footer

Powered by FluxBB