I'm writing a simple module specifically for a site I am making, but I suspect I am not doing things the correct way because I keep getting the feeling I am working against Drupal - not with it. If someone has a few minutes could they tell me what they think about my plan.

The site has a rigid skeleton with a set number of pages. Most pages have multiple areas where information from various nodes is displayed. For example, let's say the 'home' page has two nodes; node/1 and node/2. I have a hook in my module such that going to www.example.com/home will display the body of node/1 and node/2 via my theme (by basically turning $content into an array of node bodies via node_load). By adding more hooks I can add more pages that behave like this - which I was pretty proud of considering this is my first Drupal site.

The problem is that I need to schedule the publishing and unpublishing of nodes since the content on each page must change constantly and automatically. Using the 'scheduler' module I am only able to publish and unpublish, but to work with my module it seems I'd want something that actually will update node/1 with the body of node/X then delete node/X (or perhaps switch them so I still have a record of the previous node). Clearly this goes against Drupal, so my second idea was to just schedule the node to a particular alias and do my node_load by first figuring out the node number of what is currently aliased to 'home1' and 'home2' for example.

Even with that alias idea, I noticed the scheduler module still won't work for me. How does one typically accomplish what I am trying to do? It seems like a base feature of Drupal - to be able to swap nodes with ease.

Thanks for any responses, and sorry for the long post!
Tyler

Comments

nevets’s picture

How about using the views module and node queue module. The node queue module will let you make arbitrary lists of nodes in the order you want. You then could have one queue for each page on your site. So now when you create content you could a) add it to the appropriate queue, b) schedule when it should be published and/or unpublished. Then create on view per page/queue and filter to only show published nodes.

auxone’s picture

I will now research that. Since posting I've found that perhaps another solution is to use Taximony and categorize my node/1 and node/2 as 'home'. Then presumably, in my module, I could load all the nodes from category 'home' and display the two that are published. Using this method it seems like the scheduler module can work for me as-is since it can control which nodes would be published or not.

Does this sound like a valid solution? My next question would be.. how do I load only published nodes from a specific category in my module?

Thanks again,
Tyler

nevets’s picture

I am pretty sure if you use taxonomy and the paths taxonomy/term/{tid} where {tid} is a term id only published nodes are show. You can use views to override the path if you need to tailor the output more (no need for a custom module).