I have following requirements :

Add and List of Book Add and List of Quiz related to book.

I have created content type for Book with field name : book_id,book_name,price etc..,here book_id will be unique in every time.

Also created content type for quiz with field name : quiz_name,my_book_id etc..

Now in view of quiz i have to show field quiz_name with book_name. How can it will be possible to map this field?

I refered too much like entity reference, node reference module etc but didnt get any solution.


My solutions is

1. In your Quiz content type remove book_id field , add another field with (each name you want here I named it my_book_id ) select type node reference for it.

then in views, create a views of content type quiz, create a relation on my_book_id then you can add book title .

2. Another way is using php views field create a views with content type quiz, select quiz desire field, then add my_book_id field ,exlude it from dispaly then create php field , in value use something like this

 $node=node_load($data->mybookid); // this is not precise way, you should put nid in node_load(nid);
 print $node->title;
|improve this answer|||||
  • Thanks 4 help. I added node reference type for my_book_id so its give me option like autosuggest, checkbox etc. I wants when quiz insert only user add my_book_id not added/choose book_title. so we have to try any another approach to find out solution? – Chirag Shah Sep 14 '14 at 19:53
  • 1
    @Chirag what is my_book_id ? node id of book contents? – Yusef Sep 14 '14 at 20:02
  • 1
    @Chirag do you have custom module in your project? – Yusef Sep 14 '14 at 20:12
  • my_book_id is field of quiz content type. and in view i want to get book name which book_id is same as my_book_id. I didnt use any custom module in my project. – Chirag Shah Sep 15 '14 at 5:15
  • In shot in core PHP we are using query like this : "select a.quiz_name,b.book_name from quiz as a,book as b where a.my_book_id=b.book_id" but in drupal view how can I fetch this? – Chirag Shah Sep 15 '14 at 5:18

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.