Drupal 6: Render Views 2 data in a page tpl file

2019-07-31 14:34发布

问题:

I think the answer might be obvious but I can't seem to figure it out.

How do I render a view I've created in Views 2 (Drupal) in a page-pagename.tpl.file? My thought was that it would be some sort of PHP snippet but I can't find documentation about it.

Any thoughts that might steer me in the right direction.

回答1:

The solution is here:

http://views-help.doc.logrus.com/help/views/embed

Also "function" can be replaced with "print" and the additional param brackets can be removed.

So it will look like this:

$name = "yourviewnamegoeshere";
print views_embed_view($name, $display_id = 'default');