Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

  1. Index
  2. » Archives
  3. » [archived] kgr_safe_excerpt

#37 2005-05-16 00:11:03

mericson
Member
Registered: 2004-05-24
Posts: 137
Website

Re: [archived] kgr_safe_excerpt

Trying out this plugin, but unsuccesful. My form looks like below, however I end up with all my article titles but no bodies.

<code>
<div id=“article”>
<h3><txp:permlink><strong><txp:title /></strong></txp:permlink>
&middot;
<txp:posted /></h3>

<txp:if_individual_article> <div class=“txt”><txp:body /></div>
</txp:if_individual_article>

<txp:if_article_list> <txp:kgr_safe_excerpt words=“100” linktext=“Read more…” /> <br/> <p style=“text-align: center”><img src=”/images/45.jpg”/></p>
</txp:if_article_list>

</div>
</code>

Offline

#38 2005-05-16 00:49:17

alicson
Member
Registered: 2004-05-26
Posts: 465
Website

Re: [archived] kgr_safe_excerpt

sorry if this is completely off base.. but did you check that the plugin is turned on (to Yes) in the admin/plugins tab?


textpattern.org :: find and share Textpattern resources
docs.textpattern.io :: Textpattern user documentation

Offline

#39 2005-05-16 01:29:30

mericson
Member
Registered: 2004-05-24
Posts: 137
Website

Re: [archived] kgr_safe_excerpt

Doh! It has been many months since I installed a new plugin, that was the problem. Thanks!

Offline

#40 2005-05-16 01:33:40

alicson
Member
Registered: 2004-05-26
Posts: 465
Website

Re: [archived] kgr_safe_excerpt

:)


textpattern.org :: find and share Textpattern resources
docs.textpattern.io :: Textpattern user documentation

Offline

#41 2005-06-12 15:56:27

Coin
New Member
Registered: 2005-06-01
Posts: 2

Re: [archived] kgr_safe_excerpt

Just wondering, is there anyway of it being modified so that it showed the number of words, but only to the nearest “.” ? So, say I have words=“55” and after word #49 there is a “.”, it would cut out words #50-55? So that it doesn’t cut in the middle of a sentence?

I guess placing “…” in the plugin after the post will suffice for the moment, but a thought nevertheless (I’m a bit useless at PHP honestly…)

Offline

#42 2005-06-13 19:35:37

jstar
Member
Registered: 2005-05-12
Posts: 12
Website

Re: [archived] kgr_safe_excerpt

I have installed this plugin, but it does not seem to be working properly. I am new to TXP so I could be that I haven’t set something right.

I have a section on the site I am working on that is set up as a blog. I have created a template for that section called blog and in the code I am calling the form that I created in < txp: article form=“blog” />. My form is called blog and it looks like this:

<pre>
<h3><txp:permlink><txp:title /></txp:permlink> :: <txp:posted /></h3>
<txp:body />
<txp:kgr_safe_excerpt words=“150” linktext=“Read more…” />
<br /><br />
</pre>

