getField 1.2.2
Returns any field or template variable from any document or any of its parents.
Submitted: Jul 18th 2006 | License: LGPL | Downloads: 1473
Description
Returns any document field (id, title, alias, etc.) or any template variable for:
* any document
* any of its parents up to a specified number of levels (eg. 2 levels up)
* its ultimate parent (right under the document tree root)
Uses idea of getDoc by Mark with modification from luke.stokes
Instructions
# $docid [ int ]
# Document for which to get a field.
# Default: current document
# $field [ string ]
# Field to get for the document:
# - any of the document object fields
# (http://modxcms.com/the-document-object.html)
# - template variable assigned to the document
# Default: 'pagetitle'
# $parent [ 0 | 1 ]
# $parent = 1 - returns the field for the parent of the document.
# Default: 0
# $parentLevel [ int ]
# How high in the document tree to search for the parent of the document?
# - $parentLevel = 0 - returns the ultimate parent (right under site root)
# - $parentLevel = 1 - returns the direct parent
# Default: 0
# $topid [ int ]
# Id of the topmost document in the document tree under which to search for a
# parent.
# Default: 0
Updates
# 1.2.2
- a quick fix to "Cannot redeclare function"
# 1.2.1
- reworked fetching of template variable to enable output of widget
# 1.2
- reworked fetching of template variable value to get INHERITED value
- removed defaulting to 'pagetitle' when $field not found; this is due to fact that tv can have empty value