Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#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

#24 2004-12-13 19:26:52

domfucssion
Plugin Author
Registered: 2004-10-23
Posts: 39

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

I have been experimenting with this plugin and noticed that it has problems if the body of the post has any other block level tags than p’s. eg. if a post’s body is just a single blockquote element the plugin searches for a closing p tag – doesn’t find one and leaves the closing blockquote out of the source.

A solution might be to take each substring from the last block level tag – whatever it is, but that is beyond my php skills so I can’t fix it.

How would one code a substring from an array of possible tags? eg. div | blockquote | p | ins | del | pre

note I did not include Hn tags in my array ‘cos that might be silly in this context.

the code fromm the plugin at the moment is:

$p_end[$i] = strpos($body, ‘</p>’) + 4;

what I need to do to hack this plugin is somthing like :

$p_end[$i] = strpos($body, $anyOneOfMyBlockLevelElms) + $theStrLenOfClosingBlockTag;

sorry for such public hacking of your plugin, but I kind of need it to be slightly different.

update:after a bit of messing about i found that the missing tag only hapens when using textile, and seems OK with regular html tags. So I don’t really know what is going on at all.

Last edited by domfucssion (2004-12-13 22:39:56)

Offline

#25 2004-12-14 03:42:17

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

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

I must admit that this plugin was designed for my textpattern based weblog and I wasn’t really putting to much consideration into how the plugin might handle other types of content.

I’ll see about implementing a way to detect other types of tags, but for now, this plugin will only correctly parse content that is enclosed in paragraph tags. As far as I know, textpattern should enclose just about anything you enter in paragraph tags, but maybe someone else understands this situation better than I.

Does every post automatically get wrapped in paragraph tags? If not, what are the conditions that create paragraph tags when content is being entered?

Offline

#26 2005-02-02 18:32:19

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

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

One thing that can be easy to forget with plugins is that after you’ve installed them, they still need to be enabled before they’ll work. In you textpattern admin, on the Plugins page, there should be a list of your installed plugins with a column on the right that sasy “Active”. If the plugin says “No”, just click on the “No” link to make it say “Yes”.

If this isn’t the problem, then you’ll have to give me a better idea of what you’re using for your TP code, in your previous post nothing showed up because you didn’t put your code within the PRE tags:

<pre>

&lt;pre &gt; Put your code here &lt;/pre &gt;

</pre>

Last edited by philipashlock (2005-02-02 18:34:41)

Offline

#27 2005-02-16 20:59:39

EddieG5
Member
From: Georgia
Registered: 2004-03-03
Posts: 96

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

I’m having problems with this plug-in …

I created a form called “ACYA” and have the code:
<h3><txp:permlink><txp:title /></txp:permlink></h3> <txp:beginning length=“25” linktext=“Read More” styleclass=“morelink” />

Now, when I call this form from a page using:

<txp:article_custom form=“ACYA” section=“ACYA” />

I get the title of the article, the first 25 characters and the link to the full article. But when I click on the link, the rest of the article does not show … it appears the same way as it does before – just the title and the first 25 letters.

Am I doing something wrong?

Thanks for your time and the plug-in!

Offline

Board footer

Powered by FluxBB