Hello all,

I am new to Drupal, and dove right in, and have been playing with it intensely for about 3 weeks now. I think I'm getting the hang of it, but after days of toil, I think
I just simply need help on this one. The view I'm trying to create is kind of like this: http://www.wowwiki.com/Level_19_rogue_twinking_guide

I have created 4 content types for a hobby gaming site. The purpose of this site is to recommend the best weapons and items for a particular class (ie: rogue, mage, warrior etc) and level bracket (ie: 10-19, 20-29, 30-39 etc) group listed by slot (ie: head, feet, hands etc).

My content types are set up as follows:

Class: with one field: Class Name (text)

Brackets: with one field: Bracket Level (text)

Slot: with one field: Slot Name (text)

Item: with 6 fields: Item Name (multi-text), Item Slot (node reference - select box), Item Location (multi-text), Item Classes (node reference - checkboxes), Item Brackets (node reference - checkboxes), Item Comments (body).

How do I create a view that will list all of the items that are only in certain classes and brackets of that class, grouped by the item slot.

Example like this:

Rogue Items for 10-19:

Head:
-Lucky Fishing hat, located in fishing contest in StranglehornVale
-Green tinted goggles, located from engineering 150

Feet:
-Footpads of the fang, located in wailing caverns, dropped by lord cobrahn
-Feet of the Lynx, located on a world drop..

so in other words:

[class name] for [bracket levels]

[slot name]:
-[item name], [item location]
-[item name], [item location]

[slot name]:
-[item name], [item location]
-[item name], [item location]

etc.

I'm sorry this post is so long, and I hope it is clear. Please let me know if this is not the appropriate place to post this.

Thanks for any help.

Comments

ludo1960’s picture

...Creating separate views, then create a PHP page and use:


<?php
$view = views_get_view('viewname1');
print $view->execute_display('default', $args);
?>

<?php
$view = views_get_view('viewname2');
print $view->execute_display('default', $args);
?>

<?php
$view = views_get_view('viewname3');
print $view->execute_display('default', $args);
?>

jive01’s picture

Thanks for the help ludo,

Can this not be resolved by using settings within the views module?

ludo1960’s picture

..100% sure you can do this using just the settings.

jive01’s picture

I can or can't? If so, what views settings do I use?

jive01’s picture

I guess my question is what view settings do I use to be able to view only items that are within a specific class and bracket...

mtsanford’s picture

I think you can do this using relationships. First use a *filter* to select for your item node type.

then add 3 relationships, 1 for each of your node references, all using "Do not use a relationship" in the relationship selector so they link to the base table.

Then you can use arguments for class and bracket. The class arguments will use the Content: Class Name text field, and use the "class" relationship you created above. Similar for the bracket argument, though the argument will filter on Content : Bracket Level field, and use the "bracket" relationship. "require this relationship" should probably be checked too.

If you then set up a page display with path set to yoursite/bestitems/%/%, you should get what you want... e.g: yoursite/bestitems/Rogue/10-19 would show the result of the query.

I'm not sure about the grouping as I have not used that much.

mtsanford’s picture

You may want to rethink your data types.

Do you really need to have a node type for each of these things? Why not just use taxonomy terms for class, bracket, and slot, allowing multiple terms for each?

jive01’s picture

But I guess my Noobness in Drupal made me hesitate. In other words my lack of education in taxonomies, holds me back. I might install a fresh drupal install and try this out. And I would use the classes (rogue, mage etc) as primary navigation items, and brackets (10-19, 20-29 etc) as secondary navigation items, and there was no clear way to make taxonomies, navigation items.... and I am still wrestling with views.

I did however figure out somewhat the views. Here are the view settings:

My Filters are set:
Node: published
Content: Item Brackets (field_item_brackets) is one of 10-19
Content: Item Classes (field_item_classes) is one of Rogue

Fields:
Content: Item Name (field_item_name) - custom label: Rogue 10-19th Bracket
Content: Item Location (field_item_location)
Content: Item Slot (field_item_slot)

It tried to get it to sort by item slot name, however, doesn't seem to want to do that using:

Sort Criteria:
content: Slot Name ...

Why wouldn't the sort work.

mtsanford’s picture

"and there was no clear way to make taxonomies, navigation items.... and I am still wrestling with views. "

Your view should be MUCH MUCH simpler using taxonomies. You can see for yourself how complex the view I came with was with your node references, and I'm not even sure that view would work.

