Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By s_andy on
I have a Search page created using the embedded filters and views. The page is working perfectly. Part of the results look like below:
The number showing on the top is the program ID. Upon clicking the 'Learn more' button, I want to redirect to the page which shows the details of the selected program. Not sure of which way i should start with the process. I need to design a Dynamic template and when clinking the 'Learn more' button of a specific program I should fill the template with data. Is there a way to do this? Any suggestion on where to start?! Thanks!
Comments
You can create the second
You can create the second view and set its url path like: /details.
This view will be display the detailed infor.
Add to this view the contextual filter, for filtering by program ID field.
Then in your first view rewrite the result of some field with the link like this: /details?program_id={{ 'field_program_id' }}
Additional blocks in that detailed page
Thanks! If I want to add additional blocks like 'Google maps' to the details page can I still use the same route? Also any best link to learn about contextual filters? Haven't used that before and I am unable to find an example similar to my needs.
I think that you can.
I think that you can.
You'll find many tutorials, for instance, this one:
'Drupal 8 Site Building, Lesson 29: Contextual Filters'.
Also...
Thanks a lot! Also the contextual filter should be added on 'Details' view right?
Will try this right away and post if I'm seeing any challenges.
Tried this one...
I tried this method. attaching the details view with contextual filter config here. Also attaching the code I have added to my primary view.
I am still not able to see the result of a specific program. It is showing me all the program names. Any help?!
Detail view screenshot: https://imgur.com/a/Z1kTsKa
Contextual filter screenshot: https://imgur.com/a/TJhv1cg
Results: https://imgur.com/a/kK3y1hF
My URL is: /details?program_id=field_program_id it's not taking in the field_program_id value :(
"Learn more" button code: <a class="button js-form-submit form-submit btn-info btn" type="button" value="LEARN MORE" href=/details?program_id={{ 'field_program_id' }}>LEARN MORE</a>
Also in the link what is program_id field? is it the contextual filter field name?
1. You need to configure the
1. You need to configure the contextual filter properly, see the screenshot: https://cdn1.imggmi.com/uploads/2020/1/24/6f7e39f1ba522fdc721a43224660a8...
2. 'program_id' is just a name of the query parameter (you are free to use another name).
Another way is to create the
Another way is to create the link like this:
and configure the contextual filter like on this screenshot:
https://cdn1.imggmi.com/uploads/2020/1/24/af025899afff3ae8bebd72101faeac...