Filter content in Symfony 1.2.x admin generator?

一笑奈何 提交于 2019-12-08 10:35:50

问题


I have a Symfony 1.2.7 application where 3 different sites coexist in the same database. All content has a foreign key, 'site_id', that says which site it belongs to.

In my generated admin interface I want to be able to show content from the currently selected site (actually set using a filter class, based on the domain used to access the admin interface).

An example:

Using 'www.domain.com/admin/', the user has access to content belonging to the 'domain.com' domain (with site_id=1) and this site only.

Any ideas on how to achieve this?

Thanks in advance


回答1:


you can use table_method option in the generator.yml of your Content module:

        config:
...
          list:
            table_method: getSiteContent
...

then write a method in your Content_Table class that modifies the query object:

public function getSiteContent(Doctrine_Query $q) {
        $q->andWhere( some where condition with site_id );
        return $q;
}


来源:https://stackoverflow.com/questions/1308215/filter-content-in-symfony-1-2-x-admin-generator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!