1
<?php
$href = $data->node_data_field_news_external_link_field_news_external_link_value;
if($href == ''){
    $href = 'node/' . $data->nid;
    $href = url($href, array('absolute' => TRUE));
}
echo '<h3><a href="' . $href . '">' . $data->node_title . ' (' . date("F j, Y", $data->node_created) . ')</a></h3>';
?>

I'm sorry but I've searched for something that can help me with this. I know it is simple, but I've already spent hours while trying to teach myself PHP in the process. I hope that this will take someone 30 secs and allow me to keep learning.

Anyways... I have an attribute (field_successdate) in the News content type that I'm trying to use. It's a date of when the News happened. In the view, the customPHP field uses the node's created date and appends it to the node's title to create a link to the object. I'm trying to replace the node's created date with my field_successdate. I've added it to the fields and then referencing it in the customPHP code, but no luck. Do I have to add the field_successdate to the fields in the view and then add an argument? (I've tried that too)

Can any one help?

Thanks!!!

1
  • If anyone could show me how to do this in PHP just for the sake of learning, I'd appreciate it! Jan 16 '13 at 21:54
0

It's probably easier to add the field to the field list (field_successdate). Then use Views rewrite display option to write the node: title link to include the date from field_successdate.

The rewrite will require the Token module to be enabled. rewrite the title as: [node:title] [node:field_successdate]

Be sure you hide field_successdate if you dont want it literally shown in the view by itself somewhere. You may or may not need to move field_successdate to the top of the field list so its gets made into a Token to be used in the title properly.

I'd make a pic of this .... but that'd take like minutes....

2
  • Thanks for your quick answer. This is close... I'm able to get the result I want cosmetically, but now I can't get it to link to the individual node. I've tried rewriting as a link and using a token to get to the link... but it links to the view, not the unique node... Jan 16 '13 at 21:48
  • Actually, I think I fixed it. Thanks! I didn't think of using tokens!!! Jan 16 '13 at 21:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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