embed view inside taxonomy-term page
edex13 - December 8, 2007 - 05:01
i want to theme taxonomy term page. what i found that i can theme it using path(http://drupal.org/node/104316).
i copy page.tpl.php and name it to page-taxonomy-term.tpl.php
after that i create view below:
$view = new stdClass();
$view->name = 'taxo';
$view->description = 'Shows posts started by or participated in by a given user';
$view->access = array (
);
$view->view_args_php = '';
$view->page = TRUE;
$view->page_title = 'post';
$view->page_header = '';
$view->page_header_format = '1';
$view->page_footer = '';
$view->page_footer_format = '1';
$view->page_empty = 'No posts found.';
$view->page_empty_format = '1';
$view->page_type = 'list';
$view->url = 'temp/url/$arg';
$view->use_pager = TRUE;
$view->nodes_per_page = '15';
$view->sort = array (
array (
'tablename' => 'node_comment_statistics',
'field' => 'last_comment_timestamp',
'sortorder' => 'DESC',
'options' => 'normal',
),
);
$view->argument = array (
array (
'type' => 'taxid',
'argdefault' => '1',
'title' => '',
'options' => '',
'wildcard' => '',
'wildcard_substitution' => '',
),
);
$view->field = array (
array (
'tablename' => 'node',
'field' => 'title',
'label' => 'Title',
'handler' => 'views_handler_field_nodelink_with_mark',
'options' => 'link',
),
);
$view->filter = array (
array (
'tablename' => 'node',
'field' => 'status',
'operator' => '=',
'options' => '',
'value' => '1',
),
);
$view->exposed_filter = array (
);
$view->requires = array(node_comment_statistics, node);
$views[$view->name] = $view;then i paste
<?php
//load the view by name
$view = views_get_view('taxo');
//output the view
print views_build_view('embed', $view, array($id), false, false);
?>above the
<?php print $content ?>if i go to http://localhost/?q=taxonomy/term/7
how i can use the number 7 as the argument for the embed view?

you can use arg() function
you can use arg() function for argument
Kuldip Gohil
A quess
Change
print views_build_view('embed', $view, array($id), false, false);to
print views_build_view('embed', $view, array(arg(2)), false, false);You may need to change
array(arg(2))toarray(1 => arg(2))(adjusting the 1 as neeed) if the view does not expect the tid as the first argument.it work. thank you very much
it work. thank you very much :)
Thanks. This helped a lot
Thanks. This helped a lot in my embedding a view. My use is as follows w/ views2 and drupal 6.2...
<?php$view = views_get_view('myviewname');
print $view->execute_display('default', array(arg(1)));
?>