Specify the same itemView for several views in YII?

805 Views Asked by At

I have the following directory structure:

-> views

---> product
  |- view.php
  |- gridView.php

---> site
  |- index.php

gridView.php is a partial view that I wish to use in index.php under site. If I copy gridView.php to site/gridView.php, the following works:

<?php
  $this->widget('zii.widgets.CListView', array(
    'dataProvider'=> $dataProvider,
    'itemView' => 'gridView',
    'summaryText' => '',
    'emptyText' => '
    ', 
  ));
?>

But if I only leave a copy under /product/, the above does not work.

How can I get the index.php view to work using the same gridView.php file located in product? I've tried the following, but it does not work:

<?php
  $this->widget('zii.widgets.CListView', array(
    'dataProvider'=> $dataProvider,
    'itemView' => 'product/gridView',
    'summaryText' => '',
    'emptyText' => '
    ', 
  ));
?>

Any ideas?

1

There are 1 best solutions below

0
On

If you want to access views from another controller you should always preceed the view name with a / followeed by the controller ID. So in your case that's /product/gridView.