Spun off from #1471770: Embed display is missing its handler class

Add a helper function similar to views_embed_view() that adds views title.

Probably would be best to pass back a render array(Contents of the view would still be in '#markup').

Not sure yet what others would be expecting really. I have seen this tossed around a few times about the title and is the only reason I am looking into this, however, I am unsure what is expected for this. Open to some ideas.

Comments

joachim’s picture

> Not sure yet what others would be expecting really

The more I think about it the more I'm unsure about that too!

On the surface of it, having something that gives you:

- h2 - title - /h2
- view content

would seem handy.

But then, this is going to be consumed in so many different ways that I don't know how useful it would be. For one thing we don't know what heading level is needed.

Having said that, having to get the title yourself is not that simple:

  $view = views_get_view($name);
  if (!$view || !$view->access($display_id)) {
    // Access denied
  }

  $title = $view->get_title();
  $content = $view->preview($display_id, $args);

... the one line call to views_embed_view() has ballooned to 6!

So something that returns an array of title, content would be saving on that, even if you then have to format the title text yourself.

jstoller’s picture

I was just trying to figure out why this wasn't working. Could this module simply supply a $title variable to views-view.tpl.php? Then users can do whatever they want with it in the theming layer.

jstoller’s picture

Issue summary: View changes

Adding reference to original issue.

grndlvl’s picture

Issue summary: View changes
Status: Active » Closed (outdated)