Jump to content

Recommended Posts

Posted

Hi

I'm unsure why my code below doesn't limit the results to 3 as specified.

I have a Repeater Matrix (pro fields) on my page with 10 items and I want to echo out slides 2,3,4 only 

IE Start from the second slide and limit to the next 3

		$items = $page->matrix_slider('start=1,limit=3');
		foreach($items as $slide) {
        echo "
				<div class='uk-width-1-1 uk-width-1-3@s'>
				<div class='desk-wrap uk-text-left'>
					
					<a href='{$slide->url}'><img src='{$slide->images->first()->size(640,320)->url}'></a>
					<div class='desk-wrap-content'>
					<h4><a href='{$slide->url}'>{$slide->title}</a></h4>
					{$slide->body_mini}<br/>
					<a href='{$slide->url}' class='uk-button uk-button-primary'>Read more</a>
					</div>
				</div>
				</div>

Thanks

 

 

Posted
3 hours ago, Peter Knight said:

$items = $page->matrix_slider('start=1,limit=3');

There is no method call on the repeater matrix field value there - I think you meant to include ->find():

$items = $page->matrix_slider->find('start=1,limit=3');

That should work.

  • Like 3
Posted
59 minutes ago, Robin S said:

There is no method call on the repeater matrix field value there - I think you meant to include ->find():


$items = $page->matrix_slider->find('start=1,limit=3');

That should work.

That was it. Thanks ?

Posted
3 hours ago, dragan said:

Try to use slice()


$matrix = $pages->get(11203)->my_matrix;
$items = $matrix->slice(1, 3);

 

That's pretty cool. And new to me too. I'll try that tomorrow and file under 'new stuff'. In the meantime, Robin's observation had me back on track.

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