0

I have a Views, that renders nodes as "Rendered entity" with custom display mode - "cover". In template (or preprocess function) for this specific theming case, I need to get the Views object, that calls this render process, especially its arguments. How can I do this?

2
  • Have you tried using the devel module to print out the variables available to your template to see if the view is in there?
    – rooby
    Dec 29, 2014 at 12:33
  • yes, but there no information about views
    – Molfar
    Dec 29, 2014 at 13:07

1 Answer 1

1

The "Rendered entity" row type comes from the Entity API module.

When using the node view row type the views module adds the view object to the node in views_plugin_row_node_view::render(), however the entity module doesn't do anything similar for its row type, so there is no easy way to get the view object when themeing the entity.

If your view is using a page display you can use views_get_page_view() but this doesn't work with other display types, like block views for example.

Note that there is a feature request for the entity module to add the view object to the entity but it is still in development and the module maintainer wants to use a different approach.
So you could use that patch and then when a newer patch comes along you will likely need to make some minor tweaks to your custom themeing code, or you could make a new version of that patch as per the maintainers comments and then use that and possibly avoid having to change your custom code in future.

If you are comfortable updating the patch I would recommend that approach, otherwise I would recommend using the current patch and updating your custom code in future.

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.