I really think you should figure out taxonomies, and then can make a page display taking arguments for class & bracket, and you can then add menu items for each of the combinations, eg rogue/1-9, rogue/10-19, etc.

jive01’s picture

I installed a fresh copy of drupal on my server, and am going to give it a shot with taxonomies. I'll let you know how it works out. ;).

At the very least, at least I learned something from the last attempt. :-0

jive01’s picture

Ok, I did it, and you are right, it was easier to set up taxonomies to emcompass:

Vocab: Class; Terms: Roge, Mage, Hunter etc..
Vocab: Bracket; Terms: 10-19, 20-29, 30-39 etc...
Vocab: Slot; Terms: Hands, Feet, Head etc...

My content type is Items:
Item Name (field_item_name) text
Taxonomy (which has all the vocabs and terms as select boxes)
Item Location (field_item_location) text
Item Comments - Node module form (body)

I got the view that I needed with very similar settings as when I used these as content types using the following settings in views:

Relationships: none
Arguments: none

Fields:
Content: Item Name (field_item_name)
Content: Item Location (field_item_location)
Node: Body (labeled Item Comments)

Filters:
Taxonomy: Term = Mage
Taxonomy: Term = 10-19

Sort criteria:
Taxonomy Term Asc

This displays it and filters out all (for example) Mage items at the 10-19 bracket. What I don't understand is

1. How do I sort the results based on the Slot terms (head items grouped, Feet items grouped etc)

2. How do I place the term names in the headings? For example:

Mage 10-19 Bracket Items

Back

  • Sentinal Cloak - bought from the auction house - comments: a great item
  • caretakers cape - Tailoring (150) - comments: Find a tailor

Head

  • Lucky Fishing Cap - Fishing Contest from Stranglehorn Comments: rare item
  • .....
  • .....
  • .....

Again thanks for your help.

jive01’s picture

Figured out to create the term name in the headings, but it appears that I am unable to sort by taxonomy term. Is sorting by taxonomy term not possible in views?

jive01’s picture

Ok, I figured out my view, and learned that it's not possible to sort by taxonomy!! Wow, i can't believe that this was overlooked. The best way for me to sort by slot type, was by keeping the slot a content type and not a taxonomy....

From there, it was pretty easy:

My Filters are set:
Node: published
Content: Item Brackets (field_item_brackets) is one of 10-19
Content: Item Classes (field_item_classes) is one of Rogue

Fields:
Content: Item Name (field_item_name) - custom label: Rogue 10-19th Bracket
Content: Item Location (field_item_location)
Content: Item Slot Node: type
Content: Slot Name (field_item_slot_name)

Relationship: Content:
Item Slot (field_item_slot) require this relationship checked

Sort criteria:
Slot Name (field_item_slot_name)
Relationship: Item Slot
Descending (or ascending depending on how you want to sort)

This worked like a charm...

hexblot’s picture

I really cannot believe someone didn't recommend some very nice properties of views, and since I stumbled upon this post looking for something else, I'll try to demonstrate how I would do the above :

* create one content type, named item, with the default fields ( rename title to name and body to comments ), no extra fields needed
* create taxonomies for class, slot, bracket and location. Class / slot / bracket should be single/multi select, location should be free tag ( that way you get autocomplete when adding locations, or a nice dropdown -- in any case, you avoid duplicates )

You need only ONE view to accomplish all of the above :
Filter:
Node,Published->Yes,
Node,Type->Item

Sort:
None or postdate descending, doesn't really matter ( see below )

Fields:
Taxonomy,All Terms-> exclude from display, limit terms by vocabulary ( select the vocab for slots )
Node,Title-> style as needed
Node,Body-> style as needed

Basic Settings:
Style: HTML List-> Select Taxonomy,AllTerms as your grouping field

Arguments:
Taxonomy:Term, Action to take if argument is not present: Display Empty Text, Validator: Taxonomy Term->Check class vocab, Argument Type: Term name of synonym

Taxonomy:Term, same as above but select bracket vocab. Also add a title here -- using placeholders, e.g. "Items for a %1 in the %2 bracket"

Create a page display at some path, eg items

When you navigate to items/mage/10-19 you should get all the items suitable for a mage, in the 10-19 bracket, grouped by slot. If you used the above title, you should also see "Items for a mage in the 10-19 bracket" as a title.

Hope this helps someone :)

It's nice to be important,
but it's more important to be nice.