Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>These are the steps to achieve the required result.</p> <ol> <li><p>Define a table method in your generator.yml</p> <pre><code>config: actions: ~ fields: ~ list: display: [news_id, title, category_name] table_method: doSelectJoinCategory </code></pre></li> <li><p>Add doSelectJoinCateory to your NewsTable.class.php</p> <pre><code>class NewsTable extends Doctrine_Table { ... public static function doSelectJoinCategory($query) { return $query-&gt;select('r.*, c.cateogry_name') -&gt;leftJoin('r.Category c'); } } </code></pre></li> <li><p>You need to override the sort query in your actions.class.php</p> <pre><code>class newsActions extends autoNewsActions { ... protected function addSortQuery($query) { if (array(null, null) == ($sort = $this-&gt;getSort())) { return; } if (!in_array(strtolower($sort[1]), array('asc', 'desc'))) { $sort[1] = 'asc'; } switch ($sort[0]) { case 'category_name': $sort[0] = 'c.category_name'; break; } $query-&gt;addOrderBy($sort[0] . ' ' . $sort[1]); } </code></pre></li> <li><p>The default generator theme will require that you override the isValidSortColumn in actions.class.php</p> <pre><code>protected function isValidSortColumn($column) { return Doctrine_Core::getTable(‘Payment’)-&gt;hasColumn($column) || $column == ‘cateogry_name’; } </code></pre></li> <li><p>You will need to override the generator theme to display sort link and icons as it requires the sort field to be real database mapped field. edit your symfony_dir/lib/plugins/sfDoctrinePlugin/data/generator/sfDoctrineModule/admin/template/templates/_list_th_tabular.php :</p></li> </ol> <p>Change this line</p> <pre><code>&lt;?php if ($field-&gt;isReal()): ?&gt; </code></pre> <p>To this : </p> <pre><code>&lt;?php if ($field-&gt;isReal() || $field-&gt;getConfig('sortBy')): ?&gt; </code></pre> <p>Hope that helps you</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload