You are not logged in.
Since I’ve done it with images and other stuff, I figured I might as well tackle text as well.
Written with a cursory nod of appreciation to Drew McLellan and Manuel Ebert who have both made random text plugins before, this one takes it a step further. You can choose to grab your text from a pool given in a fixed string, a TXP field, a URL field, a TXP variable, a database or a file. And you’re not limited to just grabbing one item.
Each item you choose is optionally passed to a form/container where you can insert them into markup using the now-customary {replacement tag syntax}. Check the examples in the help for some gentle prods and ideas. I’m sure there are all sorts of wacky things you can randomize, like pulling an entry or two out of a sed_pcf.
There’s plenty of scope for extensions to this one if anyone has any ideas. Possible things to do:
Here is the latest version for your comfort and enjoyment: download
Any ideas or problems, you know where I live.
Revision history
————————
All available versions and changes are listed here. Each entry indexes the relevant post(s) in this thread to learn about the features.
{smd_rnd_txt_chosen_item}var_prefixfile_delim (thanks MyOtheHedgeFox)Last edited by Bloke (2011-05-03 00:07:23)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern.
Txp Builders – finely-crafted code, design and Txp
Offline
Ops, I’ve installed it on a 4.0.7 but haven’t had time to test it yet! Also would like to know if it works!
Offline
Liiint wrote:
Is anybody else having problems with this plugin on Txp 4.07.
Congratulations on being the first person (besides myself) to use it!
But I wouldn’t have thought it was the plugin: it’s so dim and simple it should run on any TXP version! It is working for me under 4.0.7 but there are so many ways to use it, anything’s possible. Would you mind posting the tag you are using that is causing problems and any associated information, and I’ll see if I can work out if the plugin’s to blame. Also, when you say “stopped working”, are there any errors if you put your site in debugging mode?
The smd plugin menagerie — for when you need one more gribble of power from Textpattern.
Txp Builders – finely-crafted code, design and Txp
Offline
Make that two people. ;)
Here’s my newbish question:
I plan on adding a quote of the day type thing, but I’m not really grasping how to get the plugin to pull the quotes from a textpattern article, preferably one that’s not live and set to hidden or whatever other setting will stop the full list of quotes from appearing on my site. :P
Any help would be greatly appreciated!
Offline
hamsteralliance wrote:
I plan on adding a quote of the day type thing, but I’m not really grasping how to get the plugin to pull the quotes from a textpattern article
Hi, if you want to use an article to hold the quotes there are a couple of ways to approach it. I believe if you “hide” the article TXP won’t be able to see it so you’ll need to make it visible. But we can hide it in other ways.
Method 1:
"All that we see or seem is but a dream within a dream."
-- Edgar Allan Poe
|
"Assassination is the extreme form of censorship."
-- George Bernard Shaw
|
...
<txp:smd_random_text type="field" source="excerpt" />
<txp:article_custom section="quotes" limit="1" /> (or perhaps use id="ID_of_article"). You may have to specify a different form too — one that only outputs <txp:body />, but that depends on the layout of your default FormMethod 2 (slightly easier):
If you are going to the trouble of creating a form you might as well do it this way instead:
<txp:smd_random_text type="field" source="body" />
quotes, and save the article<txp:article_custom /> tag as above with the ID of the Quotes articleEither of those methods (or a combination of forms/containers depending on your preferred way of working in TXP) will do the job. As long as you never link to the “hidden” section, nobody will be any wiser that it exists :-)
Does that help, or at least give you some ideas about how to approach it?
Last edited by Bloke (2009-01-27 10:15:30)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern.
Txp Builders – finely-crafted code, design and Txp
Offline
Sounds good to me!
Now I just gotta figure out how to get it in the spot I want it in. Thanks! :D
Offline
I’ve actually tried it out now and it’s not working as well as planned. :)
I created the section, the form and the article with a few lines of text in it.
Wherever I use the article_custom code you have up there it ends up posting the entire article and attaching the author name and timestamp to it too.
like this: http://www.hamsteralliance.com/upload/donotwant.gif
Any ideas? :D
Last edited by hamsteralliance (2009-01-27 11:17:20)
Offline
hamsteralliance wrote:
Wherever I use the article_custom code you have up there it ends up posting the entire article and attaching the author name and timestamp to it too.
That’s because it’s rendering the article using the default Form, which tells it to display a title, the body, the author, the timestamp, the categories, etc etc etc. What you need is a form that displays a single thing: the body. In fact, if you’re using TXP 4.0.7 or higher, you can take advantage of the fact that the article tags can be containers. Try this:
<txp:article_custom id="blaaah">
<txp:body />
</txp:article_custom>
The smd plugin menagerie — for when you need one more gribble of power from Textpattern.
Txp Builders – finely-crafted code, design and Txp
Offline