Get Page level and output something based on this level

Sometimes there is a need to output specific content or blocks based on current level of the Page.
Here comes this UDT to help.

Go to Extensions -> User Defined Tags and create new UDT called level copy the code below.

$gCms = cmsms();
$hierarchy = count(explode(".", $gCms->variables['friendly_position']));

$smarty->assign('level', $hierarchy);

If you call this UDT with {$level} in your page or template you will see output 1 for first level (parent) pages or 2 for sublevel and so on.
Now if you would like to do some action or specific output based on current level of the page simply use this UDT as following.

{*first we need our UDT*}
{*now do something*}
{if ($level gte '2')}
    Some action or output

In the above example we used our UDT {level} first to get current page level, and we output something if level is greater or equal 2, you could also use eq if you only want your output on level 1,2 or 3 or whatever number you enter.