zaib Posted October 24, 2017 Posted October 24, 2017 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
SamC Posted October 24, 2017 Posted October 24, 2017 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.
PWaddict Posted October 24, 2017 Posted October 24, 2017 I think @adrian's reply on a similar topic will help what you want to achieve. 2
webhoes Posted October 29, 2017 Posted October 29, 2017 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 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now