Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I have a portfolio showing somes nodes (views3 + views slideshow using cycle). Everything works fine, I've a default path /portfolio to access to it.

However, I'm trying to set a path for each slide. I would like to use /portfolio/%nid and using %nid in views to default the first viewed slide to this node id.

Anyone know how it is possible ? I've tried with UI but I don't think it is enough.

share|improve this question

2 Answers

In jQuery Cycle there is an option called startingSlide. By default this is set to 0, like this: startingSlide: 0

If I remember correctly there is a tab/textarea for advanced settings where you can add options to jQuery Cycle from within the Views UI. I think you can add "startingSlide: 5" for example there.

You will need to find out which is the starting slide (convert the %nid to which row in the view it is) and add it as a HTML element. When that is in place we can fetch it with jQuery and add it as a jQuery Cycle option. I'm not sure which is the best way but I think you could do something like:

    function MYMODULE_views_pre_render(&$view) {
      if($view->name == "MYVIEW") {
        $view->attachment_after = $startingslide;
      }
    }

You will have to add more code to find out $startingslide there of course. Look inside $view->result and find out which of the rows that is the argument, that will be your $startingslide. Use dpm() on the view to search through the object.

Hope this will help you. Let me know what you ended up doing :)

share|improve this answer

You could add an exposed filter to your view, configure it to show nids greater than the provided value, and mimic it's URL accordingly.

for example /portfolio?nid_is_greater_than=3

You could then hide your filter with css.

share|improve this answer
I'd use an argument (contextual filter) rather than an exposed filter - unless there are already arguments in use and this extra one would mess with the handling of those. – Alfred Armstrong Mar 20 at 14:51
I know of no way to compare a field value to a contextual filter value. – magtak Mar 29 at 14:46
Good point. Must have been half-asleep when I posted the previous comment, sorry. – Alfred Armstrong Mar 30 at 16:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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