Frank Vèssia Posted January 23, 2011 Share Posted January 23, 2011 I need to create profile pages o a website. A profile contains a field named country. When i create a new profile i want to have a select with all the countries i can choose. I saw i can have this linking pages and choosing a page with a select but i cannot create a page for every country. Is there a better solution? Thanks Link to comment Share on other sites More sharing options...
Adam Kiss Posted January 23, 2011 Share Posted January 23, 2011 I don't think there is currently better solution Why can you create page for every country? with API, you can automatize it, i.e. create template, which parses some CSV and adds children to a hidden page, call it once and you're all done. Is there any problem with this? Link to comment Share on other sites More sharing options...
Frank Vèssia Posted January 23, 2011 Author Share Posted January 23, 2011 good, i didn't think about this, however i think creating hidden pages is not a clear solution for this kind of purpose but i will try. Link to comment Share on other sites More sharing options...
Adam Kiss Posted January 23, 2011 Share Posted January 23, 2011 Actually, hidden pages are ideal. Just put them into root next to 404 and other hidden pages. Have one root with url '/countries/' and in your template, you'll even have quite self-explaining code like echo '<select>'; foreach ($pages->get('/countries/')->children() as $country) echo "<option value='{$country->name}'>{$country->title}</option>"; echo '</select>'; note: this is considering you left original 'title' field as name for that country this all is good, when you don't wish to have any content for countries. If you do, reconsider placement of 'countries' parent to be better placed in your site structure More information about data import automation: How do I import lots of data into pages? Link to comment Share on other sites More sharing options...
ryan Posted January 23, 2011 Share Posted January 23, 2011 I agree with what Adam has recommended here. In my sites, I usually create a /config/ page that is hidden, and then place all my selectable pages under there, like /config/countries/, /config/states/, etc. Note that you don't want your actual 'country' pages to be hidden, just the main '/config/' (or /countries/ if you are using that). The advantage of keeping these as pages is that it's easy to add/edit them, and it's easy to setup a template that could list everything in a particular country, for example. Viewing /countries/france/ can produce a list of all pages that have it selected... a huge benefit. If your sites have highly relational structures like this (with indexable URLs) your search engine performance will benefit greatly, and it's just really useful to have for may reasons, taking almost no work on your part. Link to comment Share on other sites More sharing options...
Frank Vèssia Posted January 24, 2011 Author Share Posted January 24, 2011 Thanks. i've checked the demo sample and i agree with this solution, at the first time it was a little bit strange but now i understand the structure of PW. Link to comment Share on other sites More sharing options...
Adam Kiss Posted January 24, 2011 Share Posted January 24, 2011 As I said in the other question in modules – it might be sometimes hard to wrap your head around possibility of anything, but that's how it works Adam 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