Jump to content

Listing Directory in PW


Pitbull
 Share

Recommended Posts

Hi! i need some help to build a listing website the way should work is like this: the bold is the categories and link

CITIES                                   /// CATEGORY  ------ (TEMPLATE = CITIES)

----------City                            /// SUBCATEGORY OF CITIES  ------ (TEMPLATE = CITY)

TOWNS                              //CATEGORY - ( SHOW ALL TOWNS ASSIGNED TO CITY SUBCATEGORY ABOVE ) (TEMPLATE = TOWNS)

------------Town       ///SUB CATEGORY OF TOWNS - ( SHOW ALL TOWN ASSIGNED TO TOWNS CATEGORY ABOVE ) (TEMPLATE = TOWN)

TYPES                                   /// CATEGORY - (OF SHOP TYPES, LIKE (RESTAURANT, CAFE BAR, HOTEL) )  (TEMPLATE = TYPES)

----------Type                            /// SUBCATEGORY OF TYPES  (TEMPLATE = TYPE)

SHOPS                                   /// CATEGORY

-----------RESTAURANT DESTROS  (LETS SAY THIS RESTAURANT BELONGS TO City = Chania, Towns = Kydonia, Town = Platanias, Type = Restaurant )

-----------CAFE BAR SUNLIGHT

-----------CLUB DANCE TIME

AND SO ON.........

So when a visitor come to site and clik CITIES he see each City that assign to category CITIES, the same with Towns he see each Town,

then when click the Town he see the each Type of Shops (Restaurants, Hotels, Bars etc..) and when he clik the type he is interesting lets say Hotels he then see the hotels that asigned to this City -> Towns -> Town-> Type.

How can i conect them together?

I follow this guide https://processwire.com/talk/topic/3579-tutorial-approaches-to-categorising-site-content/ so thats wy i come with this categories, i read a lot of simmilar posts in forum but there are to advance for me right now, so i am lost.

Thank you in advance!
Link to comment
Share on other sites

You will get better answers but here are some examples...All these assume these code is being called in another page other than the one you are after...(pages..)

$city = $pages->get("template=city, title=Doha");//get one specific city

$cities = $pages->get("template=cities, title=Cities")->children("limit=10");//get 10 of all cities
$cities = $pages->get("/path/to/cities/page/")->children("limit=10");//get 10 of all cities

If you are able to follow, have a look at the code in the Blog Profile (maybe even the Skyscrapers profile)

Edited by kongondo
  • Like 2
Link to comment
Share on other sites

It seems you are one the right track. I too struggled with structure and read the excellent guide written by kongondo you posted many times. My advise is to set up your site locally and start building it. Read the api and pay attention especially to the selectors. 

In my opinion Cities, Towns and Types will all be page reference fields. Create a template for you shops and add those three fields with to it. Then you can try testing out some selectors to query the information you are wanting. :)

Link to comment
Share on other sites

thank you guys i think i do good with your help, this is what i do

  • Home
    • Shops
      • Gatos // HAS 4 PAGE FIELDS (example) city=City1, town=Town2, village=Village1 , type=Restaurants
      • Ammos// HAS 4 PAGE FIELDS= city, town, village, type
    • Cities
      • City1 // DONT HAVE PAGE FIELDS
      • City2 // DONT HAVE PAGE FIELDS
      • City3 // DONT HAVE PAGE FIELDS
    • Towns
      • Town1 // HAS 1 PAGE FIELDS= city
      • Town2 // HAS 1 PAGE FIELDS= city
      • Town3 // HAS 1 PAGE FIELDS= city
    • Villages
      • Village1 // HAS 1 PAGE FIELDS= town
      • Village2 // HAS 1 PAGE FIELDS= town
      • Village3 // HAS 1 PAGE FIELDS= town
    • Types
      • Restaurants  // DONT HAVE PAGE FIELDS
      • Cafe Bars // DONT HAVE PAGE FIELDS

for every category i have a template:so page Cities have a template named cities now every children have a template named city 

the same i did for the rest of categories-childrens

the code i use to conect the pages is this:

THIS CODE IS FROM CITY PAGE (CHILD OF CITIES) AND WORKING FINE
<?php 
$city = $page->title; // I USED THIS VAR TO DISPLAY DYNAMIC THE NAME OF THE CITY FIELD BELLOW*
$vilages = $pages->find("template=town, city=$city"); // *HERE
foreach($vilages as $child){?>
<div class="col-md-4">
<div class="lbl">
<a href="<?php echo $child->url?>"><img src="<?php echo $child->imagecategory->url?>" alt="" class="fwimg"/><!--</a>-->
<div class="smallblacklabel"><?php echo $child->title?></div></a>
</div>
</div>
<?php } 
?>

THIS CODE IS FROM TOWN PAGE(CHILD OF TOWNS) AND WORKING FINE
<?php $town = $page->title; // I USED THIS VAR TO DISPLAY DYNAMIC THE NAME OF THE TOWN FIELD BELLOW* $towns = $pages->find("template=village, town=$town"); // *HERE foreach($towns as $child){?> <div class="col-md-4"> <div class="lbl"> <a href="<?php echo $child->url?>"><img src="<?php echo $child->imagecategory->url?>" alt="" class="fwimg"/><!--</a>--> <div class="smallblacklabel"><?php echo $child->title?></div></a> </div> </div> <?php }

and i use same code for other pages only change the template= and field= , this i explain for some others new to lovely processwire like me.

Now i need help!!

in template Type the way the website works is home page i see the cities then i click city and go to towns click town and go to villages click village and go types HERE IS MY QUESTION:: i dont know how to do this request:

$pages->find("template=shop, city=$city, town=$town, village=$village, types=$type");

how to get dynamic field values? when i click the type page eg. Cafe Bars to view the Shops on this type (remember the shops belong to village that belong to town and then to city) how to code so when i am in type page that i click i see the shops that belong to village that belong to town and then to city that i clicked to come here.
this is were i stack... Please help me..
 
thank you!! and i hope my explain is good
Link to comment
Share on other sites

I am sory so hard to explain in english i will try with url's


 


first page= http://localhost/allcr/en/cities


when i click to city 1 i go to:


second page= http://localhost/allcr/en/cities/city1/


when i click to town 1 i go to:


third page= http://localhost/allcr/en/towns/town1/


when i click to vilage 1 i go to:


fourth page= http://localhost/allcr/en/villages/village1/


when i click to type 1 i go to:


fifht page= http://localhost/allcr/en/types/restaurants/


 


when i click to restaurants i want to see restaurants that belong to the vilage i click something like this will explain the conection:


 


http://localhost/allcr/en/cities/city1/towns/town1/villages/village1/types/restaurants/restaurant1


 


i need this type of familly conection


 


i am sory i am in localhost i need to build it first and then go online


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...