Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Plugin: pfa_beginning - excerpt generation based on length attribute
NOTE: This plugin is now maintained as Beginning and not pfa_beginning and can be found at http://forum.textpattern.com/viewtopic.php?pid=96955
Provides the <code><txp:beginning /></code> tag allowing automatic excerpt generation from article body based on length attribute
Available here
I think there have been a few other plugins that will automatically create an excerpt (in fact one was just posted), but this one is a little different. Instead of including the first few words of the article body, this is based on the number of characters in the first few paragraphs of the article body. So no matter what, there will be at least one whole paragraph for the excerpt. This way we don’t have to worry about stripping html tags because we include both opening and closing < p > tags in the excerpt.
here is the extended help that comes with the plugin:
The only attribute for this plugin is ‘length’. If you do not specify a length then the default of 350 characters will apply. This plugin will display the first paragraphs of the entry until the total number of characters in these paragraphs is above the ‘length’. So the first paragraph that creates a combined (with previous paragraph’s character count) total of more than the number of characters in ‘length’ will be the last paragraph displayed.
Example tag:
<code><txp:beginning length=“500” /></code>
***
(note: the info below is updated for each new release of the plugin)
Name: pfa_beginning
Version: 0.5 rc3
Author: Philip Ashlock
Author URL: http://web.philitopia.com
Modified: 2005-05-25
Download URL
Discussion Thread URL
Last edited by philipashlock (2006-09-12 03:11:24)
Offline
Re: Plugin: pfa_beginning - excerpt generation based on length attribute
anyway to add in a “read more” link?
Listen to Kenneth
Offline
Re: Plugin: pfa_beginning - excerpt generation based on length attribute
Well you can do this quite easily with in a form:
<pre>
<txp:beginning />
<p><txp:permlink>Read the full article</txp:permlink></p>
</pre>
I guess the only problem with simply doing that is that even if the excerpt displayed is the entire article there will still be a link that says “read the full article” (even if they just did)
Last edited by philipashlock (2004-07-29 09:44:14)
Offline
Re: Plugin: pfa_beginning - excerpt generation based on length attribute
That will not work at my blog.
Whan I put this in a form for example like this
<code>
<txp:if_individual_article>
<txp:body />
</txp:if_individual_article>
<txp:if_article_list>
< txp:beginning />
< p >< txp:permlink>Read the full article< /p >
</txp:if_article_list>
</code>
only the line <code>< txp:beginning /> < p >< txp:permlink>Read the full article< /p ></code> and now article or link is shown.
can you help me how to build a form that works proper?
Last edited by holli.p (2004-07-29 07:12:38)
Visit my Textpattern sites:
Northerndelight | Hasenbude
Curiculum Vitare | Rezepteblock
Offline
Re: Plugin: pfa_beginning - excerpt generation based on length attribute
holli.p:
I’m sorry for the confusion, but it looks like I added some extra whitespace in the tags in my previous post. I’ve since edited that post so that the preformatted tags are shown. It looks like you copied exactly what i had before and also added the spaces in the tags, but you shouldn’t have those in there.
What you want should look like this:
<pre>
<txp:if_individual_article>
<txp:body />
</txp:if_individual_article>
<txp:if_article_list>
<txp:beginning />
<p><txp:permlink>Read the full article</txp:permlink></p>
</txp:if_article_list>
</pre>
Last edited by philipashlock (2004-07-29 10:21:10)
Offline
Re: Plugin: pfa_beginning - excerpt generation based on length attribute
wow, great thats it. but one note:
you should close the permalink tag
<code><p><txp:permlink>Read the full article</txp:permlink></p></code>
otherwise the rest of the page is linked to the artikel ;-)
one question more:
when I write an article without an paragraph and use the form with your plugin, the entire article is displayed but the link to the full artikel is shown anyway. Some idea?
Visit my Textpattern sites:
Northerndelight | Hasenbude
Curiculum Vitare | Rezepteblock
Offline
Re: Plugin: pfa_beginning - excerpt generation based on length attribute
Well currently, my plugin isn’t set up to determine whether or not it is displaying the full article. So the solution should be to update this plugin to allow you to specify a the link text to the permalink, but not to display this if the entire article is shown. I think that is how kgr_safe_excerpt works.
Because my plugin is similar to kgr_safe_excerpt I thought I would collect ideas on what needs to be improved between the two of them, what works, what doesn’t and then try to make a plugin that addresses all issues. Your situation really helps me to figure out what the faults are. I’ll try to fix the plugin, so that it will address a situation like the one you are talking about and have it available in the next day or two.
I put a post on this form a little while ago to let people know that I wanted to hear what they were liking and disliking about these excerpt plugins, so please keep giving me feedback on the best way for a plugin like this to operate.
That post can be seen here
And by the way, I really like the design of your website.
Offline
Re: Plugin: pfa_beginning - excerpt generation based on length attribute
the only addition to yours that i’d like would be the inclusion of a customizable ‘continue reading’ link.
Listen to Kenneth
Offline
Re: Plugin: pfa_beginning - excerpt generation based on length attribute
Ok, this is just a little update, i’m just going to give you a file to let you copy and paste the revised code in the plugin page to update it. I’ll release a newer version as an actual installable plugin when it’s a little more polished and hopefully I’ve received a little more feedback.
All I’ve added is the ability for a “continue reading” or “permalink” link text (like kgr_safe_excerpt). You can now use the tag like this:
<pre>
<txp:beginning length=“150” linktext=“permalink” />
</pre>
both attributes are optional
you can get the fresh code here: beginning tag update
Oh, and i’m thinking of renaming this plugin to: auto_excerpt
How does that sound? I’m not too clear on the whether or not it’s necessary for me to prepend my initials to the tag/function name. The plugin template asks for this to be done to the name of the plugin, but not specifically to the tag itself.
Last edited by philipashlock (2004-08-01 11:02:26)
Offline
Re: Plugin: pfa_beginning - excerpt generation based on length attribute
I’ve made a pretty significant update to the plugin, it should be much more useful and satisfying. Suggestions for further improvements are welcome. Get it here
Here is the updated Extended Help and plugin information:
There are two attributes for this plugin, ‘length’ and ‘linktext’. If you do not specify a length then the default of 350 characters will apply. This plugin will display the first paragraphs of the entry until the total number of characters in these paragraphs is above the ‘length’. So the first paragraph that creates a combined total (combined with previous paragraph’s character count) of more than the number of characters in ‘length’ will be the last paragraph displayed. If the number of characters that are displayed is less then the value specified by ‘length’ then you can have a permalink displayed to show the full article. The link text of this permalink can be specified with the attribute ‘linktext’. (NOTE: The excerpt generated could actually end up being the full article because we give precedence to paragraphs. If this happens ‘linktext’ will not be displayed because we are already showing the whole thing.) Also: If you’ve created an excerpt for an entry then your excerpt will be used in place of anything generated by this plugin.
Example tag:
<pre><txp:beginning length=“500” linktext=“Read More” /></pre>
***
Name: pfa_beginning
Version: 0.2
Author: Philip Ashlock
Author URL: http://web.philitopia.com
Modified: 2004-08-17
Download URL
Discussion Thread URL
Last edited by philipashlock (2004-08-17 08:15:13)
Offline
#11 2004-10-14 02:18:10
- hafnius
- Archived Plugin Author
- From: DK
- Registered: 2004-09-02
- Posts: 47
Re: Plugin: pfa_beginning - excerpt generation based on length attribute
great plugin
One Q though. The generated permlink has an empty title tag. How do i write in that one?
<code>
<a href=”/permlink/” title=”?”>Foo</a>
</code>
/Hafnius
Stupid me… forgot that the title gets filled from the en_gb.txt.
The Q remains though – is there a way of customizing the “Permanent link to this article”?
/Hafnius
Last edited by hafnius (2004-10-14 02:26:18)
– Nobody puts Baby in the corner !
Johnny Castle, Dirty Dancing
Offline
Re: Plugin: pfa_beginning - excerpt generation based on length attribute
I’m sure there is, but I haven’t looked into it yet. I’m sorry but I’m awfully busy with other things at the moment and don’t see this as a significantly needed feature. The way this plugin uses the permalink function is done in such a way that the a tag is completely out of my control without hacking into it some more. Maybe someone else would be interested in doing this.
Offline