gearsdigital
gearsdigital

Reputation: 14205

Drupal: Dynamic View using Arguments

For a current project i need to setup a specific view to display a gallery detailpage. It should work like this:

1. User clicked a node (costum-post-type: gallery)
2. User received an overview page with linked images
3. User clicked an image
4. User received the gallery page (gallerific view)

Step 1-3 are done. But how can I get Drupal to build a detail page using the data of the overview page?

For Example something like this: http://example.com/gallery-1/detail or http://example.com/gallery-2/detail.

/gallery-n is the overview page with linked images and detail is the detailpage of /gallery-n.

Hope you'll understand what i mean?!

EDIT

On the overview page i have a bunch of thumbails which each are linked to the detail gallery (jquery galleriffic) page.

Upvotes: 0

Views: 2524

Answers (2)

Igor Rodinov
Igor Rodinov

Reputation: 471

If I'm correct understand your problem you should do this things.

 1. Create view1 for page with linked images. It should be page display with http://example.com/images/%nid
   where %nid is nid argument of gallery. 
 2. Create view2 for gallery detailed page. it should be page display with http://example.com/%nid/detail 
 3. Theme that views as you want.
 4. For view1 for image field use override output in field settings to make it links to %nid/detail

P.S. Use relationships where needed. If description is not clear, fill free to ask.

Upvotes: 1

Mark Cameron
Mark Cameron

Reputation: 2369

You can try something like this, in a custom module you make (or maybe already have): where you set the path to the page you want in the menu and set it as a callback that calls a function and then you can render whatever you want, or call whatever you want.

function MODULENAME_menu() {
  $items = array();
  $items['gallery/%/detail'] = array(
    'title' => 'Gallery Detail',
    'page callback' => 'MODULENAME_gallery_detail_page',
    'page arguments' => array(1),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK
  );
  return $items;
}

function MODULENAME_gallery_detail_page($gallery_id) {
  // Here you can render the view as a page, using the gallery
  // id which you passed as a parameter to this function.
  // So Change MYCUSTOMVIEW to the view you want to render
  $view = views_get_view('MYCUSTOMVIEW');
  print views_build_view('page', $view, array(), false, false);
}

Just change MODULENAME with the name of your module. You might need to do some work when calling the views_build_view, but it should be a start, you can ask some more questions if you like and I'll help out.

Upvotes: 1

Related Questions