Tuesday 15 April 2014

php - Rendering only the URL from a Drupal 7 custom field -


Only the URL for custom fields in custom (no title, Div markup, etc.) is giving me the hard time Node display of node - My_Content_Type_Node.tpl.php . I am trying to go on the underlined path, but having a difficult time. My special area is:

My custom field is a categorized word reference for the forum, with the machine name of taxonomy_forums I try to use I am doing the following (with subtle variations), without success:

  $ url = render ($ node- & gt; taxonomy_forms [$ node-> language] [0] ['Url']);   

Basically, I am trying to tie the material on a specific spokesman forum for comment, and I am making a link for it.

I use the default layout (link, title, markup), but no luck is separating it:

  $ forum = render ($ content [ Taxonomiephor ']);   

Any help is greatly appreciated, and this is my first post, so please let me know if more information is needed.

Thank you!

Update: To retrieve the following for var dumps:

Array (1) {["und"] = & gt; Array (1) {[0] = & gt; Array (2) {["tid"] = & gt; String (1) "5" ["taxonomy_term"] = & gt; Object (stud class) # 81 (8) {["tid"] = & gt; String (1) "5" ["vid"] = & gt; String (1) "2" ["name"] = & gt; String (13) "Total Prize" ["Description"] = & gt; String (167) "Use this location to ask questions, comment or start a conversation with the Rural Foundation and use other site users to evaluate their total award processes." ["Format"] = & gt; NULL ["Weight"] = & gt; String (1) "4" ["vocabulary_machine_name"] = & gt; String (6) "Forum" ["rdf_mapping"] = & gt; Array (5) {["rdftype"] = & gt; Array (2) {[0] = & gt; String (14) "CoC: Container" [1] = & gt; String (10) "sioc: Forums"} ["name"] = & gt; Array (1) {["forecast"] = & gt; Array (2) {[0] = & gt; String (10) "rdfs: label" [1] = & gt; String (14) "Skoze: prefelabel"}} ["Description"] = & gt; Array (1) {["forecast"] = & gt; Array (1) {[0] = & gt; String (15) "Skoze: Definition"}} ["vid"] = & gt; Array (2) {["forecast"] = & gt; Array (1) {[0] = & gt; String (13) "Sko:: InSem"} ["Type"] = & gt; String (3) "rel"} ["guardian"] = & gt; Array (2) {["forecast"] = & gt; Array (1) {[0] = & gt; String (12) "Sko: elaborate"} ["type"] = & gt; String (3) "rel"}}}}}}}

only one URL You can check this function. If you need an absolute or relative URL, you can specify So if you need the full URL then the code can look like this:

  $ url = url ($ node-> Taxonomie Force [$ node-> language] [0] ] ['URL'], array ('absolute' => TRUE);   

And you have to make sure that $ node-> taxonomy_forums [$ node- & gt; Language] [0] ['url'] is the proper array of structure You can see it through the development function dsm ($ node- & tax; taxonomy_forums) Just make sure the develop module is installed.

No comments:

Post a Comment