Jump to content

result is showing in every category


zaib
 Share

Recommended Posts

I've two templates, one is category (multi select check boxes) and one is result based on the selected category

when I'm rendering result page all result is showing in every category, its not filtered each result should be belongs to the referenced category

<?php 
	$getCities = $pages->find("template=t3Cities_list, tags={$page->tag_code}, sort=title");
	$getResult = $pages->find("template=attractions, tags={$page->tag_code}, sort=random"); 
?>
<div class="container">
	<?php
	foreach($getCities as $city){
		echo "<div class='row'>";
		echo $city->title ;	
		echo "</div>";
		foreach($getResult as $result){
			echo $result->title ;
		}
	} 
?>
</div>

result should be like this

 

Birmingham
Oxford Street Louvre and Tuileries


Dubai
Gold Souk Dubai Mall


paris
Mercado de Motores Nómada Market

shopping.png

Link to comment
Share on other sites

9 hours ago, zaib said:

I've two templates, one is category (multi select check boxes) and one is result based on the selected category

Not sure what you mean here. Do both templates have this field called 'tags'? Is a page reference field I presume.

Link to comment
Share on other sites

You have two stand alone queries with no relation between them. Tag_code is not relating them in this case.

You should do something like this...

 

$cities = $pages->find("template=t3Cities_list, sort=title");

foreach ($cities as $c){

                   echo <div class="row">' . $c->title . '</row';

                              foreach($c->tag_code as $t){

                              echo $t->title .  ' |  ';

                             }

                }

 

I usually make it a function in _func.php

 

 

 

  • Like 1
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...