0

I have been searching for the answer for so long but still none of the solution that I can finish my goal...

my content structure is as following:

  • I have Content-type that keep a list of Quotes - I named it [A]
  • I have Content-type that keep a list of Titles - I named it [B]
  • In a 'Quote', I have a field that refer to which 'Title' that it is referring.

EXAMPLE (not codes)

Quote-1 have a field referring to Title-1

Quote-2 have a field referring to Title-1

Quote-3 have a field referring to Title-2

Quote-4 have a field referring to Title-3

Quote-5 have a field referring to Title-1

(multiple Quotes can referring to the same Title)

So...I used Views(block) to display this Quotes[A] in a page and...HERE is what I want...

I want each 'Quote' to link into another page which require 2 parameters...

  1. node ID (which is already sent by default Drupal (q=...))

  2. Title ID (that is referring in a field of the Quote)

    by default, the Drupal have value of 'q' sent to another page but ...

How can I add Title ID parameter into each 'Quote' link?

2
  • What did you use to refer to 'Title within 'Quote'? Are you using Entity Reference?
    – Darvanen
    May 1 '15 at 6:33
  • Yes I use Entity Reference Eventually, I can make it as Ben's answer but there is a bug gap that the URL can be changed manually and access to a mistaken content connection. Do you have any suggestion??? May 1 '15 at 11:21
0

You could add the Title ID field to your view, exclude it from display, move it above the link, enable rewriting on the link field and write the link format you want, including the Title id.

Edit following the follow-up question: Well, in my opinion, you shouldn't have to put the Title id in the URL at all. What I wrote above solves your specific problem but, really, I think you should do things differently and thus wouldn't have this problem or the follow-up one.

Link to node/quoteid and load the Title node by looking at field_title_id (replace by the actual field name). You can do that loading in hook_preprocess_node by calling node_load($node->field_title_id[LANGUAGE_NONE][0]['nid']) from there you can either render the whole title node (node_view) or just get one field and send it to your template.

Basically, the Quote->Title relation is in the database, there's no reason you should have to express it in the form of a URL. The reverse would make sense, if you had a Title page where you want to show a single quote.

Second edit following the second follow-up question:

To display all other Quotes linked to the same title you could create a view with Title ID as a contextual filter. You can render the view manually in your template, passing it the Title ID. That'll display all quotes, including the main one displayed in that page. You probably want to filter that one out one way or another.

1
  • Thank you again Ben, appreciate your answer. However.. May 2 '15 at 2:08

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