Forum

Thread tagged as: Question

Limit option is being ignored?

Hi,

I'm having a problem with the limit option with perch_content_create.

The docs say: "Limit. Integer. The number of items to display when the region is output."

I only want to show 3 items from this multiple region, so the limit option seems like a good fit for this.

This is what I'm using:

perch_content_create('Featured List', ['template'=>'featured.html', 'limit'=>3, 'multiple'=>true]); 
perch_content_custom('Featured List');

In 'region options' I can see 'Number of items to display' is set to 3, as specified in perch_content_create

The limit option seems to be ignored. If I press 'save and add' five times, five items are output on the page.

Am I missing something?

Summary information

Perch Runway: 3.1.1, PHP: 7.1.12, MySQL: mysqlnd 5.0.12-dev - 20150407 - $Id: b396954eeb2d1d9ed7902b8bae237b287f21ad9e $, with PDO
Server OS: Darwin, cgi-fcgi
Installed apps: content (3.1.1), assets (3.1.1), categories (3.1.1)
App runtimes: <?php $apps_list = [ ];
PERCH_LOGINPATH: /perch
PERCH_PATH: /Users/stephen/Repositories/project/cms/perch
PERCH_CORE: /Users/stephen/Repositories/project/cms/perch/core
PERCH_RESFILEPATH: /Users/stephen/Repositories/project/cms/perch/resources
Image manipulation: GD
PHP limits: Max upload 32M, Max POST 32M, Memory: 128M, Total max file upload: 32M
F1: 3b606135b33e6a102526838f4152a807
Resource folder writeable: Yes
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
REQUEST_URI: /perch/core/settings/diagnostics/
DOCUMENT_ROOT: /Users/stephen/Repositories/project/cms
HTTP_HOST: project.local
Stephen Meehan

Stephen Meehan 4 points

  • 3 years ago

Hi Stephen

Wouldn't you need to put the limit on the perch_content_custom function? I believe that the perch_content_create function is a one time trigger to automatically create regions - useful for page templates. It's the perch_content_custom function doing the display work in your template.

Jon

Drew McLellan

Drew McLellan 2638 points
Perch Support

perch_content_custom() is for overriding those defaults and specifying your custom options. Use count on perch_content_custom() to retrieve however many items you want.

If you're using perch_content() the limit on the region will kick in.

Hi Jon / Drew

Thanks for the replies. I've switched to perch_content(), it's working as expected now.