Jump to content

Recommended Posts

Posted
Hi,
I have a number of pages with a template that has a repeater field (salida_fecha_repeater) which has 2 fields salida_fecha (type date) and salida_fecha_markup (float), when I show the pages, I have show the first available date, so I would not show dates before today.
 
$salidas = $pages->get("/salida/")->children("limit=5,salida_fecha_repeater.salida_fecha>=".date("Y-m-d"));
foreach($salidas AS $salida ) {
        $markup = $salida->salida_fecha_repeater->find("salida_fecha>=".date("Y-m-d"))->first(); # Test 1
	#$markup = $salida->salida_fecha_repeater->first(); # Test 2
	echo $salida->title." [".$salida->id."]"." | ".$markup->salida_fecha_markup."<br>";
}
With # Test 1 returns nothing
With # Test 2 returns the first record in the repeater does not always correspond.
 
Thanks in advance
Diego
Posted

Your children() operation is just finding the pages that have at least one repeater item that matches the criteria. So you are doing the right thing by performing another find (or foreach) on the result. Just to rule out any possible localization, date conversion, or ProcessWire version issues, try replacing your 'date("Y-m-d");' with just 'time();', for both queries. 

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
×
×
  • Create New...