3

I have a content type called Movie, it has a node reference to a content type called LeadActor. The LeadActor content type can have node references of its own back to several different Movies nodes.

When I have a page that displays the full content of a Movie, I've changed the node template to have a link to the LeadActor.

When a user uses the link to LeadActor from a Movie page, is there anyway for me to know what Movie the user came from when I'm on the LeadActor page?

I've thought about adding an extra argument to the LeadActor page link - the node id to the Movie, but I was wondering if there might be a cleaner way to handle this.

I'm using Drupal 7 and the node reference (references) module. I've also tried using the corresponding node references module - but so far I haven't been able to understand if this will work.

Thanks for your help.

1
  • 2
    Your question is more likely to get answered if you accept the answers that helped you on your previous questions. See the faq for more information on how to accept answers.
    – mpdonadio
    Commented Nov 12, 2011 at 0:24

2 Answers 2

1

Reading the text of your question, it looks like you don't necessarily need to know what the parent is but more where the visitor is coming from (and if it is a movie which one).

A possible solution, as you mentioned, would be to add some parameters to the URL. A simpler option might be just a tiny bit 'o javascript.

<script type="text/javascript">
  (function ($) {
    $(document).ready(function() {
      var referrer =  document.referrer;
    });
  })(jQuery);
</script>

Then use the referrer (previously browsed URL) and compare it against the list of movie URLs via JQuery. If one matches, add a css class to style the link as an indicator.

<script type="text/javascript">
  (function ($) {
    $(document).ready(function() {
      var referrer = document.referrer;
      $('#movie-list li a').each(function(index) {
        if ($(this).attr('href') == referrer) {
          $(this).addClass("active-movie");
        }
      });
    });
  })(jQuery);
</script>

Where

<ul id="movie-list">
  <li><a href="http://example.com/duck">duck</a></li>
  <li><a href="http://example.com/duck">duck</a></li>
  <li><a href="http://example.com/goose">goose</a></li>
</ul>
0

There is a module called reference from URL it can help But I think you need only to know which album so send nid as an argument with the link "Change the node tpl of albums to add nid to the link" then in artist check args() to get nid

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.