So I'm trying to use sfPropelPager to navigate through a list of a
user's friends, and I'm having some difficulty.

The schema is (simplified):

friend:
  id: ~
  senderId: ~
  userId: ~
  confirmed: boolean

user:
  id: ~
  name: varchar(255)

and I've set up a propel pager like this:

    $c = new Criteria();

    $cton1 = $c->getNewCriterion(FriendPeer::SENDERID, $id);
    $cton2 = $c->getNewCriterion(FriendPeer::TARGETID, $id);
    $cton1->addOr($cton2);

    $c->add($cton1);
    $c->addDescendingOrderByColumn(FriendPeer::CREATED_AT);
    $c->addJoin(UserPeer::ID,FriendPeer::TARGETID);
    $c->add(FriendPeer::CONFIRMED, '1');

    $pager = new sfPropelPager('User', 10);
    $pager->setCriteria($c);
    $pager->setPage($request->getParameter('page', 1));
    $pager->init();
    $this->pager = $pager;

Everything is obviously separated into different layers.  Here's the
template:

<?php echo $pager->getNbResults() ?> results found.<br />
Displaying results <?php echo $pager->getFirstIndice() ?> to  <?php
echo $pager->getLastIndice() ?>.
<br />
<?php foreach ($pager->getResults() as $user): ?>
  <?php echo $user->getName() ?>
<?php endforeach ?>
<br />
<?php if ($pager->haveToPaginate()): ?>
  <?php echo link_to('&laquo;', 'article/list?page='.$pager-
>getFirstPage()) ?>
  <?php echo link_to('&lt;', 'article/list?page='.$pager-
>getPreviousPage()) ?>
  <?php $links = $pager->getLinks(); foreach ($links as $page): ?>
    <?php echo ($page == $pager->getPage()) ? $page : link_to($page,
'article/list?page='.$page) ?>
    <?php if ($page != $pager->getCurrentMaxLink()): ?> - <?php endif ?
>
  <?php endforeach ?>
  <?php echo link_to('&gt;', 'article/list?page='.$pager-
>getNextPage()) ?>
  <?php echo link_to('&raquo;', 'article/list?page='.$pager-
>getLastPage()) ?>
<?php endif ?>


After trying to get this to work for 3 hours, my brain is numb, and if
any of you could help out a symfony newbie, I'd appreciate it.  I just
want to display the names of a user's friends, but the script displays
both names in the set.  I'm not sure how to use Propel and the Pager
to only return the other name.  Is there another pager object that
will just take an array?  Finishing it fast is my first priority, so
if there's a simpler way to do it, that would be preferred.

Thanks,

Brendan

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
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