0

I have a CCK field that is a Entity Reference with auto complete. And in the "Manage Display" Link label to the referenced entity.

How can I add a query string to this URL?

Is there any hook avialabe? I had tried using <themename>_preprocess_field but no luck.

Current URL is : example.com/abc Need Query String : example.com/abc?cid=asdfasdf

This is my array. I didnt find ['entity'] entity in the array. Actually it is an taxonomy reference.

[field_article_tags] =&gt; Array
        (
            [und] =&gt; Array
                (
                    [0] =&gt; Array
                        (
                            [tid] =&gt; 707
                            [taxonomy_term] =&gt; stdClass Object
                                (
                                    [tid] =&gt; 707
                                    [vid] =&gt; 2
                                    [name] =&gt; free prescriptions
                                    [description] =&gt; 
                                    [format] =&gt; plain_text
                                    [weight] =&gt; 0
                                    [uuid] =&gt; d185d2a4-59e5-470d-8692-ea23348d7a63
                                    [vocabulary_machine_name] =&gt; article_tags
                                    [rdf_mapping] =&gt; Array
                                        (
                                            [rdftype] =&gt; Array
                                                (
                                                    [0] =&gt; skos:Concept
                                                )

                                            [name] =&gt; Array
                                                (
                                                    [predicates] =&gt; Array
                                                        (
                                                            [0] =&gt; rdfs:label
                                                            [1] =&gt; skos:prefLabel
                                                        )

                                                )

                                            [description] =&gt; Array
                                                (
                                                    [predicates] =&gt; Array
                                                        (
                                                            [0] =&gt; skos:definition
                                                        )

                                                )

                                            [vid] =&gt; Array
                                                (
                                                    [predicates] =&gt; Array
                                                        (
                                                            [0] =&gt; skos:inScheme
                                                        )

                                                    [type] =&gt; rel
                                                )

                                            [parent] =&gt; Array
                                                (
                                                    [predicates] =&gt; Array
                                                        (
                                                            [0] =&gt; skos:broader
                                                        )

                                                    [type] =&gt; rel
                                                )

                                        )

                                )

                        )

                    [1] =&gt; Array
                        (
                            [tid] =&gt; 2157
                            [taxonomy_term] =&gt; stdClass Object
                                (
                                    [tid] =&gt; 2157
                                    [vid] =&gt; 2
                                    [name] =&gt; prescription charge
                                    [description] =&gt; 
                                    [format] =&gt; 
                                    [weight] =&gt; 0
                                    [uuid] =&gt; 6bf69030-99b9-42e2-83dd-1f63e5a7d1d4
                                    [vocabulary_machine_name] =&gt; article_tags
                                    [rdf_mapping] =&gt; Array
                                        (
                                            [rdftype] =&gt; Array
                                                (
                                                    [0] =&gt; skos:Concept
                                                )

                                            [name] =&gt; Array
                                                (
                                                    [predicates] =&gt; Array
                                                        (
                                                            [0] =&gt; rdfs:label
                                                            [1] =&gt; skos:prefLabel
                                                        )

                                                )

                                            [description] =&gt; Array
                                                (
                                                    [predicates] =&gt; Array
                                                        (
                                                            [0] =&gt; skos:definition
                                                        )

                                                )

                                            [vid] =&gt; Array
                                                (
                                                    [predicates] =&gt; Array
                                                        (
                                                            [0] =&gt; skos:inScheme
                                                        )

                                                    [type] =&gt; rel
                                                )

                                            [parent] =&gt; Array
                                                (
                                                    [predicates] =&gt; Array
                                                        (
                                                            [0] =&gt; skos:broader
                                                        )

                                                    [type] =&gt; rel
                                                )

                                        )

                                )

                        )

                    [2] =&gt; Array
                        (
                            [tid] =&gt; 1515
                            [taxonomy_term] =&gt; stdClass Object
                                (
                                    [tid] =&gt; 1515
                                    [vid] =&gt; 2
                                    [name] =&gt; prescription charges
                                    [description] =&gt; 
                                    [format] =&gt; plain_text
                                    [weight] =&gt; 0
                                    [uuid] =&gt; 9fed77c3-42c3-421b-ba05-d62b18428702
                                    [vocabulary_machine_name] =&gt; article_tags
                                    [rdf_mapping] =&gt; Array
                                        (
                                            [rdftype] =&gt; Array
                                                (
                                                    [0] =&gt; skos:Concept
                                                )

                                            [name] =&gt; Array
                                                (
                                                    [predicates] =&gt; Array
                                                        (
                                                            [0] =&gt; rdfs:label
                                                            [1] =&gt; skos:prefLabel
                                                        )

                                                )

                                            [description] =&gt; Array
                                                (
                                                    [predicates] =&gt; Array
                                                        (
                                                            [0] =&gt; skos:definition
                                                        )

                                                )

                                            [vid] =&gt; Array
                                                (
                                                    [predicates] =&gt; Array
                                                        (
                                                            [0] =&gt; skos:inScheme
                                                        )

                                                    [type] =&gt; rel
                                                )

                                            [parent] =&gt; Array
                                                (
                                                    [predicates] =&gt; Array
                                                        (
                                                            [0] =&gt; skos:broader
                                                        )

                                                    [type] =&gt; rel
                                                )

                                        )

                                )

                        )

                )

        )
7
  • where is this link showing? if on a page -- it could be possible to add this in your content type template... or is it a view? Commented Apr 12, 2016 at 0:52
  • Its on Content type template!!
    – NTT
    Commented Apr 12, 2016 at 5:36
  • Did you get it resolved then? Commented Apr 29, 2016 at 1:30
  • Nope. I have to hack the module to get this done, though I am not happy to do so...!!!!
    – NTT
    Commented Apr 29, 2016 at 10:26
  • You shouldn't have to hack the module. Did you try my answer and it didn't work? What was the result/error? Commented Apr 29, 2016 at 11:43

1 Answer 1

0

This is one approach that might work for you, using the preprocess_page hook (see this tutorial for more background info).

In your theme's template.php, add this:

function YOURTHEMENAME_preprocess_page(&$variables) {
   if ($variables['node']->type = 'YOUR_CONTENT_TYPE') {
     debug ($variables['node'], 'Node:', TRUE);
   }
}

Then look through your node object and find your CCK field HTML which contains the link, and drill it down on the debug by adding the array/object children until you get the exact path to the link, my guess is it will be something like $variables['node']->field_YOUR_FIELD_NAME['YOUR_LANGUAGE'][0]['entity']... and the rest will depend on your entity structure.

Now replace the 'debug' line with your link path and append the value to your link, something along this:

$variables['node']->field_YOUR_FIELD_NAME->['YOUR_LANGUAGE'][0]['entity']->value = $variables['node']->field_YOUR_FIELD_NAME->['YOUR_LANGUAGE'][0]['entity']->value . YOUR_QUERY_STRING;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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