Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: Plugin idea: Word Count?
Hey, sorry for not replying earlier.
I think it would be a bit more tricky to do. Off the top of my head, I can’t think of a way to do it that wouldn’t involve iterating through all your posts and counting the words in each post. The plugin would have to do something like select all the posts your made from your database, and count all the words in each one. It might slow things down a lot.
It would be better if the word count was maintained as a statistic when you save an entry in the database. Then retrieving the word count would be simple, and retrieving the total word count would also be simple.
I’ll try doing something anyway.
Offline
Re: Plugin idea: Word Count?
Cool beans, thanks!
Offline
Re: Plugin idea: Word Count?
What? That’s wicked good. Alright then, I will add that to my word count plugin then. I didn’t know there was a length function in SQL.
Update: I’ve updated my plugin to use the sql code posted above. So now there is a total word count tag.
Last edited by ramanan (2004-05-19 02:25:47)
Offline
Re: Plugin idea: Word Count?
Sweet, thanks Radley and ramanan.
Offline
Re: Plugin idea: Word Count?
Hi there,
Following is a form template of type article:
<code>
<div class=“entry”>
<span class=“date”><txp:posted /></span>
<h3>
<txp:permlink><txp:title /></txp:permlink>
</h3>
<p><txp:excerpt /></p>
<p class=“entry_footer”>
<txp:permlink>Read more …</txp:permlink> [<txp:rsx_word_count />] | <txp:comments_invite />
</p>
</div>
</code>
I am trying to display the number of words in an article after the excerpt. All I’m getting is “Read more … []”.
What am I doing wrong?
Let me know if more info is required.
ta
Offline
Re: Plugin idea: Word Count?
When you go to the plugin page, make sure that the plugin is active. There is a yes/no thing that tells you whether the plugin is in use or not. That might be the problem.
Offline
Re: Plugin idea: Word Count?
Yes of course!
Silly me! You would’ve thought I’ll figure that out. Specially since this is my third plugin! Oh well, having a slow Sunday I suppose.
Thanks Ramanan, your plugin is working fine.
Offline
Re: Plugin idea: Word Count?
ramanan is the version of your plugin with Radley’s SQL addition the one you link to here ?
Because I don’t see any SQL in the code for that plugin. Unless I’m really confused, not being very adept at php and textpattern plugin writing.
Thanks!
Offline
Re: Plugin idea: Word Count?
Yep. That should be the one. There should be two tags that you can use. <txp:rsx_word_count />
and <txp:rsx_total_word_count />
.
Offline
Re: Plugin idea: Word Count?
> ramanan wrote:
> Yep. That should be the one. There should be two tags that you can use.
> <txp:rsx_word_count />
and <txp:rsx_total_word_count />
.
Hmm, I don’t see it.
I’m looking at this: http://www.funkaoshi.com/static/rsx_word_count.txt
And the code in it is:
function rsx_word_count($atts) { global $thisarticle; $wordcount = count(explode(” “, $thisarticle[‘body’])); return $wordcount; }
Should be more right?
Thanks!
Offline