GetFieldの 使用方法

(posted at: 2014-06-05)

GetField.tpl のパラメーターに関する記述の一部の自分用翻訳(内容は保証しません)。

&docid [ 整数 ]
値を得たいフィールドの ID値。
デフォルト:自分自身
&field [ 文字列 ]
内容を得たいフィールド名:
- フィールド名については、http://modxcms.com/the-document-object.html) を参照
デフォルト:'pagetitle'
&parent [ 0 | 1 ]
1 ならスニペットは親ドキュメントの値を返す。
デフォルト:0
&parentLevel [ 整数 ]
ドキュメントツリーにおいて、自分から何番目の親かを指定する:
- &parentLever=`0` - ドキュメントルートを返す
- &parentLever=`1` - 自分から1番めの親を返す
&topid [ 整数 ]
&parent で 1 をセットしたときに、ドキュメントツリーにおいて、最上位に据えたい親の id 値をセットする。
デフォルト:0(直接の親)

元ドキュメント

/* Parameters
----------------------------------------------- */

# $docid [ int ]
# ID of the document for which to get a field content.
# Default: current document

$gfIntDocId = (isset($docid)) ? $docid : $modx->documentIdentifier;

# $field [ string ]
# Name of the field for which to get the content:
# - any of the document object fields (http://modxcms.com/the-document-object.html)
# - template variable
# Default: 'pagetitle'

$gfStrDocField = (isset($field)) ? trim($field) : 'pagetitle';

# $parent [ 0 | 1 ]
# If set to 1, the snippet will return value for the document parent.
# Default: 0

$gfBoolParent = (isset($parent)) ? $parent : 0;

# $parentLevel [ int ]
# Specifies 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

$gfIntParentLevel = (isset($parentLevel) && is_int((int) $parentLevel)) ? $parentLevel : 0;

# $topid [ int ]
# Id of the topmost document in the document tree under which to search for a parent. Used only with $parent set to 1.
# Default: 0

$gfIntTopDocId = (isset($topid) && is_int((int) $topid)) ? $topid : 0;