0

I dislike the fact that the Node Title is not truly a field because it prevents me from being able to control its display order, etc., like I can with all of the other fields. I tried using the exclude_node_title module which did as it claimed and I added a new field called Post Title of type Text.

How can I make that new custom title field into a link to the Content?

  • I take you mean you cannot control where the title is displayed when showing the node, not where editing it. – kiamlaluno Nov 11 '12 at 0:40
  • That is correct. – Kenny Wyland Nov 11 '12 at 1:00
1

If you are a Drupal module developer, the easiest way to do this would be to define a custom field formatter that would specifically do this (i.e. linking field value to the URL of the node) for the text field and content type that you want.

If you are looking for a UI solution, I'd suggest installing the custom_formatters module. Once you have done that, import the formatter below.

$formatter = new stdClass();
$formatter->disabled = FALSE; /* Edit this to true to make a default formatter disabled initially */
$formatter->api_version = 2;
$formatter->name = 'string_to_link';
$formatter->label = 'string_to_link';
$formatter->description = 'Converts string from a text field attached to a node to a link';
$formatter->mode = 'token';
$formatter->field_types = 'text';
$formatter->code = '<a href="[node:url]">[node:title]</a>';
$formatter->fapi = '';

Now, go to the "Manage Display" page of the content type where you have your Node title field, and set the formatter to *Custom: (string_to_link)*. The value of the field is immaterial now. It'll be linked to the node always.

However, linking to the node from the node view itself is not really of much use, right? So, I'm guessing you'd want this in a node listing. (A set of nodes). In that case, you might want to use the Views module where you can explicitly link the node title to its URL for a view.

| improve this answer | |

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.