Closed (fixed)
Project:
Services
Version:
7.x-3.0
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
23 Oct 2013 at 08:47 UTC
Updated:
24 Oct 2013 at 03:43 UTC
i'm developing a mobile apps call the drupal service, i'want to get paged nodes of relative taxonomy_term, selectNodes seems can help
http://mydomain/my_services/taxonomy_term/selectNodes/
i've tried this parameter (tid=66&pager=1&page=1&limit=0,1) but only 0 nodes to be selected, seems the comma got trimed
But how do i call page 2 of the nodes of the taxonomy_term (suppose 25 nodes per page)?
i looked the source code (taxonomy_resources.inc) but still don't have idea to do ,
function taxonomy_service_select_nodes($tid = '', $pager, $limit, $order) {
$result = taxonomy_select_nodes($tid, (bool)$pager, $limit, $order);
foreach ($result as $nid) {
$node = node_load($nid);
if ($uri = services_resource_uri(array('node', $nid))) {
$node->uri = $uri;
}
$nodes[] = $node;
}
if (empty($nodes)) {
return services_error(t('No nodes were found with tid @tid', array('@tid' => $tid)), 404);
}
return $nodes;
}'actions' => array(
'selectNodes' => array(
'file' => array('type' => 'inc', 'module' => 'services', 'name' => 'resources/taxonomy_resource'),
'help' => t('This method returns all nodes with provided taxonomy id.'),
'access arguments' => array('access content'),
'callback' => 'taxonomy_service_select_nodes',
'args' => array(
array(
'name' => 'tid',
'type' => 'string',
'description' => t('The vocabulary ids to retrieve, separated by comma.'),
'source' => array('data' => 'tid'),
'optional' => FALSE,
),
array(
'name' => 'pager',
'type' => 'int',
'description' => t('Whether the nodes are to be used with a pager (the case on most Drupal pages) or not (in an XML feed, for example).'),
'source' => array('data' => 'pager'),
'optional' => TRUE,
'default value'=> TRUE,
),
array(
'name' => 'limit',
'type' => 'int',
'description' => t('Maximum number of nodes to find.'),
'source' => array('data' => 'limit'),
'optional' => TRUE,
'default value'=> FALSE,
),
array(
'name' => 'order',
'type' => 'int',
'description' => t('The order clause for the query that retrieve the nodes.'),
'source' => array('data' => 'order'),
'optional' => TRUE,
'default value'=> array('t.sticky' => 'DESC', 't.created' => 'DESC'),
),
),The callback function
function taxonomy_service_select_nodes($tid = '', $pager, $limit, $order) {
$result = taxonomy_select_nodes($tid, (bool)$pager, $limit, $order);
foreach ($result as $nid) {
$node = node_load($nid);
if ($uri = services_resource_uri(array('node', $nid))) {
$node->uri = $uri;
}
$nodes[] = $node;
}
if (empty($nodes)) {
return services_error(t('No nodes were found with tid @tid', array('@tid' => $tid)), 404);
}
return $nodes;
}
Comments
Comment #0.0
hkvega01 commentedtypo
Comment #1
marcingy commentedSupport requests are never critical
Comment #2
hkvega01 commentedpost)
The url link should be
http://domainABC.com/my_services/taxonomy_term/selectNodes?page=1
parameter:
tid=1
problem fixed.
Comment #3
marcingy commentedComment #3.0
marcingy commentedAdd the parameter test.