Hi,

I'm trying to setup a random, recent, single node, front page. I'm in the process of upgrading from 4.7 to 5.x, and while in 4.7 I could manually change the “Default front page:” once per day (not exactly what I wanted, but worked okay), I read somewhere that enough of Views had been incorporated into 5.x core that there was a switch setting now to do what I truly wanted without needing the Views module loaded. Alas, I can't seem to find that.

Basically I want one random piece of full content from everything published in the last two weeks to show up on the front page of our site every time someone loads the site's front page.

I've done a multitude of searches, and after wandering through Views, CKK, Insert View, PHP snippits, and probably a dozen other modules/functions looking for the “way” to accomplish this, my brain is mush. I see many half-way there type solutions, and hints that it isn't that hard to do, but nothing so far that lights the path, and screams, “Do it like this!”

So, humbly, I come to you gurus that are more familiar with Drupal, and ask, “How do I do this? How is this accomplished without killing the server or annoying my hosting service? Failing that, just how is it done?

Thank you,

M.J. Taylor
Publisher
from Reason to Freedom

Current Site Settings:
Caching mode: Normal
Minimum cache lifetime: 10 min.

Current Add-On Modules:
Excerpt 5.x-1.x-dev
Form collect 5.x-1.0
Form store 5.x-1.0
Pathauto 5.x-1.2
Service links 5.x-1.0
Captcha $Name$

Comments

mkalbere’s picture

you could use the view module to generate the random page. And then you just link the homepage to that url view

M.J. Taylor’s picture

Okay, thanks mkalbere,

I guess I was hoping that it had been moved into Core like I thought I had read, and I just couldn't find the proper admin area to do it.

Thanks,

M.J. Taylor
Publisher
from Reason to Freedom
Wekly libertarian magazine promoting thinking for oneself, thus helping to create a free, benevolent society.

mkalbere’s picture

;-) I read to quickly your first post ...
So we are speaking about http://drupal.org/project/views.
After installing it,
- create a new view
- check the "page" view and pu the url you want
- be sure to select complete node display
- put the filter you want
- at the bottom the is the "sort" area. Select random that should do the trick

M.J. Taylor’s picture

Thank you mkalbere,

Works like a champ, except...

It doesn't update the total and day counts for the node it displays. I've been asking how to identify the displayed node ID over in this thread, http://drupal.org/node/160664 , so I can then manually update the counts in the footer.

Any thoughts?,

MJ

mkalbere’s picture

usualy $node is defined if not

arg(...) give you the url . Even if you use the url alias those fcts will return the "internal" path.
So for a node :

if (arg(0)=="node" && is_numeric(arg(1)){
$nid=arg(1); // is the node number
$node=node_load($nid); //load the node info (body, cck fields etc ))
}

For teaser list it would probably be a bit more diffcult. You could redifine the display by using contemplate module, and then inside teaser display update the counter you need ...

M.J. Taylor’s picture

Hi Mkalbere,

Views, seemingly being a function, doesn't follow $node or arg() conventions from inside itself (e.g. using PHP in a View's Footer).

With help from you, coreyp_1, and dvessel I managed to work this out and write up a Handbook page:

HowTo: Create a Random, Single, Full Node on Your Home Page (4.7.x/5.x)

While I'm unsatisfied with the implementation, it does work.

I also added a feature request for Views to do the counter incrementing so my kludge can be discarded.

Thanks very much for your help,
MJ