<?php

/**
 * Snippet to get a parent of the current page.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @package clearFusionCMS\snippet\parent
 * @copyright Copyright (c) 2012 - 2013 clearFusionCMS. All rights reserved.
 * @link http://clearfusioncms.com
 */

/* @var $tplEngine cfTemplateEngine */
$controller = $tplEngine->controller;

$depth = isset($depth) ? $depth : 0;

if($depth) {
	$path = $controller->content->getPath($controller->pageData['id']);
	echo ($depth && isset($path[$depth - 1])) ? $path[$depth - 1]['id'] : '0';
}
else
	echo $controller->content->getParent($controller->pageData['id']);
