0

thanks in advance for your help with this.

Firstly, the Basic Page type of my drupal build has a Title (as per usual) and a Subtitle custom field. The Title and Subtitle are then displayed in a header when viewing the node.

I then have a View which is producing a page displaying a list of Employees from the Employee content type. The Employee content type does not have the subtitle field. When the view is displayed it uses the standard page.tpl.php which will display the subtitle field if it exists.

Since the View is displaying a page, it is not bound to any specific Basic Page node so there is no subtitle to pull in to the View.

Is it possible to add the subtitle variable into this View so I can fill it with a custom piece of text and have it display on the View page.

Thanks again.

EDIT: Updated text to clear up confusion

1 Answer 1

2

There are a couple of ways to go about this, if I understand your goals correctly:
1) If your view is set up to use Fields, you can customize the Subtitle field to include additional content along with what is coming from the Node's field.
To do this, Edit the view, Select the field, Expand "Rewrite results", and then you can use a Replacement Pattern token along with your additional text:

The subtitle is [field_subtitle], yes it is!

2) If your view is set up to display as a Node, you would create a Node template override, named like node-contenttype_with_subtitle.tpl.php, and you can format your layout specifically for your need here:

echo 'The subtitle is '.$node->content['subtitle']['#value'].', yes it is!';

Note that the 2nd approach would affect the appearance of that content type everywhere, not just in the view. So, if you want this special treatment of the subtitle only in your view, then the 1st approach may be preferable.

A third option would be a field-level override template, where you would create a file named something like views-view-field--subtitle--page.tpl.php and control your output there. Here is an in-depth look at that approach: https://drupal.org/node/352970

(Please let me know if I misunderstood your question, and I'll be glad to take another stab at answering.)

2
  • Hey tsclark, thanks for the response. Sorry, I dont think my question was very clear. Ive updated it so hopefully my goal is more understandable. The pieces of content (Employees) being pulled in by the View don't have the Subtitle field as they dont get displayed individually. What Im trying to do is almost add a custom field (subtitle) to this view which I can then fill with whatever I want and have it display in the appropriate place when it renders. Sep 20, 2013 at 4:47
  • In that case, the solution is even simpler. Each View has a Header and a Footer field. You can add text to either or both of these to complement the information output dynamically by the View. If you're wanting to add text to display with each node output in the View, you can add a Field with the type Global: Custom text.
    – tsclark
    Sep 23, 2013 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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