Accessing View's field's content?

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
jessSchn's picture

I have a Press Release content type setup. And now I'm working on creating a view to easily list out all press releases in one spot with the Title (linked to the article) and a Teaser. Here is the tricky part:

The Press Release content type has a field called press_type. Allowed values are "Internal" or "External" (required field).

If Internal is selected I want the title on the views page linked to the corresponding node/article.

If External is selected I want the title on the views page linked to the field "press_url". Which will take you off my drupal site and will land you on someother webpage.

To accomplish this I'm thinking I need to customize my Views page with "views-view-fields--Press-Release" and I need to check the "press_type" to know how to handle the "title" link. I have the logic written out:

if (press_type == "External"){
if (isset(press_url){
  title href = press_url
}else{
  not sure what to do if the press_url isn't filled in - this isn't a required field because internal press releases don't need it.  I'll figure this out later.
}
}else{
  title links to node
}

Here is where I'm stuck:
I can print the content (

<?php
print $field->content;
?>
) in the views template file, but I'm not sure how to get into that content to check the value of press_type.

Why am I trying to do it this way? Because I'm going to have other people entering in the press release information and it would be easiest to have all the information they need to enter in one spot instead of using two different content types.

Please let me know of any suggestions and how to get to the press_type level.

Comments

Drupal Drop In!

Allie Micka's picture

Hi Jess,

Hopefully you're here at the DrupaCamp. In addition to all the great sessions today and tomorrow, there's a Drop-in room where you can get support from the community and give some too.

Hope to see you there!

Out of Town

jessSchn's picture

Allie,

I would LOVE to be at Drupal Camp this year, but I had already signed up for a Half Marathon race that is out of town this weekend. Maybe next year.