I understand that by default the node titles link to internal drupal paths. But here's the setup I am looking for: I have Views 2 module (what a magnificent and mighty useful bit of code :o)). I'd like to create a node type (I have CCK), I'd like to produce a web page and on that web page, I'd like to have Title and Description of an external resource. When a visitor clicks on the title, it should take him/her to the URL referenced by the Title link and not to an internal Drupal path. Sounds simple enough, but how do I implement this type of a submission form at the Admin end?

Any ideas would be splendid!

Thanks,
Kenneth

Comments

drupalem’s picture

Anyone willing to help this curious soul?!

bdillahu’s picture

Not quite what you are looking for, but close... depending on your CSS it might be workable for you. It ads a weblink content type that has a field for the URL which is displayed prominently.

realityloop’s picture

I'd like to do something similar to this, where the view outputs a list of nodes of a particular term, so that I can list on site nodes, and external links.

The issue for me is getting the title to link directly to the external site..

Kenneth I believe you could to it by customising the teaser display so that the link is to URL field assuming you are using CCK to store the site's URL.

glass.dimly’s picture

Hey all,

I'm also interested in this. Realityloop, what you says will work, but is a pain.

Anybody know how to do this?

I've been looking at Link for CCK http://drupal.org/project/link but it obviously wont link-ify the title.

-glass.dimly

somerandomnerd’s picture

Hi- I'm trying to do the same thing; inspired by John Gruber's Daring Fireball site (http://daringfireball.net)- I like the idea of a post that is all about drawing attention to another page on another site rather than my own content.

My guess is that it will involve something in the Theme section to make it work, but I'm still feeling my way around Drupal's workings, so any advice would be appreciated...

somerandomnerd’s picture

OK, I've got it working.

First, install the CCK module and activate it (only the basic text content field is needed.)

Second, create a new Content type, and add a new text field. Call it "URL".

Finally, open up your node.tpl.php file in your active template, and find the part that generates the title. For my theme, it looked like this;

  <h2 class="title"><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>

That should make sense; what we want to do is intercept that chunk of code, so that if there's a "URL" field with come content in it, then we use that as the target URL.

The CCK handbook had all the info I needed to figure out the variable names, so my code now looks like this;

  <h2 class="title"><a href="
<?php if (content_format('field_url', $field_url[0])) print content_format('field_url', $field_url[0]); else print $node_url; ?>">
<?php print $title; ?>
</a></h2>

And my content that's on the front page now links to the external URL instead of an internal one.

Obviously, that's the only place the link will appear- RSS feeds and any other links will still be the default internal link, but it's a first step...

mes5464’s picture

somerandomnerd,

I liked this post and found it very helpful. But it triggered a memory of something I read elsewhere and I finally found it.

If you create a custom type, you can then go to your theme and create a node-[cutomtype].tpl.php for that type. I just copied the node.tpl.php and named it as node-newslink.tpl.php. Then you don't have to change the original and you don't need the if statement to test for the existence of the $field_url field. Additionally, I added the target attribute to the link tag so that my links open in a different window.

Again, thank you for this solution. It is elegant!

yamenshahin’s picture

Is there any way to make this code for Drupal 7

johnhanley’s picture

I recently was looking for the same functionality and CCK Redirection fits the bill nicely.

bunset’s picture

I want to do it in my front page only to feedapi nodes, I have them saved in a specific content-type, so I can clone node.tpl.php to have a page template where customize.

As you can know feedapi imported nodes has in every node a link called "original article", that is the link destination I want to use when the users click in the title of node in front page.

How can I do this guys?

theorichel’s picture

This did really the trick., I can link to whatever now in my titles. Just for clarification: the field_url as in the example above was in my situation field_url_0 so the adaptation had to be changed accordingly. Typically something for idiots like me, but I may not be the only one.

Thanks!

akadimi’s picture

Hi bunset, have you managed to do something with CCK Redirect and Feedapi modules