Well preety easy. try this :

   // IssuePeer.php
   public static function selectAllFromCulture($c)
   {
       $culture = sfContext::getInstance()->getUser()->getCulture();
       $criteria = clone $c;
       $criteria->add(self::CULTURE,$culture);
       return self::doSelectJoinAll($criteria);
   }

   public static function getCountForCulture($c)
   {
       $culture = sfContext::getInstance()->getUser()->getCulture();
       $criteria = clone $c;
       $criteria->add(self::CULTURE,$culture);
       return self::doCount($criteria);
   }

the main issue is that you are initializing the $criteria in the peer
method. Doing so, the methods that handling the filters & pagination are
useless.
you could also check if $c is a Criteria instance

       if(false == ($c instanceof Criteria)){
          $c = new Criteria();
       }
    $criteria = clone $c;
[....]


alecs


On Thu, Apr 23, 2009 at 11:45 AM, Adam Frame <[email protected]> wrote:

>  Good morning fine people :)
>
> I have a very strange problem to do with the Admin Generator on
> sf1.0.20/Propel.
>
> I use a custom peer_method and a custom peer_count_method in generator.yml.
> The custom peer_method returns a Propel object based on doSelectJoinAll. The
> custom peer_count_method does a doCount of the same object.
>
> I also have a max_per_page set of 5 to paginate the results in list view by
> 5.
>
> This, however, is not working.
>
> The list view shows ALL of the records retrieved by the custom peer_method
> without paginating it at all. The pagination links still appear at the
> bottom of the list but they don't make any difference.
>
> Looking in the cache (issues/actions.class.php .. executeList()) the Pager
> is being prepared correctly (I think). Here is what it shows ..:
>
>    // pager
>    $this->pager = new sfPropelPager('Issue', 5);
>    $c = new Criteria();
>    $this->addSortCriteria($c);
>    $this->addFiltersCriteria($c);
>    $this->pager->setCriteria($c);
>    $this->pager->setPage($this->getRequestParameter('page', 1));
>    $this->pager->setPeerMethod('selectAllFromCulture');
>    $this->pager->setPeerCountMethod('getCountForCulture');
>    $this->pager->init();
>
> Changing the peer_method in generator.yml to doSelectJoinAll makes the list
> paginate fine. So what do I have to do to make it work with a custom
> peer_method? What am I doing wrong?
>
>    // IssuePeer.php
>    public static function selectAllFromCulture()
>    {
>        $culture = sfContext::getInstance()->getUser()->getCulture();
>        $c = new Criteria();
>        $c->add(self::CULTURE,$culture);
>        return self::doSelectJoinAll($c);
>    }
>
>    public static function getCountForCulture()
>    {
>        $culture = sfContext::getInstance()->getUser()->getCulture();
>        $c = new Criteria();
>        $c->add(self::CULTURE,$culture);
>        return self::doCount($c);
>    }
>
> The result is the same no matter what I am filtering in the custom peer
> method.
>
> Any and all help will be appreciated.
>
>
> Adam
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to