Jump to content

sorting pages by fieldtype "date"


vxda
 Share

Recommended Posts

Hi i need to sort pages for upcomming games. so i have this code

<?php
	$Match = $pages->find('parent=1022, sort=date');
	$tab = "";
	$button = "";
	$i = 0;
	foreach ($Match as $match ) {
		$date = date("d F", $match->getUnformatted("date"));
		$time = date("h:i", $match->getUnformatted("date"));
		$count = count($match);
		$selectVal = '';
		if ($match->transmition == '1') $selectVal = 'tak';
		else $selectVal = 'nie';
		if ($i == 0) {
			$button .= "<a class='active {$i}' href='#tab_{$match->id}'>Następny mecz</a>";
			$tab .= "<div id='tab_{$match->id}' class='tab active'>";
		}else{
			$button .= "<a class='{$i}' href='#tab_{$match->id}'>Poprzedni mecz</a>";
			$tab .= "<div id='tab_{$match->id}' class='tab'>";
		}
		if ($match->logo1) $logo1 = $match->logo1->size(77,77)->url;
		else $logo1 ='';
		if ($match->logo2) $logo2 = $match->logo2->size(77,77)->url;
		else $logo2 ='';
		if($date && $time)
		$tab .= "<dl><dt>Kiedy?</dt><dd>{$date} {$time}</dd></dl>";
		if($match->team_name2)
		$tab .= "<dl class='teamname'><dt>Z kim gramy?</dt><dd>{$match->team_name2}</dd></dl>";
		if($match->text_input)
		$tab .= "<dl><dt>Gdzie?</dt><dd>{$match->text_input}</dd></dl>";
		if($match->text_input2)
		$tab .= "<dl><dt>Jaki typ rozgrywki?</dt><dd>{$match->text_input2}</dd></dl>";
		if($match->text_input3)
		$tab .= "<dl><dt>Jakie bilety?</dt><dd>{$match->text_input3}</dd></dl>";
		if ($selectVal)
		$tab .= "<dl><dt>Czy będzie transmisja?</dt><dd>{$selectVal}</dd></dl>";
		if ($logo1 && $logo2) {
			$tab .= "<div class='clear'></div>";
			$tab .= "<div class='logos clearfix'>";
			$tab .= "<div class='logo1'><img src='{$logo1}' alt='' /></div>";
			$tab .= "<div class='vs'>VS</div><div class='logo2'><img src='{$logo2}' alt='' /></div>";
			$tab .= "</div>";
		}
		$tab .= "</div>";
		$i++;
		if($i > 1) break;
	}
?>
<section class="next-match">
	<div class="container">
		<div class="span4">
			<div class="tabs clearfix">
				<?php echo $button; ?>
			</div>
			<div class="tab-wrap">
				<?php echo $tab; ?>
			</div>
		</div>
	</div>
</section>

now i need first $tab to be the closest next date from today's date,

in the second $tab i need to display the last one played from today's date.

The first one is working fine showing exacly what i need, just cant figure out how to dispaly the last one played.

Any idea how can i achive this ?

Regards

Paweł

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...