2

I have a view with no fields but a special format (An openlayer map). I would like to wrap the whole output (a map) with a static link. Typically I would like something like:

<div class="view-content">
    <a href="some static url">
        /*the map*/
    </a>
</div>

Is this achievable?

EDIT My view doesn't use fields, so I can't use custom texts fields. format

1 Answer 1

1

There might be a couple of method to do this.

Using Views: you can add a "Custom Text" global field and add view content to it and wrap it on the link or you can "Rewrite results" on the same file and output the field as a link.

Using a template file: view let you have a custom template file for your view, so you can use it to wrap your view content with the link.

Using jQuery: you can do something like this:

$('div.VIEW-CLASS').click(function(){document.location.href='URL.COM';});

And that will wrap the view on a link.

See the images below to see how to add a "Custom text" field and how to make it a link:

Select custom text field

Select custom text

Add views fields into the custom text field and make it all a link

Add views fields into the custom text field

4
  • I cannot add a view to a custom text. I could add a view area to the header/footer, but not rewrite results. I also have tried to add the following snippet in the header/footer but it didn't work: <script language='Javascript'>$('div.openlayers-views-map').click(function(){document.location.href='/somedir';});</script> . Is that the correct way to insert it? Thank you!
    – znat
    Commented Sep 3, 2012 at 14:59
  • I updated the answer with images. Please take a look.
    – Emil Orol
    Commented Sep 3, 2012 at 20:58
  • Thank you Redhatlab, my view doesn't use fields and I cannot transform it in fields as it's a map...
    – znat
    Commented Sep 4, 2012 at 0:16
  • This is an interesting solution... Are changes in the hidden fields (like trimming) still applied?
    – 0711master
    Commented Feb 12, 2018 at 20:34

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.