Jump to content

Repeater (slice long list into 2)


renobird
 Share

Recommended Posts

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

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

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

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.

  • Like 1
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...