I used the following snippet to count the number of published children of a resource on one webpage. After a recent update from Evo 3.1.9 this snippet stopped working with the error (in logs):
« Evolution CMS Parse Error »
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in field list is ambiguous (SQL: select `id` from `modx_site_content` left join `modx_document_groups` on `modx_document_groups`.`document` = `modx_site_content`.`id` where `modx_site_content`.`parent` = 6 and `modx_site_content`.`published` = 1 and `modx_site_content`.`deleted` = 0 and (`privateweb` = 0) order by `menuindex` asc)
Code of the snippet
<?php
/*
==================================
ChildrenCount Snippet
=================================
<strong>0.2</strong> Returns the number of published children of a parent
Author: Thomas Steinberg (Mazso)
Version: 0.2
for MODx version 0.95+
Date of release: 2007-11-22
License: GNU General Public License (GPL) (http://www.gnu.org/copyleft/gpl.html)
----------------------------------
Installation
In the MODx manager, go to Resources > Snippets and create new snippet. Name it "ChildrenCount", copy and paste the contents of GetField.tpl, and save.
Refer to documentation for usage instructions.
----------------------------------
Parameters
$parentId [ int ]
optional
ID of the parent(s); if not set, ChildrenCount uses the ID of the current parent. You can use several comma seperated IDs.
__________________________________
Snippet call
[[ChildrenCount]]
[[ChildrenCount? &parentId=`your ID`]]
__________________________________
Example Usage
In combination with PHx: when the number of children is greater than 3 show {{your_chunk}}
[+phx:if=`[[ChildrenCount]]`:gt=`3`:then=`{{your_chunk}}`:else=` `+]
*/
$ccParentId = isset($parentId) ? $parentId : $modx->documentIdentifier;
$ccParentId = explode(",",$ccParentId);
$ccChild = 0;
foreach ($ccParentId as $ccValue) {
$ccChild = $ccChild + count($modx->getDocumentChildren($ccValue, 1, 0,'id'));
}
echo $ccChild;
Does anybody know what changed and how to fix this?