Closed (fixed)
Project:
References
Version:
7.x-2.x-dev
Component:
Code: node_reference
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
8 Mar 2011 at 19:40 UTC
Updated:
26 Jan 2012 at 00:28 UTC
Jump to comment: Most recent file
Comments
Comment #1
nuezIn the end i solved the issue by creating a specific field template for my Reference field, called 'field--field_name.tpl.php'. I put the file in my theme folder, and edited the file: instead of rendering $item, i printed $item['#href'], being able to use that value directly into a hyperlink.
Comment #2
dalai commentedHello Nuez, could you provide your code as example? Have the same issue to solve. Thanks!
Comment #3
nuez1. first you copy the field template (field.tpl.php) file from you're modules\field\theme directory.
2. you change it into a theme suggestion. If your field name is 'field_link' your file should be named 'field--field_link.tpl.php'.
3. Edit the file. The file´s output is originally:
4. You change it into:
5. You can see that instead of using the entire $item array, i just output the 'href' part of it. I got rid of all de html, because its a specific theme output, so i don´t want it. You can check for different values in the $item array using print_r or if you are using the devel module you can use the kpr function which gives you a nice and readable output. I also added the html to output the hyperlink, I don´t know if that´s the best practice in terms of preprocessing etc, but it works for me.
6. you put the theme template file in your theme directory. As of DRUPAL 7 you don´t need to put the 'parent files' anymore, just the file is enough. Reset your theme cache in order for it to be recognized.
Comment #4
henrrrik commentedI've created a patch that adds a "URL, as plain text" display formatter for both user and node references, just like the one link.module provides.
In the meantime, I've also created a simple add-on module that provides this for node references for (http://drupal.org/sandbox/henrrrik/1094596) in case anyone else needs this functionality right away.
Comment #5
Jason Dean commentedhenrrrik - You just saved me from a massive headache. The module works a treat - thanks! :)
Comment #6
Fidelix commentedI believe this is worth to be in the references module core, not in an addon module.
Comment #7
bsztreha commentedHi,
i have another patch for this solution, with settings page, where you can more options for the generated plain url.
Two formatters:
Node ID: return the referenced nid
URL as plain text: return the URL (settings: Alias TRUE/FALSE, Absolute TRUE/FALSE)
Comment #8
bsztreha commentedSorry, new patch without dpm :)
Comment #9
yched commentedI made a few edits, and added similar formatters on the user_ref side.
Committed the attached patch.
Thanks !
Comment #11
wxman commentedRemoved by me. Created a new issue.