(first posted: Aug 27, 2006)
(1868 Reads)
keywords: articles dynamic data
Permalink
Articles data and getall function
Important update:
I've submitted a patch to articles get.php and getall.php that resolves several of the discrepancies cited below, namely
- articles 'get' now supports the 'extra' arg, so it can retrieve hooked dd fields, using 'extra'=>'dynamicdata' (like in 'getall')
- articles 'get' now supports the 'fields' arg (like in 'getall')
- articles 'getall' now supports a 'wheredd' clause for selecting on dynamic data
Here's the bugzilla post for the patch
patch for articles userapi get.php
http://bugs.xaraya.com/show_bug.cgi?id=5925
patch for articles userapi getall.php
http://bugs.xaraya.com/show_bug.cgi?id=5926
The Articles module can do more with its built in data fields than it can with extended hooked in Dynamic Data fields.
- built in fields have a limited number of properties.
- DD fields have a full range of properties.
- to set validation on built in fields, click the field name (on the left)
- to set validation on dd fields, there's a "validation" link once you clicked "modify" dd
- articles "get" function is limited to the built-in fields, it cannot retrieve any hooked dd fields
- you must use articles "getall" function if you want any dd fields, using 'extra'=>array('dynamicdata')
- 'sort' arg only works on built-in fields
- 'where' clause arg only works on built-in fields
- search only works on built-in field (both in getall, and the search hook used by the Search module)
- conveniently, DD fields provide the raw data ($myfield) and the output processed data ($myfield_output) so you dont need to do that yourself
Some other hooked modules are more tightly integrated, namely categories, ratings, and hitcount. Read the comments at the top of getall.php for specific fields you can filter on.
If you need to filter articles on a DD value(s), here's how: First you get the dd objects that meet your criteria, extract the article id's from results, and then getall the articles.
<xar:set name="dditems">xarModApiFunc('dynamicdata','user','getitems', array('module'=>'articles', 'itemtype'=>'12', 'where'=>"year_founded eq 1996"))</xar:set>
<xar:if condition="!empty($dditems)">
<xar:set name="aids">array_keys($dditems)</xar:set>
<xar:set name="arts">xarModApiFunc( 'articles', 'user', 'getall', array('aids'=>$aids, 'extra'=>array('dynamicdata')))</xar:set>
</xar:if>
You need to check for empty $dditems, otherwise the getall will return all articles if the aids list is null.
There are no comments attached to this item.



