I am changing my non-modx design to a modx template. Not a big deal... but... since I have a second menu on the right created with wayfinder which only shows links to pages with parent 48. But my original design was also driven by a small mysql query to see how many items there were on the second menu. This I needed to get the min-height correct for my css. Now I tried the query in a snippet but that failed...
The query is the following:
<?php require_once(’Connections/MODX.php’);
mysql_select_db($database_MODX, $MODX);
$query_modxrijen = "SELECT * FROM modx_site_content WHERE modx_site_content.parent = 48";
$modxrijen = mysql_query($query_modxrijen, $MODX) or die(mysql_error());
$row_modxrijen = mysql_fetch_assoc($modxrijen);
$totalRows_modxrijen = mysql_num_rows($modxrijen);
echo $totalRows_modxrijen
?>
I used the echo because I assumed that it would echo the result in my css part of my template. But it did not...
css part:
<style type="text/css">
<!--
#main {
min-height: [[collectionrows]] px;
}
-->
</style>
Now is my question... How can I get a row count from the modx database to isert in my template...
Thanks,
Bram
you can try this:
<?php
$id=48;
$depth=1;
$childids=$modx->getChildIds($id, $depth);
return count($childids);
?>
see also the wiki-api-pages:
http://wiki.modxcms.com/index.php/Category:API
Thank you! With a little tweaking it works! now I can start with the content!
Bram