Jump to content

Recommended Posts

Posted

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.

Posted

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);
Posted

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.

  • Like 1
Posted

you can always loop through the links and put them into two different arrays.

OK, I'll try that route. Thanks Apeisa. :)

Posted

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.

Posted

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. :)

Posted
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

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
  • Recently Browsing   0 members

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