KentBrockman Posted April 3, 2013 Share Posted April 3, 2013 Hey there,currently we are developing our first project with Processwire. Coming from MODX Revolution we are absolutely impressed by the simplicity and power of processwire. ...and the speed of the Admin All things are running great, except of one requirement. We got stuck on building a navigation by ID. Means we want to get a list of defined pages.For example: "Show a list of pages with the ids 1, 1001, 1003, 1007" $homepage = $pages->get("id=1,1001,1003"); Everything we tried (find, array and so on) didn't work.What are we doing wrong?Or is there a other "best-practice" to build a list like this?Thank you so much for your support and all your efforts on this great project! Link to comment Share on other sites More sharing options...
Wanze Posted April 4, 2013 Share Posted April 4, 2013 Hi KentBrockman, welcome to ProcessWire. There are two reasons why it doen't work: 1) $pages->get will return only one page. If you want multiple pages, you have to use $pages->find which returns a PageArray. 2) You need the OR selector: id=1|1001|1003 So you could try this: $myPages = $pages->find("id=1|1001|1003"); foreach ($myPages as $p) { echo $p->title; } To make this more dynamic, you could add a checkbox field to the templates of pages you want to list, let's call the field "show_nav". Then check the checkbox on the pages you want to appear and update the code: $myPages = $pages->find("show_nav=1"); Of course this is only one possible solution out of 100 (infinity), with ProcessWire you have no limits 3 Link to comment Share on other sites More sharing options...
diogo Posted April 4, 2013 Share Posted April 4, 2013 100 sounds like a limit to me... edit: another option would be to have a hidden page called "navigation" with a pageFieldType multiple in it where you could list the pages. 97 to go 3 Link to comment Share on other sites More sharing options...
KentBrockman Posted April 4, 2013 Author Share Posted April 4, 2013 Wanze,thank you for your fast answer to our question.Your solution works right "out-of-the-box".By looking at it again ("id=1,1001,1003") is truly embarrassing. Grüße aus Deutschland. 1 Link to comment Share on other sites More sharing options...
kongondo Posted April 4, 2013 Share Posted April 4, 2013 KentBrockman, Welcome to ProcessWire! /kongondo Link to comment Share on other sites More sharing options...
k07n Posted April 4, 2013 Share Posted April 4, 2013 Dumb question here: Where can I find ID of the page in the backend? Link to comment Share on other sites More sharing options...
arjen Posted April 4, 2013 Share Posted April 4, 2013 Look in the url of the browser while editting a page: /processwire/page/edit/?id=1007 1 Link to comment Share on other sites More sharing options...
diogo Posted April 4, 2013 Share Posted April 4, 2013 Or hover the edit link on the tree and see it on the status bar of the browser. 1 Link to comment Share on other sites More sharing options...
SiNNuT Posted April 4, 2013 Share Posted April 4, 2013 Dumb question here: Where can I find ID of the page in the backend? Or look in the status bar while hovering a page edit link, this can be quicker diogo - resident forum ninja - strikes, once again 2 Link to comment Share on other sites More sharing options...
diogo Posted April 4, 2013 Share Posted April 4, 2013 eheh Link to comment Share on other sites More sharing options...
k07n Posted April 4, 2013 Share Posted April 4, 2013 Or look in the status bar while hovering a page edit link, this can be quicker diogo - resident forum ninja - strikes, once again hint: if you know the answer, just click "Post" and then edit post 2 Link to comment Share on other sites More sharing options...
arjen Posted April 4, 2013 Share Posted April 4, 2013 Hover works too, but most of the time I'm fighting with the mouse to get a tooltip Link to comment Share on other sites More sharing options...
k07n Posted April 8, 2013 Share Posted April 8, 2013 Hover works too, but most of the time I'm fighting with the mouse to get a tooltip /wire/modules/Process/ProcessPageList/ProcessPageList.js function listChild(child) { //bla-bla-bla .attr('title', child.path) //bla-bla-bla change to something like: .attr('title', child.path + ' id' + child.id) it will show ID on tooltip. And the question =) How made this not by hacking "core"? Link to comment Share on other sites More sharing options...
diogo Posted April 8, 2013 Share Posted April 8, 2013 hint: if you know the answer, just click "Post" and then edit post Ninjas don't need this Link to comment Share on other sites More sharing options...
Soma Posted April 8, 2013 Share Posted April 8, 2013 Only the green thing. Link to comment Share on other sites More sharing options...
pwired Posted April 8, 2013 Share Posted April 8, 2013 Look in the url of the browser while editting a page: Or hover the edit link on the tree and see it on the status bar of the browser. I'm in the interesting part of the forum. This is very useful to know and to work with. Link to comment Share on other sites More sharing options...
Soma Posted April 8, 2013 Share Posted April 8, 2013 A good developer knows every ID of his pages by memory. 5 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