简体   繁体   English

Drupal 6:将自定义显示输出分配给views_embed_view

[英]Drupal 6: assigning custom Display Output to views_embed_view

$viewName = 'my_view_name'; $ viewName ='my_view_name'; print views_embed_view($viewName); 打印views_embed_view($ viewName);

we have such a cool views_embed_view func. 我们有一个很棒的views_embed_view func。 in Drupal to display a view inside another template. 在Drupal中显示另一个模板中的视图。 But It doesn't get the custom "Display Output" :/ it gets the default. 但是它没有得到自定义的“ Display Output”:/它得到了默认值。

How can I assign my custom Display Output (under Theme: Information) to views_embed_view? 如何将自定义显示输出(在主题:信息下)分配给views_embed_view?

Appreciate helps! 感谢帮助! thanks a lot! 非常感谢!


[UPDATED] [更新]

I try as below, but still not taking the custom display 我尝试如下操作,但仍未采用自定义显示

alt text http://files.droplr.com.s3.amazonaws.com/files/15306373/1hKd8R.view.jpg 替代文字http://files.droplr.com.s3.amazonaws.com/files/15306373/1hKd8R.view.jpg

  $view = views_get_view('my_view_name');
  $view->set_display('page_2'); // See gotcha below
  $view->set_arguments($user->uid); // Set arguments
  $view->pre_execute(array($user->uid)); // Set arguments for pre exicute
  print $view->display_handler->preview();
  $view->post_execute();

The gotcha is that page_2 is not the name of your display it is the views internal name, you can work this out by looking at the theme informaiton for the display you want in views admin. 需要注意的是,page_2不是显示器的名称,它是视图的内部名称,您可以通过在视图管理中查看所需显示的主题信息来解决。

你可以用

<?php print views_embed_view('my_view_name', 'block_1') ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM