MTRandomEntries is a plugin that, like MTRandomComment , pulls out a random entry from the current blog.
Usage Example:
<MTRandomEntries category="Gaming" lastn="5">
<a href="<$MTEntryLink$>"><$MTEntryTitle$></a>:<br />
<$MTEntryExcerpt$><br />
</MTRandomEntries>
Download randomentries.tar.gz or randomentries.zip , unpack it, and place randomentries.pl in your plugins directory.
MTRandomEntries
- Container tag for the random entries that acts like MTEntries
- If used within MTCategories , the random entries are chosen from current category.
- If used within MTEntries , MTEntry , an Individual Archive, etc. or anything that contains an entry, the random entries are chosen from the categories of the current entry, OR-ed together.
- It takes the following arguments:
- category: Restrict the list of entries from which the random entries are chosen to those in specific categories. You can either supply a specific category, or use AND or OR like in MTEntries
- lastn: Generate n random entries, defaults to 1
ChangeLog
- Version 0.5: Added support for current entry categories
- Version 0.45: Added support for AND and OR in category argument
- Version 0.3: Added support for MTCategories
- Version 0.2: Fixed lastn > number of entries bug
- Version 0.17: Fixed MT Date tag bug
- Version 0.15: Fixed bleeding
- Version 0.1: First version
Hey David,
Is there any way to use this with only a particular category? I'm setting up a photography site, and I'd like to show a random picture from each of my multiple categories.
Question about this plugin -- is the randomization on REBUILD or on REFRESH?
It seems that having it re-randomized on refresh is almost more desirable than rebuild - each one has it's point...
Thanks!
This worked fine until I started using XML-RPC tools to post to my blog. Now, when I ask MT to do a rebuild via XML-RPC, it complains that I'm using an MTEntryLink outside MTEntries - it's fine if I rebuild manually (ie by clicking Rebuild), but it breaks if I try to rebuild via XML-RPC.
Any ideas? I love the feature - shame to have had to take it away because I'm now posting via SMS.
Thanks in anticipation - sorry to bother you...
Is there any way to make this work over multiple categories? (i.e. category="1933 OR 1934 OR 1935")
I receive a "no 1933 OR 1934 OR 1935 category" error now.
THanks.
Wow. You work quickly. Thanks.
how do I restrict the random entries to my current post's category ?
thanks!
Doh!
Take that!
http://www.rayners.org/pics/pow-snowball.png
I'm currently using this on my index page of a photoblog and it works fine, but when I put the same code on my individual archive page, it errors out on my latest entry. (I've uploaded new entries and it always dies on the latest.)
[error]
Building entry 'Snowy Landscape' failed: Build error in template 'Individual Entry Archive': Error in tag: No such category 'MT::Category=HASH(0x87764b4)'
[/error]
Do you have a clue what is wrong, because I'm completely stumped. I couldn't find anything in your comments here or in the thread on the MT forums.
Thanks,
Erik
This is just fabulous...Thanks for the work.
Emily asked this but I didn't see an answer - is there a way to make this work on refresh instead of on reload? Reload is useful, but refresh would be even better. Thanks for the great plugin!
Well, because of the way MT builds its pages, a plugin can only grab a random entry when the template is rebuilt, not when it is refreshed. If you want to do it during a refresh, you'll have to use PHP to do that.
I'm now using this in combination with php in one place, and in combination with MTOtherBlog in another.
Your plug-ins are neat.
I like how your site is set up. looks great.
Hey Dave, I want to do something like this- is it possible?:
So that it would select randomly 1 entry from any random category while including every category on the blog. Is that another plugin idea, like MTRandomCategories?
Your site looks great. What are your fees to do one for me?
I really like your plugin for what it does, but I came across a strange phenomenon: It seems that the MTRandomEntries tag works somewhat different to the MTEntries tag.
Could you please help my fixing that:
My fotolog is at http://www.alexemde.de/fotolog
It shows 5 recent entries at the bottom of the side but I rather have it show 5 random entries.
So I changed the opening tag as well as the closing tag from MTentries to MTRandomEntries, the rest of the template stays the same word by word. And here is what it does: http://www.alexemde.de/fotolog/week_2003_08_03.html
Any suggestions?
Cheers, Alexandra
I'm also getting this error when trying to build on individual entry pages, sans category variable (fine when I call the category manually on index pages):
[error]
Building entry 'Entry Title' failed: Build error in template 'Individual Entry Archive': Error in tag: No such category 'MT::Category=HASH(0x87764b4)'
[/error]
Any idea why?
I created a version of this plugin in PHP today that will refresh the list upon page reload, rather than template rebuilding. Check it out: http://www.gabeanderson.com/life/2003/08/29/mt_random_entries.php.
Is there a way to exclude only a couple of categories? There are many categories in the blog where I'm using this, and I'd like to just exclude one or two without listing the ones I'm including. A "NOT" function would be nice in the category selection, in other words.
Hi,
I have added the script to the page. Script displays 1 entry from specified category. But this random entry displayed on my site is only generated when I rebuild my site / page.
Is is possible to show randomly this entries each time page is reloaded / each time user makes a visit to the site?
-- m
The entries can't be random every time I refresh the browser :(
Same problem as a couple of others - on individual index pages, get
Build error in template 'Individual Entry Archive': Error in tag: No such category 'MT::Category=HASH(0x86fb3bc)'
Shame. I was keen to get this working :(.
Here's some craziness. I want to use this to generate a random entry that excludes categories. Is that possible unto itself or using other plugins in cohoots?
what particular php feature are we going to use if we want to have a random entry displayed each time a page is reloaded? ty
congrats mate! Fine job and fine site!
David
Ok, I will sign your blog. I really love your site.
Kevin
Ok, I will sign your blog. I really love your site.
Samuel
Getting the indiv entry problem myself:
Build error in template 'Individual Entry Archive': Error in tag: No such category 'MT::Category=HASH(0x86fb3bc)'
This is what happens when I don't specify a cateogry. But the added problem is that when I do specify a category the rebuild stalls out completely after about 20 entries.. Weird behavior. If anyone solves this please email me!
i get the following error when trying to do a build that includes an MTRandomEntries tag. Any help would be appreciated.
Can't use an undefined value as an ARRAY reference at plugins/randomentries.pl line 32.
Thanks!
Hi David,
I'm getting this error when I navigate from any category archive page to this page:
http://www.empyrealenvirons.com/categorylisting.html
Fatal error: Smarty error: [in evaluated template line 93]: syntax error: unrecognized tag 'MTRandomEntries' (Smarty_Compiler.class.php, line 580) in /*my domain*/mt/php/extlib/smarty/libs/Smarty.class.php on line 1088
Any idea what it could be?
Thanks,
Joanna