Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8231015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:19:53+00:00 2026-06-07T17:19:53+00:00

I have a view that pulls in the titles from 3 different content types.

  • 0

I have a view that pulls in the titles from 3 different content types. One of these content types has a title that should link to an external website, the other 2 types have titles that link to nodes within the Drupal site. Is there a way I can set the Title field to handle links differently depending on what content type the title is from?

Answered thanks to Vlad below!! 🙂

This is the working code we are using in the views-view-fields--news--block.tpl.php template..

<?php if ($fields['type']->content == 'Event'): ?>
  <a href="<?php print $fields['path']->content; ?>"><?php print $fields['title']->content; ?></a>
<?php endif; ?>

<?php if ($fields['type']->content == 'PATF News'): ?>
  <a href="<?php print $fields['path']->content; ?>"><?php print $fields['title']->content; ?></a>
<?php endif; ?>

<?php if ($fields['type']->content == 'News Link'): ?>
//This link goes to _blank
 <a href="<?php print $fields['field_link']->content; ?>" target="_blank"><?php print $fields['title']->content; ?></a>
<?php endif; ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T17:19:55+00:00Added an answer on June 7, 2026 at 5:19 pm

    Drupal 6

    1. In your view settings, add Node: Type to Fields
    2. In Basic settings group click Theme: Information and click Row style output
    3. Copy all content from Row style output into your theme file (should be named something like views-view-fields--viewsname.tpl.php or views-view-fields--viewsname--viewsnamw.tpl.php) in your theme folder.
    4. Modify output where you should check content type and make different output.

    Drupal 7

    It’s pretty similar with difference that you can find Theme: Information in group Advanced and you have to add Content: Type in your Fields group.

    In your views-view-fields--xxx--xxx.tpl.php file write something like:

    if ($fields['type']->content == 'Page') {
      // print title linking to node
      print $fields['title']->content;
    }
    if ($fields['type']->content == 'News') {
      // print title linking to other website
      print 'http://example.com/'. $fields['title']->content;
    }
    

    Improved code

    $link = $fields['path']->content;
    $title = $fields['title']->content;
    $options = array();
    
    if ($fields['type']->content == 'News Link') {
      $link = $fields['field_link']->content;
      $options['attributes']['target'] = '_blank';
    }
    
    print l($title, $link, $options);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a View that is pretty complex. The query pulls data from about
I have created a table view that pulls its cells from an array. Each
I have a view that has a column to make it sortable. When clicking
I have a view that has a tooltip attribute. I want to set that
I have a view that could be called from any of 3 actions from
I have set up a UITableView with 3 sections that pulls from 3 NSArrays
I have a simple view and a helper that defines the title. Everything works
I have a Silverlight Windows Phone 7 app that pulls data from a public
I have a view that calls on four different partial views (.ascx) to populate
I have an activity that pulls a String Array from xml and displays a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.