Need to echo a count of the number of child pages in a site - is there an add-on for that?

I'm trying to create a block which will display a count of the pages that are child to another page within my site. The idea is that pages will be created for Job Vacancies on my website and I would like to display the current number of vacancies in a block on my homepage. something like... "There are [count] Vacancies"

Any ideas how I can do this with ad-ons in the marketplace?

I have beginner's programming experience and I've never created my own block. I've read the 'building blocks' guide... the documentation, but I'm still not certain what to edit, although I think the 'Get number of children' method can be used to fetch the number of child pages to another page??


Can anyone point me in the direction of an add-on that I can use to do this or give me a hint how to edit the 'basic test' block so it gets the number of child pages and echoes a count of these pages?

much appreciated

View Replies: View Best Answer
JohntheFish replied on at Permalink Reply
Magic data has a symbol for that. (I think - am away from my desk at the moment, will check later). It is also very easy to add custom symbols.
pmlmedia replied on at Permalink Reply
Thanks Jon - I though Magic Data might be able to do this but was not certain. I will investigate - thanks again.
JohntheFish replied on at Permalink Best Answer Reply 1 Attachment
For any other Magic Data users reading this, the body of the symbol is:
Loader::library('magic_data/symbol_plugin_base', 'jl_magic_data');
class MagicDataSymbolsNumChildren extends MagicDataSymbolPluginBase {
  public function getSymbol() {
    return 'NUM_CHILDREN';
  public function getDescription() {
    return t('Given a page, returns the number of child pages.');
  public function getHelp() {
    return t('Tries to find the result of preceding symbols as a path or Page ID, returning the number of children or null. <br><br>For example: <i>\'SET /about NUM_CHILDREN\'</i>.');
  public function processSymbol ($id, &$params){
    Loader::library('page_extraction', 'jl_magic_data_symbols1');
    $pix_obj = new PageExtraction();

(full symbol attached).

This can safely be added directly to the symbols package and will be included next time I update the package.