Hi,
I'm using Insert View on my current project to allow my client to insert image galleries (created with the Image module/taxonomy/Views) into nodes. It seems that Insert View inserts the page version of a View.

The functionality I'm looking for is for Insert View to insert the block version of a View. This way, my client could insert an image gallery that would show, for example, just 8 images, with a [more] link that goes to the full image gallery page (the page version of the View).

Is this possible? Is this a feature anyone is willing to code?

Thanks,
Alex

Comments

mlsamuelson’s picture

Category: support » feature

Inset View calls views using views_build_view, which allows one to specify a "block," "page," or "embed" view. Insert View uses the embedded view, as that is usually what's wanted.

So, how do address a dilemma such as yours... I'm not sure that adding a parameter to the insert view tag is advisable - as these are supposed to be somewhat easy to use, right? If we want to make it as complicated (and require the technical understanding) as just using the code, then, well, we should just be using the code, right?

Does anyone think that a global setting to choose whether views should be inserted as a page, block or embedded view would be useful?

For now, you could make the module work how you want with a simple *cough* hack *cough* by changing 'embed' to 'block' on lines 76 and 79 of the insert_view.module file.

mlsamuelson

akahn’s picture

I tried out the hack and indeed it does insert a block view rather than the page view. Unfortunately, the "more" link at the bottom of the block doesn't point to anywhere useful. If I'm on node/3 and the View I've inserted is [view:image_gallery==Community Gardens], the more link goes to node/3/Community+Gardens (sort of a bunk path, not the path to the full gallery) as opposed to gallery/Community Gardens, the path for the page version of the View.

Any suggestions on how to hack Views to make this work would be appreciated. ;) Should this possibly be filed as a bug for Views? Maybe?

Cheers,
Alex

mlsamuelson’s picture

Ah, okay, this is sounding familiar.

The issue is that the "more" link is being constructed as a relative link, and thus it's adding on to the current path rather than using the root level as it's point of origin. This is an understandable thing to have happen if we're running a view out of a node, like we do when we use insert view. And because it's such an edge case, I wouldn't feel it's a views shortcoming to resolve...

You ought to be able to construct a view that:
1. includes your full-featured gallery as a page view
2. also includes a block view (depending on fields desired, etc. you may want to setup the page and block views as separate views) and then,
3. in the block view's footer, manually enter a link to the page view using a link that's relative to the root of the site (eg. "/path/to/view").

Now this is a manual solution, and not one I'd recommend if you're seeking to use various arguments in your view, but as a workaround, if you only have to tweak a couple views for this, it could provide the functionality you need.

Are you using taxonomy as an argument in your view?

mlsamuelson

akahn’s picture

Yes, I'm using taxonomy as an argument in the view. Formerly (as in the example above) I was using Taxonomy: Term Name as the argument, but since that created problems (somewhere in between Image and Pathauto), I've switched back to using Taxonomy: Term ID. I thought it'd be more intuitive for my client to insert a view using [view:image_gallery==Community Gardens] as opposed to [view:image_gallery==5], but he'll have to deal with using term ID.

Your idea for the block view's footer is a good one! If the view's argument is available somehow in the footer, this would be easy. Do you know if/how I could refer to a view's argument in its footer? (Simply using $arg doesn't work.) That would make everything come together. Otherwise perhaps I could override the Views function that creates the more link.
Thanks for the help.

-Alex

akahn’s picture

Status: Active » Fixed

Okay. I put the following PHP in my block footer:

<?php $this_view = $GLOBALS['current_view']; ?>
<a href="image/tid/<?=$this_view->args[0];?>">View the full image gallery</a>

And it works perfectly. Now each embedded image gallery block links to its full page version. args[0] contains the argument the view was passed. Thanks for leading me in this direction, mlsamuelson, and for the excellent module. :)

mlsamuelson’s picture

Thanks for letting me know that resolved the issue. And for sharing the code. It's always a thoughtful touch when folks do that.

mlsamuelson

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.