Link to

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

Requisite - I am trying to create a news block that pulls content from the site and also points to urls outside the site. I am able to make either one work but not both.

The usual way - When you create a view and list only title and desc ; clicking the title takes you to the node (news page)

However when I use Rewrite results and use the replacement patterns option (this only works when I uncheck the "Link this field to the original piece of content " option.) , it works only if they are urls present. Is there any way to suggest the title to point to the node? I can also set something as default when creating the content type.

Is there any way to make links work as follows - to check if there is any url present (I have mine stored in filed_news_link). If yes then point the title to the external link. If not make it work the usual way - point the title to the node.

Any help or direction is very appreciated.

Thanks!

Comments

This is probably outside the

michaelfavia's picture

This is probably outside the scope of the views UI as it is a reasonably complex operation youre doing here.

I normally implement this in the views views-view-fields--VIEW-NAME.tpl.php file. It works just like any other template file. I fyou just drop ina file containing the code youll fiund by clicking on "Theme: Information" in your view edit screen you can probably figure out the rest if you know a little php. The views row and output are all available for you there.

There might also be a "php field" style solution if you are deadset on encapsulating it in a view object.