PDA

View Full Version : How to randomly cycle content displayed on front page (section manager)?


Mikhailtech
11-26-2011, 10:53 PM
Is there a way to randomly display content in a section each time the front page is loaded? I don't see it as an option in the "display order" dropdown.

I was told at the vb forums it would have to be some sort of modification. Has anyone tried this?

Mikhailtech
11-29-2011, 02:51 AM
bump ... anyone?

Dead Eddie
11-30-2011, 03:14 AM
I'm a little confused. Are you looking to display content from a random section each time the home page loads? Or display content in a random order?

Mikhailtech
12-12-2011, 03:26 AM
Display content in a random order within a section (regardless of category). There's no option to display in random order right now.

Dead Eddie
12-12-2011, 12:41 PM
Create a new plugin that hooks into vbcms_collection_section_querydata and add the following code:


//comma separated list of nodeids to apply this to
$sections = array(1,5);

if(self::QUERY_BASIC == $required_query && in_array($this->filter_node_exact, $sections))
{
$this->sortby = ' ORDER BY RAND()';
}

Edit the section(s) you want to apply it to at the top, and you're good to go.

summytinc
12-15-2011, 05:14 AM
Wow, that works great. Any ideas how to get it to work on the home content or in sections which include sub-section content? Thanks.

Dead Eddie
12-16-2011, 12:27 PM
Wow, that works great. Any ideas how to get it to work on the home content or in sections which include sub-section content? Thanks.

By default, your "home content" is at node 1. If you've changed that, you'll have to set it for the node you've designated as your home page.

This does work on sections that includes sub sections.

Mikhailtech
12-26-2011, 01:44 AM
I can't get this to work. Did as you said, I'm guessing you have to select the section in the array(x,x) part? I tried putting in different numbers and it's not working.

I have Home > Articles (section) > (categories) of articles > actual content.

See attachment.

What am I doing wrong? And how do I figure out what "node" my home content is in (if it's not 1 because that doesn't seem to work)?

Dead Eddie
12-26-2011, 12:43 PM
I can't get this to work. Did as you said, I'm guessing you have to select the section in the array(x,x) part? I tried putting in different numbers and it's not working.

I have Home > Articles (section) > (categories) of articles > actual content.

See attachment.

What am I doing wrong? And how do I figure out what "node" my home content is in (if it's not 1 because that doesn't seem to work)?

1. Yes, you need to put the actual nodeids of the sections you want to randomize there. Those are the numbers in the url (1-Index).

2. If you want to see what node controls your homepage, go to admincp -> Settings -> Options -> Content Management -> Default Page

3. What do you mean when you say it's "not working"? It's not randomizing the content? It's giving you a blank page? It's doing something else unexpected?

4. What version of vBulletin?

summytinc
02-09-2012, 01:27 PM
Thanks for your help on this. Can this be set up with a cache so that it doesn't run a new query when paginating through articles in that section?

Dead Eddie
02-12-2012, 01:06 PM
Without digging back into the code, I'd suspect it's possible, but doing so would require code edits and a bit more work than just a simple plugin.

Mikhailtech
03-05-2012, 01:53 AM
Ok, I figured out the problem. On my article section which has categories (http://www.pcshoptalk.com/content.php?2) this works. However, the Article section is a sub-section of the Home section and what's displayed on the main page is the Home section > Article sub section > categories > content.

So basically if I click on the "articles" link it will randomize the content shown on that page, but not on the front page. Can I somehow either display just the article section on the front page or make the article section not a sub section of home?

Does this make sense?

This is why I'm not a programmer ...

Dead Eddie
03-06-2012, 11:36 AM
Ok, I figured out the problem. On my article section which has categories (http://www.pcshoptalk.com/content.php?2) this works. However, the Article section is a sub-section of the Home section and what's displayed on the main page is the Home section > Article sub section > categories > content.

I have a feeling it's just me, but I'm not understanding your setup. Categories shouldn't come into it at all...Articles/Sections are the only node types you've spoken about using. And, this should work regardless of where you are on the node tree.

So basically if I click on the "articles" link it will randomize the content shown on that page, but not on the front page. Can I somehow either display just the article section on the front page

Yes. AdminCP->Options->Settings->Content Management->Default Page

or make the article section not a sub section of home?

No.