Section Fronts: with some help from Views Arguments Extras

Posted Apr 28, 2010 // 6 comments
Erik:

Section Fronts can mean a lot of different things. But in general they are a page that aggregates stories around a topic or section. I will run through using the Views Arguments Extras module to easily implement a section front concept in drupal.

Problem

We want to have a section front that has two list, one of blog post and one of article posts. We want this list to be limited by a taxonomy term, we want to "promote" particular articles to be at the top of the section and we want control over the order of the promoted items. We also want to create new section fronts easily and quickly.

Solution

As we want to the ability to create these quickly and easily it makes sense to have section fronts as a content type, and to some how set it up so all one has to do is create a new node and they get a new section front.

If we do this we have a good place to store the taxonomy term to use as well as which story/blog nodes we want to promote, as we can use cck taxonomy to store the term and cck node references (which let us order) for the promoted blog and story nodes.




So now the hard part how do we get that information into views? While there are ways using view relationships, a new module Views Arguments Extras Module makes it a little easier.

Views Arguments Extras: Default Argument

Views Arguments Extras enables a new argument default type "CCK field Value from Current Node" (you might have used the other default type to get the currents nodes nid or maybe to insert some logic with php). This gives us direct access to the cck field that holds which taxonomy term to use and which nodes to promote.

Lets Create the view for Stories. First, we add a 'Taxonomy Term ID' argument to the view. While setting it up we use Views Arguments Extras new default argument "CCK field Value from Current Node", to pull the term id from the field_section_term cck field.




This will limit the articles to those from the correct Topic. But how do we get the promoted entries to appear at the top?

To do this, you need to combine a cck field default setting and a new sort option called "Arguments: Multi-item Argument Order" that is provided by Views Arguments Extras.

We need to pull in the values from the field_section_prom_story but we do not want it to limit the view (like most arguments do) so we create a Global: NULL argument. When setting it up we use the default argument "CCK field Value from Current Node" to pull the nids from the field_section_prom_story cck field. We set the delta setting to 'all', this will pull all of the nodes list in a comma separated list.

So now the data is available to the view, but we want these items at the top of the list and sorted. This is where Views Arguments Extras new sort: "Arguments: Multi-item Argument Order" comes in.

Views Arguments Extras Sort - Arguments: Multi-item Argument Order

Views Arguments Extras new sort: "Arguments: Multi-item Argument Order" allows us to sort our view based on the order of the nids in an argument. Because we are pointing the sort at a Global:NULL argument type, we have to say what kind of data is in the argument (in this case nids);




Now the promoted entries will appear on top with the rest of the stories below. You can do the same for the view that pulls your blog entries.

One can use panels or context, or code in the tpl file to place the views on the node page, and we have Section fronts with promotable content, the data stored in a logical way, and easy maintenance.

About Erik

When Erik Summerfield joined our software development team, we knew that his natural talents in math and economics would be an asset to our team and clients alike. Plus, his experiences in various programming languages including .NET/C#, perl, ...

more >

Read Erik's Blog

Comments

by Ajayg (not verified) on Thu, 04/29/2010 - 17:32

Why not use nodeque instead

Just wondering how this is different that using nodequeue (and associated smartqueue) module which gives the functionality outof the box?

by irakli on Thu, 04/29/2010 - 18:26

Ajayg, the main goal was to

Ajayg,

the main goal was to make it very easy and streamlined, for editors, to create section fronts. If editors have to first create nodequeue separately, then copy/paste its qid into a field on a node (since nodes don't have a way to reference nodequeues) - it does not make a streamlined workflow.

On the other hand nodes already have a way to reference ordered list of nodes through nodereferences, which is what the approach described by Erik is trying to leverage.

Hope this answers your question (and I did not mis-interpret Erik's design).

by esummerfield on Thu, 04/29/2010 - 19:52

Irakli hit it on the head.

Irakli hit it on the head. Also we looked at smartqueue around taxonomy, but we want multiple queues per taxonomy (in this example two, one for stories and one for articles, but one might want to have featured content as well or, a multimedia list, etc). The Editor would have to create node queue for each of these lists.

Also by placing it all in a node, the editor does not have to learn a new interface (as they will already be working with node edit) as well as having all of the content for this page located in a single location.

There are multiple ways of getting the end goal (trust us we might have tried them all), but this method end up being the most simple for us to maintain and for editors to use.

by Jay (not verified) on Fri, 04/30/2010 - 21:25

Wow nice module

Very interesting, I did not realize this module existed, thx!

by Jay (not verified) on Fri, 04/30/2010 - 21:41

i like

So you create a section front content type and you can grab values from that node and use them as arguments in views in various regions on the section front detail page.

i had been doing i guess the same thing with node relationships which i suppose isn't as straight forward.

i set up section fronts using panels with the same methodology - the views arguments extra modules.

i wish with node panels you could create more than 1 type. to my knowledge you only get the 'panels' node content type and so if you modify that to create a 'section front' content type you're stuck with all panels being section fronts.

by esummerfield on Mon, 05/03/2010 - 09:26

Panel Nodes for everyone

Jay,

We are working on a module to allow any content type to be a panel node. From what we have done so far it looks like it will be possible. But, we are still working through the right way to do it.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • Allowed HTML tags: <a> <strong> <code> <p> <img> <ul> <ol> <li> <h2> <h3> <h4> <b> <u> <i>
  • You may insert videos with [video:URL]

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.