1

I have two pages: jobs and offices.

My jobs page is an indexed view (with Search API) which displays jobs that have an entity reference field to the office it belongs to.

I want to put a link on my office page that links to the job page which only shows the jobs belonging to that particular office.

I've followed a few examples but none of them seem to work with my indexed view. Has somebody done something similar?

This is what I did: https://www.drupal.org/node/1841004 but it doesn't seem to work.

Thanks!

1 Answer 1

0

If you want to show the jobs for that particular office on your job page, you might want to use a parameter. you need to pass the nid of that office to the url.

Create a link similar to this:

  $nid = arg(1);
<?php 
    $l = l( t('More Jobs'), 'list-of-jobs',   array('query' => array('field_office' => $nid)  ));
    echo $l; 
        ?>

your entity reference field is "office" right? use that field for your contextual filter. then use Views Contextual Filter Query module to get the parameter from the URL. In my example, it's field_office.

Hope this helps!

2
  • Doesn't seem to be working for me. The machine name of my field on the job content type is field_office. I tried jobs?field_office=10 but it still doesn't filter. I added "field_office" as parameter name in contextual filter too. May 11, 2015 at 9:22
  • That's weird, because I do this kind of things on my previous website. I might have missed something. Try using a Content NID for the contextual filter then use the parameter of field_office, use a relationship, Entity Referenced (the field referencing each other) then relate the contextual filter. Tell me what the results is going to be. :D
    – Danz
    May 15, 2015 at 2:32

Your Answer

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

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