Quote from: MrFussyfont at Sep 29, 2010, 09:21 PMThought I'd share something useful I discovered with getResources. Not sure if this should be posted here or in the getResources forum; too bad you can't cross-post or use tags...
The site I'm working on has a bunch of testimonials or quotes from happy customers. I wanted the ability to show a random one in the sidebar. You can do something like this with the RandomChunk add-on, but it requires a comma-separated list of chunks. Instead I put each quote in a separate resource and found a way to select one at random for the sidebar and also be able to list them all on a 'Testimonials' page.
Since the sortby param is passed to the SQL you can use the MySQL 'RAND()' function:
[[!getResources? &parents=`27` &limit=`1` &tpl=`testimonial` &includeContent=`1` &sortby=`RAND()`]]
The above will select a random resource that is a child of resource id 27. To list all the resources in random order, just change the limit to zero.
This is a nice tip, and a cool idea when you dont want to change the front side of the page, but let the code generate it everytime(in some portions of the site)... but not offense here, my reasoning:
What about google bots reading your site? i mean, having random content showing everytime your user enters, lets say, the same page, is not a cause for a possible penalty?.
i have a large websites, with thousands of page(more than 10k) and editors are not willing to change the site every day, not even every week. so i decided to do that random thing in most of my menus, that &sortby=`RAND()` code was so simple to put in every getresources, but then i remembered that MR. Google comes to my site(dunno how often a day or days) and read the content(and structure) of the site.
Or users come to my site, lets say, bryan comes to my home page, scan the entire page, and probably he likes a article(located in my right side menu), and for some reason he clicks the refresh button, and ¡boom! the article is gonna because the random code was there. Bad news for bryan because he wont be able to read it again, or recomended it to another person since the article is no longer there.
i would use it with caution in production sites, not pretty sure if google will consider this a Spam or something else indetriment of my site.
Thats my opinion.