11

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.

5 Answers 5

1

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 :)

0

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.

3
  • 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. Mar 20, 2013 at 14:51
  • I know of no way to compare a field value to a contextual filter value.
    – user5005
    Mar 29, 2013 at 14:46
  • Good point. Must have been half-asleep when I posted the previous comment, sorry. Mar 30, 2013 at 16:09
0

Since your problem is about appearance, not about structure I suggest to not solve it on the server and not in the URL path but on the client with a URL fragement: /portfolio#slide-[nid].

I've not read the javascript code of views slideshow + cycle, but I guess it's quite easy to adopt it's behavior to read the URL fragment on initialization of the slideshow. Or maybe there is already such a logic implemented which you could use...

0

How about using 'Rewrite Output Results' option in Fields section of Views?

  1. In Views, go to Configure (Image) Field > Rewrite Results
  2. Check the 'Output this field as a link' checkbox
  3. Enter the Link Path (nid/) and other details
  4. Click on Apply
  5. Save View

Hope this helps.

0

Views passes off the display to node_view() in that case, and doesn't get involved with the markup for the row.

The easiest way to do what you want is to implement hook_preprocess_node(), look for a View in the current context, and if the node is being rendered as part of that display, you can make some alterations.

TAKE A LOOK AT THIS:

function MYMODULE_preprocess_node(&$vars) {
  if (!empty($vars['view']) && $vars['view']->view_name == 'foo') {
    $nid = $vars['node']->nid;
    $vars['extra_link'] = l('Some text', "node/$nid");
  }
}

In your node.tpl.php file you'll have access to $extra_link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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