views:

266

answers:

2

Hi friends,

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

we have such a cool views_embed_view func. in Drupal to display a view inside another template. But It doesn't get the custom "Display Output" :/ it gets the default.

How can I assign my custom Display Output (under Theme: Information) to views_embed_view?

Appreciate helps! thanks a lot!


[UPDATED]

I try as below, but still not taking the custom display

alt text

+2  A: 
  $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.

Jeremy French
you again :) appreciate your time and help! I updated the post
artmania
aha sorry, you say Theme Name, the listbox above these theming file names,! ok, I tried that as well, but still no working. I have blank between words at my theme name. is that the problem? "my theme name"
artmania
In your case you will probably need set_display('block_1').
Jeremy French
Where about do you live my friend? I would love to buy you a ice-cold beer for today's great help! You did teach me a lot today! appreciate! it works great now!
artmania
+1  A: 

You can just use

<?php print views_embed_view('my_view_name', 'block_1') ?>
VictoriaChan
aha! that's cool! thanks!!
artmania