huseyin Posted June 9, 2019 Share Posted June 9, 2019 Hello, I am working on my first PW project (this is also my first post here) We are a 5 person web design and service company in Turkey. The project is a City Portal with News, Events, Company Directory and Classified Ads. Which one of the following is better for performance? Why i am asking this : Using "pages->find" seems to me like a MySql query and using " $data->find" seems to work on already requested data and no MySql request. I dont know how this works in PW. 1-) $data = pages->find("template=news | template=events | template=directory | template=ads"); $news = $data->find("template=news"); $events= $data->find("template=events"); $directory = $data->find("template=directory"); $ads = $data->find("template=ads"); 2-) $news = pages->find("template=news"); $events = pages->find("template=events"); $directory = pages->find("template=directory"); $ads = pages->find("template=ads"); My second question; This project will cover multiple cities. The website visiter will be forced to select a city and this selection will be stored in a cookie for lates visits. The web site should only load content for the selected city Is there any tutorial for such category handling or could anyone give me a short explanation to direct me to the right path. If there is no simple general filter trick so do i need to add a city filter to any find()? Thank you. Link to comment Share on other sites More sharing options...
wbmnfktr Posted June 9, 2019 Share Posted June 9, 2019 52 minutes ago, huseyin said: $data = pages->find("template=news | template=events | template=directory | template=ads"); $news = $data->find("template=news"); $events= $data->find("template=events"); $directory = $data->find("template=directory"); $ads = $data->find("template=ads"); This approach seems totally fine. You could speed things up using $cache or even ProCache. Depending on the overall setup one thing might work better than the other. To be honest... build your structure, build up your content and when you reach 100-200 news/events/whatever type of content try playing around with different settings. Do it again and again. Always have a DEV environment to test those things. In most cases there is more than one way to get things done in ProcessWire. At first one approach seems to work fine but later on with more content and users another might work way better. I find myself quite often in this situation and rework things in projects after a while because of things and the amount of content changes. 58 minutes ago, huseyin said: This project will cover multiple cities. The website visiter will be forced to select a city and this selection will be stored in a cookie for lates visits. The web site should only load content for the selected city My opinion on this: Don't force them. Give them the option to choose what they want. Offer a nice "The last time you watched CITY. Go this way to get all the latest news for CITY." You never know why someone visited a particular city. Maybe just for interest or by accident. 1 hour ago, huseyin said: Is there any tutorial for such category handling or could anyone give me a short explanation to direct me to the right path. If there is no simple general filter trick so do i need to add a city filter to any find()? Yet again there is no real this is the best option to do this answer. In your case you might want to look at the page reference field and take a look at this post about categorising content and this post about getting references in different ways. You can also try the skyscraper demo @ryan did a while back. He is handling a lot of data and references there as well. This version of Skyscraper profile works with the latest ProcessWire verion. 3 Link to comment Share on other sites More sharing options...
huseyin Posted June 10, 2019 Author Share Posted June 10, 2019 Thank you for your answer. Link to comment Share on other sites More sharing options...
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