Hi, I've just started to use drupal about 2 weeks ago (and PHP) and am getting up to speed, but I feel like a hack. What I want is the ability to have the title of a node link to something other than the node. eg On the front page I'd have an anouncement and I'd like the title to link to taxonomy menu associated to the anouncement not the node of the anouncement.

Now I have come up with a way to do this but it just feels like a hack! I'm sure its been done but my searches have failed to find it :( anyhow this is what I've done.

Say I want to link the title "New reviews just posted" to the URL "Reviews" I'd use this as the title when creating content:

nodelink:Reviews New reviews just posted

Then in the template.php (I'm using phpTemplate) file in the phptemplate_node() function, I'd parse the title for the key word nodelink: and reassign title and url in a similar way to the standalone bit of test code below.

There must be a more elegant solution out there! Any pointers
(maybe this is a theme Q , but it seemed more suited to here)

Note:this is just stand alone proof of concept stuff, not what I've added to template.php!

<?php

$str = "nodelink:Review This is a title";
$str2 = "nodelink: http://drupal.org This is a title";
$str3 = "this is only a title"; 

$teststr=$str1;

if (strstr($teststr,"nodelink:")){
  $pos1=strpos($teststr,":");
  $pos2=strpos($teststr," ");
  $url=substr($teststr,$pos1+1,$pos2-$pos1-1);
  if ($url == "") {
    $pos3=strpos($teststr," ",$pos1+2);
    $url=substr($teststr,$pos2+1,$pos3-$pos2-1);
    $title=substr($teststr,$pos3+1);
  }
  else $title=substr($teststr,$pos2+1);
  
  print "title = \"".$title."\"   at url \"".$url."\"\n";
}
else print "real title: ".$teststr."\n";
?>

T-man

Comments

pieterdt’s picture

Hi,

to do what you want to do (at least if i understand your problem correctly), I should not create nodes for which the title links to something else. You are using nodes to create some navigational elements.

It is better to either use the menu for this, or put links in a page or a story.
The path alias module can come in very handy to build clean links to node lists (via the taxonomy)

I hope this makes sense to you, if not, please ask =) I will be glad to help.

T-man’s picture

Thanks for the reply, I use taxonomy, menu and path alias to to structure my site "cleanly". What I'm looking for is: Say I have a reviews section, I've used path alias and taxonomy so that the section can be found at http://myiste.com/Reviews. OK now I have posted 4 reviews but I don't want them all promoted to the front page, I just want to promote a single summary article to the front page that looks like:

New reviews posted

head over to the reviews section to see new reviews of blah blah and blah ..etc

Now if I do this and somebody clicks on the title (which is a casual users first instinct) they just get directed to the node of the article, I want them directed to my whole reviews section. Sure I could put a link in the body or navigate there by the menu but I think peoples first instinct is often to click the title, and I like to make things as simple and natural for the visitor as possible.

T-man

bjornarneson’s picture

Could you use front page module? Use it to create a custom section on your home page like:

$output .= '<h3><a href="/link-to-review-taxonomy">New Reviews Posted</a></h3>';

$output .= '<p>Head over to the reviews section to see new reviews of';

$output .= PHP code here to generate node title links to latest reviews, separated by commas

$output .= 'end of sentence.</p>';

With this module, your front page could summarize your site's recent activity without using a node as a summary article, as you mentioned above.

--
Bjorn | choirgeek.com

T-man’s picture

Thats a good idea, but probably not quite the overall functionality what we had in mind. We'd like to use it for many sections eg. new stuff to buy, check out blah, so they won't always be on the front page, they will scroll of with other articles.

venkat-rk’s picture

Please take a look at the excerpt module:
http://drupal.org/project/excerpt

Edit: If you head to the Civicspace site (www.civicspacelabs.org), you can also find the headlines modules, which may do what you want.