Active
Project:
Feeds QueryPath Parser
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
17 Sep 2011 at 09:18 UTC
Updated:
18 Sep 2011 at 10:17 UTC
I'm developing against a service that's returning >3,000 items. For dev purposes, I'd like to limit the number of items returned. I've added a setting for item count.
In sourceForm()
$form['querypath']['count'] = array(
'#type' => 'textfield',
'#title' => t('Count'),
'#description' => t('How many items to return, 0 for all items'),
'#default_value' => isset($source_config['count']) ? $source_config['count'] : '0',
);
and
public function configDefaults() {
return array(
'context' => '',
'count' => 0, // jh added
'sources' => array(),
'debug' => array(),
'attrs' => array(),
'rawXML' => array(),
);
}
In parse(), set $count =0 before the foreach ($context as $item) { loop, and before the end of the loop:
$count++;
if (!empty($this->source_config['count']) && $count >= $this->source_config['count']) {
break; // Abandon loop if we have sufficient items
}
Comments
Comment #1
jonathan_hunt commentedDiff for above