Sort list
Permalink
Hi
I want to amend my system so that a list of tickets that is retrieved from a custom object is sorted alphabetically rather than in the order they were entered into the system. Any help appreciated.
Justyn
I want to amend my system so that a list of tickets that is retrieved from a custom object is sorted alphabetically rather than in the order they were entered into the system. Any help appreciated.
Justyn
<form action="<?=$this->action('add_attendee')?>" id="new_attendee" method="post"> <h3><?=t('Add New Attendee')?></h3> <br/> <?php foreach($tickets as $ticket){ $ticket_name = $ticket->getAttribute('tickets_title'); $ticket_event = $ticket->getAttribute('ticket_event'); $ticket_price = Loader::helper('ticket_adjust','attendees')->CompareTicketChange($ticket); if($ticket_name != 'General Admission' && $ticket_name!= 'Serve Part Time - Under 19') { ?> <div class="clearfix"> <div class="row"> <div class="span3"> <b><?=$ticket_name?></b>
Viewing 15 lines of 40 lines. View entire code block.
Can you provide us the code which creates the $tickets array rather than the code that displays it? I'm guessing you need something like $pl->sortByName()
Sorry my error:
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); class BookingSelectAttendeesController extends Controller { public function on_start(){ Loader::model('attribute/categories/proforms_item','proforms'); Loader::model('proforms_item_list','proforms'); Loader::model('proforms_item','proforms'); Loader::model('attendees','attendees'); Loader::model('attendees_list','attendees'); Loader::model('attribute/categories/attendees','attendees'); Loader::model('tickets_list','tickets'); Loader::model('attribute/categories/tickets','tickets'); $this->set('fm',Loader::helper('form')); $html = Loader::helper('html'); $this->addHeaderItem($html->css('catalyst_special.css', 'catalyst'));
Viewing 15 lines of 220 lines. View entire code block.
It looks like tickets is just a TicketList->get(), what's in the tickets_list model?
It's a custom object with a list of tickets and relevant attributes such as the handle I want sort by which is tickets_title. is that enough info?
Try using this
I'm making some assumptions but I think that will work
$al = new TicketsList(); $al->sortByName(); $tickets = $al->get();
I'm making some assumptions but I think that will work
Thanks for this. Unfortunately there was no change when I used but. It was enough for me to the do a free google and come up with:
This works perfectly. Thank you SO much.
$al = new TicketsList(); $al->sortBy(ak_tickets_title); $tickets = $al->get(); $this->set('tickets',$tickets);
This works perfectly. Thank you SO much.