I have the following code which displays a theatre show feed on my website, coming from an external ticketing company.
<!-- PULL IN SHOW FEED -->
<div class="container">
<div class="col-md-12 whats-on-feed">
<!-- PULL IN SHOW FEED -->
<div class="container">
<div class="col-md-12 whats-on-feed">
<?php
$xml = simplexml_load_file('https://tickets.leicesterymca.co.uk/feed/shows');
if(isset($wp_query->query_vars['month'])) {
$month = $wp_query->query_vars['month'];
$fromDate = date("Y"). '-'. $month;
$shows = $xml->xpath("//*[contains(ActiveFrom,'$fromDate')]");
}else if(isset($wp_query->query_vars['genre'])) {
$genre = str_replace("-", " ", $wp_query->query_vars['genre']);
if($genre != 'all'){
$shows = $xml->xpath("//*[Genres/Genre/@Name='$genre']");
}else{
$shows = $xml;
}
}else{
$shows = $xml;
}
?>
<div class="block-grid-xs-1 block-grid-sm-2 block-grid-md-3 block-grid-lg-4 show-list">
<?php
$i = 1;
foreach ($shows as $Show) {
$activeFrom=date_create($Show->ActiveFrom);
$activeTo=date_create($Show->ActiveTo);
if(strlen($Show->ShowId) > 0){
?>
<div>
<div class="box">
<div class="caption">
<h3><?php echo $Show->Name ?></h3>
<p><?php echo $activeFrom->format('D d M Y'); ?></p>
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6">
<a href='/show?showid=<?php echo $Show->ShowId ?>' class='btn btn-success btn-sm btn-clear-white'>More Info</a>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<a href='/buy?showid=<?php echo $Show->ShowId ?>' class='btn btn-success btn-sm btn-clear-white'>Buy Tickets</a>
</div>
</div>
</div>
<div class='image-holder' style='background-image: url("<?php echo $Show->SmallImageUrl ?>");' /></div>
</div>
</div>
<?php $i++; }} ?>
</div>
</div>
This is coming from an XML feed that the ticketing company outputs from their system.
Currently they are displaying in order of show ID, I think this is the default, but I need them to display in order of date - The data node in the xml feed for date is: ActiveFrom.
I have seen this solution:
<xsl:sort select="ActiveFrom" order="ascending" />
But I don't really know if A: it's the correct approach, or B: Where I would add it in relation to my code? Can anyone help?