3

The Drupal 7 site i'm working with needs to have a services directory, each service needs to have a general description and a description for health professionals.

So I've created a new content type and called it service, and create 2 custom fields one for general description and one for the health description.

Now the the general services will create their own menu items (this part is fine), the healthcare ones will need to be available in a sortable list as pictured below

http://i.imgur.com/gPf19.png

Now here's the tricky part.

(I know I could just create 2 content types, one of general and one for healthcare but i'd like to reduce the double handling and maintenance as much as possible - so if there is a way to have all the data entered in one content type that would be ideal)

Using display suite I can hide one of the fields, and using views I can create the directory listings but the directory listings created by views all just link back to the node.

So far I haven't been able to figure out a way to manipulate which fields are displayed (or even switch between display suite views) based on where the user is in the site. This could be context, a link, or block on a page, i'm open to anything at this point.

Hopefully this is starting to make sense:

Services Content Type (takes all the data, field 1& field 2)

Viewing Content through general services (/services/service-name/service-item)

Display field 1

Viewing Content through health care (/services/health-care-professionals/service-item)

Hide Field 1

Display Field 2

I was hoping you could give me some pointers, I've looked into using the context module, rules module, even had a thought about having 2 content types and using rules to copy the data from

Content Type 1 Field 2, to Content Type 2 Field 2 upon saving..

3

I was able to do this using Display Suite Extras, I found this tutorial very useful.

Display Suite Extras has a switch view mode by URL option, if you add ?v=view_name to the end of the url it will render that view. So I created the needed view types and used views to rewrite the URL of the titles to include the url parameter.

| improve this answer | |
3

Better yet I was able to figure it out entirely using views.

First I created a page with a glossary type view, but most importantly some linked titles. I altered the link path, look under the Rewrite Results tab, and click 'output this field as a link'

Now you'll be able to set link paths, tokens are available for use as well BUT you have to add them as a field in views first (and they must be placed above the linked title field)

I ended up using this path: health-professionals/[field_servicetype]/[title]

You'll also want to check 'replace spaces with dashes' to make the url friendly.

(also on a side note if you are using url aliases you'll need to go to the configuration and remove the words from the strip filter (eg, for, a, and, the) - because views has no option to do this, and your url needs to match with the actual alias. So remove those, and delete all the aliases and regenerate)

So now we have the altered linked titles setup. Now create another page, but this time look under Format > Show: and select rendered entity.

Now here's the good part, in rendered entity settings you can select 'view mode' which for me was one of the previously created modes I'd setup in display suite earlier, but you'll still be able to select from 'Full Mode','Teaser', etc.

Page Settings > Path: Needs to be the url and token, so mine was /health-professionals/%

Pager settings : Needs to be set to 'display a specified number of items' and set the number to 1 - so in essence what we're creating is an alternate way of viewing the actual node content through views.

Now the hard part

Contextual filters > add one for Content:Title

When filter value is NOT in the url - whatever, I've just left it as 'page not found' but when testing it can be a bit annoying so display all results is fine too.

When filter value IS in the URL: Override title: %1 (or %2, %3, etc depending how many filters you have an what they are)

Apply that, and now if you look down to the 'preview with contextual filters' form go ahead and input a node title, so if you have a node called 'services' you'd put services in. If it's setup right you should get the node content for that page and nothing else.

Better still you'll also have a way to link to it, and a linked index (previous page created)

this absolutely did my head in... but good result in the end :)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.