Search the Community
Showing results for tags 'compare fields'.
-
Hello everyone! I have properties and clients pages and want to make a statement showing what may be of interest to customers who are looking for. I have two different templates with fields that are repeated in both. I want to do a relationship in my module. My code works fine but looking for a more simple and efficient way and learn for the next time I do it. My site: - Clientes (template=clientes) - cliente 1 (template=cliente) ->fields (prop_precio, prop_zona, prop_tipo_inmueble, prop_tipo_transaccion) - cliente 2 (template=cliente) ... It also has a checkbox field (cliente_busca) because not all clients seeking properties. - Inmuebles (template=inmuebles) - inmueble1 (template=inmueble) -> fields (prop_precio, prop_zona, prop_tipo_inmueble, prop_tipo_transaccion) My code: $clientes = wire('pages')->find("template=cliente, cliente_busca=1, include=all"); $inmuebles = wire('pages')->find("template=Inmueble"); foreach($clientes as $cliente) { $out .= "<ul><li>Al cliente {$cliente->title} le pueden interesar los siguientes inmuebles...</li></li>"; foreach($inmuebles as $inmueble) { if ($cliente->prop_precio >= $inmueble->prop_precio && $cliente->prop_habitaciones <= $inmueble->prop_habitaciones && $cliente->prop_tipo_inmueble == $inmueble->prop_tipo_inmueble && $cliente->prop_tipo_transaccion == $inmueble->prop_tipo_transaccion && $cliente->prop_zona == $inmueble->prop_zona) { $out .= "<li>{$inmueble->title}</li>"; } } }; Any help is welcome.