renobird Posted November 12, 2012 Share Posted November 12, 2012 I have a repeater that generates a list of links. The list could get pretty long (40+). I'd like to break that up into 2 equal (or roughly equal) columns, but I can't get my head around how to do it with repeaters. I'm trying this (which isn't working). $p = $pages->get("/sponsors/"); $len = count($p->links); $col_a = array_slice($p->links, 0, $len / 2); $col_b = array_slice($p->links, $len / 2); var_dump() for $col_a and $col_b returns NULL. Link to comment Share on other sites More sharing options...
apeisa Posted November 12, 2012 Share Posted November 12, 2012 http://processwire.c...pi/arrays/page/ array_slice no good. Try $p->links->slice() Actual array_slice isn't working because PageArray is not actually a php array, it's an object. 1 Link to comment Share on other sites More sharing options...
renobird Posted November 12, 2012 Author Share Posted November 12, 2012 Hmm, OK, tried that and got: Recoverable Fatal Error Argument 1 passed to RepeaterPageArray::__construct() must be an instance of Page, none given, called in $p = $pages->get("/sponsors/"); $len = count($p->links); $col_a = $p->links->slice(0, $len / 2); Link to comment Share on other sites More sharing options...
apeisa Posted November 12, 2012 Share Posted November 12, 2012 Ok, it might be that repeater has it's own RepeaterPageArray. Not time to see source if there is slice available, but you can always loop through the links and put them into two different arrays. 1 Link to comment Share on other sites More sharing options...
renobird Posted November 12, 2012 Author Share Posted November 12, 2012 you can always loop through the links and put them into two different arrays. OK, I'll try that route. Thanks Apeisa. Link to comment Share on other sites More sharing options...
Soma Posted November 12, 2012 Share Posted November 12, 2012 RepeaterPageArray extends PageArray so it should work. Link to comment Share on other sites More sharing options...
Soma Posted November 12, 2012 Share Posted November 12, 2012 Hmm, OK, tried that and got: Recoverable Fatal Error Argument 1 passed to RepeaterPageArray::__construct() must be an instance of Page, none given, called in $p = $pages->get("/sponsors/"); $len = count($p->links); $col_a = $p->links->slice(0, $len / 2); That error is strange as if it tries to create new RepeaterPageArray and nothing to do with slice(start,end)... Might be a bug. Link to comment Share on other sites More sharing options...
Marty Walker Posted November 13, 2012 Share Posted November 13, 2012 I know it's not 'clean' but you could do it with this: http://www.madeincima.it/en/articles/resources-and-tools/easy-list-splitter-plugin/ Link to comment Share on other sites More sharing options...
renobird Posted November 13, 2012 Author Share Posted November 13, 2012 Thanks Marty — I might go a JS route temporarily to get the site up, but now that I'm on this I really want to figure it out. Link to comment Share on other sites More sharing options...
ryan Posted November 14, 2012 Share Posted November 14, 2012 That error is strange as if it tries to create new RepeaterPageArray and nothing to do with slice(start,end)...Might be a bug. This is a bug. I'd actually fixed this one a week or two ago on the dev branch but hadn't carried it over to master. I just put it on master so it should be fixed now. 1 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