Gets document parent ID(s) of the required level.
- PHP >= 5.6
- (MODX)EvolutionCMS >= 1.1
- (MODX)EvolutionCMS.libraries.ddTools >= 0.60
Just run the following PHP code in your sources or Console:
//Include (MODX)EvolutionCMS.libraries.ddInstaller
require_once(
$modx->getConfig('base_path') .
'assets/libs/ddInstaller/require.php'
);
//Install (MODX)EvolutionCMS.snippets.ddGetParentId
\DDInstaller::install([
'url' => 'https://github.com/DivanDesign/EvolutionCMS.snippets.ddGetParentId',
'type' => 'snippet'
]);- If
ddGetParentIdis not exist on your site,ddInstallerwill just install it. - If
ddGetParentIdis already exist on your site,ddInstallerwill check it version and update it if needed.
- Snippet name:
ddGetParentId. - Description:
<b>1.4</b> Gets document parent ID(s) of the required level.. - Category:
Core. - Parse DocBlock:
no. - Snippet code (php): Insert content of the
ddGetParentId_snippet.phpfile from the archive.
- Create a new folder
assets/snippets/ddGetParentId/. - Extract the archive to the folder (except
ddGetParentId_snippet.php).
-
id- Desctription: Document Id.
- Valid values:
integer - Default value:
[*id*](current document)
-
level- Desctription: Parent level.
- Valid values:
1— the immediate parent2— the parent of the immediate parent-1— the last parent-2— the parent before the lastinteger— etc
- Default value:
1
-
result_itemsNumber- Desctription: The number of parents that will be returned.
- Valid values:
integer'all'
- Default value:
1
-
result_itemTpl- Desctription: Template for output.
Empty items after parsing the template will be ignored (you can calling third-party snippets in the template and set your own display conditions).
Available placeholders:[+id+]— Parent ID.
- Valid values:
stringChunkNamestring— use inline templates starting with@CODE:
- Default value:
'@CODE:[+id+]'
- Desctription: Template for output.
-
result_itemsGlue- Desctription: The string that combines items while rendering.
- Valid values:
string - Default value:
''
-
result_toPlaceholder- Desctription: Returns value to the placeholder.
- Valid values:
01
- Default value:
0
-
result_toPlaceholder_name- Desctription: Placeholder name.
- Valid values:
string - Default value:
'ddParent'
//Include (MODX)EvolutionCMS.libraries.ddTools
require_once(
$modx->getConfig('base_path') .
'assets/libs/ddTools/modx.ddtools.class.php'
);
//Run (MODX)EvolutionCMS.snippets.ddGetParentId
\DDTools\Snippet::runSnippet([
'name' => 'ddGetParentId',
'params' => [
'level' => -1
]
]);