Content last modified Monday 6 March 2017
hop to #bottom
Categories:
Author:
Current version:
0.1
About It:
Get it:
Rate it:
  • Helpful?
  • 0 Yes
  • 0 No
Flag it:

If you'd like to provide updated information and do not have access to directly edit, please contact the site admin; thanks!

cnj_excerpt_logic

Here is a simple plugin that allows logic if the excerpt is empty or if it is not empty. How to use the code, and an example of how I use it is part of the plugin help. Basically if I have a long post I put the short front page part in the excerpt and then continue the article in the body, but if it is a short entry I just use the body of the article, this plugin enables my form to display just the excerpt or the body depending on if the excerpt has content.

Article Request Count:
Initially released:
2004-04-19
Posted here:
23 Mar 2005
Article modified:
02 Nov 2006

You may want to leave your comments/questions at the Forum thread for quicker feedback. Otherwise, comment away:

Your comment will NOT be submitted until you click the 'Submit' button on the next pageload.

Commented (4)

so i was trying to use this on an RC3 install (revision 272), and found that the cnj_if_excerpt part worked fine, but the cnj_if_not_excerpt was turning up completely blank each time.

some help from wonderful, incredible persons Remillard and ubernostrum gave me the following solution:
in place of the current cnj_excerpt_logic plugin text, have this:

function cnj_if_excerpt($atts, $thing) {
global $thisarticle;
if(preg_match(’/\S/’, $thisarticle[‘excerpt’])) {
return parse($thing);
} else {
return;
}
}

function cnj_if_not_excerpt($atts, $thing) {
global $thisarticle;
if(!preg_match(’/\S/’, $thisarticle[‘excerpt’])) {
return parse($thing);
} else {
return;
}
}
Mister T in AZ:
I have to say I’ve read and reread all the descriptions of this plugin and just don’t understand.

Sadly, I think that this may be a very well written plugin—with very poorly written descriptions.

Can anyone break this down for me?

I’m hoping this simply will look at a post, and if it is long, put a shortened version of the post in the excerpt – for me.

OR maybe it will notice if you wrote an excerpt – add a “continue reading” but if not—no need.

I guess I don’t know EXACTLY what “allows logic if the excerpt is empty or if it is not empty” means.
The plugin simply figures out of the article has an excerpt or not, and acts accordingly. For example, if you put the <txp:cnj_if_excerpt> tag into a form, then anything between the opening and closing <txp:cnj_if_excerpt> tags will only show up when the article has an excerpt. Similarly, anything between pening and closing <txp:cnj_if_not_excerpt> tags will only show up if there isn’t an excerpt.

There isn’t anything here which would automatically output a link of any kind; to get what you want, try this in your article list form:

<txp:cnj_if_excerpt>
<p><txp:excerpt /></p>
<p><txp:permlink>Read More...</txp:permlink></p>
</txp:cnj_if_excerpt>
Download link is working again.. Plugin is now hosted at textpattern.org.

This is one of my favorite plugins…

Subscribe to this article's comments RSS feed. [ ? ]   View Recent Comments across the site.

You know you want to visit the Archives.

Browse

Categories


Articles

There are also tag clouds, 'cause those are fun.
Published with Textpattern