But when I view the page (http://dev.matthewpaulturner.net/blog) I see the posting, looks like a repeat of the first paragraph & then the “Read more…” link. I just want to show the first 150 words of the article, but it doesn’t seem to be working. Any ideas?
Thanks,
-j


“On the run from Johnny Law… ain’t no trip to Cleveland.”

Offline

#43 2005-06-13 20:45:26

vagari
Plugin Author
Registered: 2004-08-25
Posts: 19

Re: [archived] kgr_safe_excerpt

Remove <code><txp:body /></code> from your form, you’re basically telling it to show it twice. This plugin replaces the <code><txp:body /></code> element in the form.

Last edited by vagari (2005-06-13 20:46:29)

Offline

#44 2005-06-13 21:16:36

jstar
Member
Registered: 2005-05-12
Posts: 12
Website

Re: [archived] kgr_safe_excerpt

Awesome! Thanks vagari!

One more question. Is there a way to allow the /blog article to still show a posted image? The top article has an image and when I removed the <pre><txp: body /></pre> tag the image is no longer in the excerpt?
Thanks again for your help!
-j


“On the run from Johnny Law… ain’t no trip to Cleveland.”

Offline

#45 2005-06-13 22:07:18

jstar
Member
Registered: 2005-05-12
Posts: 12
Website

Re: [archived] kgr_safe_excerpt

I just used the ‘excerpt’ field and called the image in there. That will work just fine for now. Thanks again for the help! Thanks to Kurt for the great plugin!
-j


“On the run from Johnny Law… ain’t no trip to Cleveland.”

Offline

#46 2005-06-22 13:32:03

ifeelcool.com
Member
Registered: 2005-01-03
Posts: 10
Website

Re: [archived] kgr_safe_excerpt

Hello KurtRaschke,

I have made a few changes to the code of your plugin! Have a look maybe you like them maybe not. It will now strip the paragraph tag from the excerpt and gets a new attribute styleclass wich wraps the link in a span-tag with the given class name!
Here it is:
function kgr_safe_excerpt($atts) { if (is_array($atts)) extract($atts);

global $thisarticle; $words = (!empty($words)) ? $words : 20; if (!$styleclass) $styleclass = ‘readmore’; //change $countchars = (isset($countchars)) ? true : false; $countexcerpt = (isset($countexcerpt)) ? true : false; $linktext = (!empty($linktext)) ? $linktext : “lees meer”; $link = “\n<span class=\”$styleclass\”>\n”. permlink(“”, $linktext).”</span>\n”; $bodycount = ($countchars) ? strlen($thisarticle[“body”]) : count(explode(” “, $thisarticle[“body”])); if (trim($thisarticle[“excerpt”]) != “”) { $excerpt = strip_chars($thisarticle[“excerpt”],Array(“p”));//strip paragraph-tag- change if ($countexcerpt) { $excerpt = ($countchars) ? substr($excerpt,0,$words) : implode(” “, array_slice(explode(” “, $excerpt), 0, $words)); } $excerpt = $excerpt.”<br />”.$link; } else if ($bodycount < $words) { $excerpt= strip_chars($thisarticle[“body”],Array(“p”));//change } else { $body = strip_chars($thisarticle[“body”],Array(“p”));//change $excerpt = ($countchars) ? substr($body,0,$words): implode(” “, array_slice(explode(” “, $body), 0, $words)); $excerpt = $excerpt.”<br />”.$link; } return $excerpt; }

//added function to strip tag(s)
function strip_chars($string,$chars) { $tags_to_strip = $chars;

foreach ($tags_to_strip as $tag) { $string = preg_replace(“/<\/?” . $tag . “(.|\s)*?>/”,”“,$string); } return $string; }

Last edited by ifeelcool.com (2005-06-22 13:33:02)

Offline

#47 2005-11-09 22:27:30

jstar
Member
Registered: 2005-05-12
Posts: 12
Website

Re: [archived] kgr_safe_excerpt

Hey Kurt,
Great job on the plugin. I have a quick question for you. Is there any way to get around the kgr_safe_excerpt hiding article images if your article reaches your defined word limit? My setup looks like this: <code><txp:kgr_safe_excerpt words=“100” linktext=“read more &raquo;” /></code>. If I have an image in that article and it’s word count is past 100 it does it’s job, but it also hides the image. Any way around that?
Also how would I add in an anchor class to the href the plugin creates?
Thanks for your help!
-j

ps: I’m running Textpattern · 4.0.2


“On the run from Johnny Law… ain’t no trip to Cleveland.”

Offline

#48 2005-11-09 23:13:11

jstar
Member
Registered: 2005-05-12
Posts: 12
Website

Re: [archived] kgr_safe_excerpt

ifeelcool.com,
Can you repost your mod of the kgr_safe_excerpt plugin please using the < code > < /code > tags please? I have tried to implement your code, but I can’t get it to work because of issues copying it from the browser.
Thanks,
-j


“On the run from Johnny Law… ain’t no trip to Cleveland.”

Offline

  1. Index
  2. » Archives
  3. » [archived] kgr_safe_excerpt

Board footer

Powered by FluxBB