I need to set up a contextual filter that will pass the information from a single row of a view into a new view that only shows that one row, using maybe a link that opens it into a new page or a PDF.

enter image description here When a user clicks "Print" I would like the resulting page to just show the information from that one line...


I have a view that lists a row of things in a table. It's data imported into MySQL that's not associated with a node. I need to build a view page certificate to use instead of Certificate.

The data is quiz scores and the fields are QID, Date, Course, Score and Print Certificate. The "Print Certificate" column is a Global: Math Expression field that basically compares the score (score) with the global passing score variable (pass_rate) and prints a link if the expression is not zero, otherwise the field is left blank. The expression I am using to accomplish this is: abs(([score]+1)-[pass_rate])+(([score]+1)-[pass_rate]).

Course is a custom content type that is connected to the quiz that was taken. The quiz also links to the course so that it comes up in this view and Quiz is using the Quiz module.

What I've Tried

I created another view as a page that is similar to the view that shows all the scores, except I limited it to one item, excluding all fields from showing and I arranged it as an unordered list instead of a table. Using Global Text field which is not excluded, add back all the other fields using replacement patterns in order to control how the data is rendered so that it reads more like a certificate about one specific quiz score or QID. What needs to be done in order that the information displayed on this view page is the same as the row that linked to it, or just one QID?


So why not just use certificate? Biggest issues are that there is no token for when the certificate was earned or when the quiz was passed. See my SE post. The other reason is because the quiz scores were imported as values from another site. See my other SE post on this.

Ideas Can I use a contextual filter in the parent view with some php using the fetchfield() function such as something like:

db_query_range('SELECT 1 FROM {quiz_node_results} WHERE qid = :qid', 0, 1, array(':qid' => $[something]->qid))->fetchField();

2 Answers 2


With much help from an answer in this post I was able to solve my issue. Here are the steps in case it is helpful to anyone else:

  • create a view (in my case, to show information from the quiz_node_results table, using quiz result ID or result_id)
  • create a PDF view containing the same fields as in the first view; use the views PDF module
  • in the first view, add a Global PHP field (use the Views PHP module) and add some PHP to print a link to the data in the row of the table from the PDF view if the score is at least the score threshold (pass_rate) for getting a certificate:

<?php if ($row->score>=$row->pass_rate) { print l('Print','/data/'.$row->result_id); } ?>

  • in the PDF view, make sure the URL to the view is /data/% and add a contextual link; in my case, for the quiz result ID, set to show all if validation is provided and to show basic validation to show all if not provided

Except of rewriting the result from 'Notes' to 'View Notes' there is the option to make this field a link. The other option is to add a 'Global: Text Area' element and set there the link of your view and also you can pass parameters. In you second view (Book Notes) you can use contextual filers to fetch which book you want to display.

If you want to add extra details except of the view, I would suggest to use panel page where you can place your view as a block (and you can pass parameters through URL) and also add whatever else you want.

  • 1
    No, you can link it to a node and then add your view as a block again. Actually you can link it even to your view page. I don't know what extra details you want to display but I think you could still use blocks to your view page for this purpose. As long as you create the link you can link it wherever you want.
    – Ismini
    Aug 22, 2017 at 13:37
  • 1
    Then you could create another page in the same view (in order to get the same results), add contextual filters which will be applied only for the specific page (in order to get the results for your row - there is the option to overwrite for the specific page/block/whatever) and add extra fields or blocks to this view page. And in your first view alter the link to send the parameters you want.
    – Ismini
    Aug 23, 2017 at 9:51
  • what how? how to add block in a view page? If so check this -> drupal.stackexchange.com/questions/50183/… or you can create a custom template where you will add your regions.
    – Ismini
    Aug 23, 2017 at 14:10
  • I'll reword my question to explain better.
    – Christia
    Aug 23, 2017 at 16:13
  • Which contextual filter and how do I link them? That's what I need to know. Thank you for your help.
    – Christia
    Aug 28, 2017 at 16:40

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.