Child Pages in Sidebar

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
singhabhishek251
Forum Members
Forum Members
Posts: 38
Joined: Wed May 22, 2013 8:11 am

Child Pages in Sidebar

Post by singhabhishek251 »

I have this below code as User Defined Tag {sidemenu}
It is working fine on a previous website, but when I copied same in new install, then it is not accepting this UDT {sidemenu} after force submitting the pages are getting deformed.
can you help me get the error from here or other code to call child pages in sidebar. I am not good with Menu Manager, so any UDT or other solution than Menu Manager will help.

Code: Select all

global $gCms;
$manager =& $gCms->GetHierarchyManager();
$thisPage = $gCms->variables['page_name'];
$currentNode = &$manager->sureGetNodeByAlias($thisPage);

$nodes = $currentNode->getChildren();

if ($currentNode->hasChildren()) {
  echo '<h2 class="leftTitle">In this section:</h2><ul>';
  foreach ($nodes as $node) {
     $content= $node->getContent();
     $url = $content->GetURL();
    if ($url == "#") { /* section header has no link by default */
      $url = "index.php?page=".$content->Alias();
    }
    echo "<li><a href=\"".$url."\">".$content->MenuText()."</a> </li>";

  }
  echo "</ul>";

}
else if($currentNode->hasChildren()==false)
{
  $nodes = &$currentNode->getParentNode()->getChildren();
    echo '<h2 class="leftTitle">In this section:</h2><ul>';
  foreach ($nodes as $node) {
     $content= $node->getContent();
     $url = $content->GetURL();
    if ($url == "#") { /* section header has no link by default */
      $url = "index.php?page=".$content->Alias();
    }
    echo "<li><a href=\"".$url."\">".$content->MenuText()."</a> </li>";

  }
  echo "</ul>";
}
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Child Pages in Sidebar

Post by velden »

Change

Code: Select all

global $gCms;
to

Code: Select all

$gCms = cmsms();
And learn Menu Manager. Really.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Child Pages in Sidebar

Post by Rolf »

Code: Select all

{menu childrenof=$page_alias}
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
singhabhishek251
Forum Members
Forum Members
Posts: 38
Joined: Wed May 22, 2013 8:11 am

Re: Child Pages in Sidebar

Post by singhabhishek251 »

velden wrote:Change

Code: Select all

global $gCms;
to

Code: Select all

$gCms = cmsms();
And learn Menu Manager. Really.
I changed, but still it is not applying when I am writing {sidemenu} in template after saving the UDT, then it is not applying I mean to getting saved and after removing it is applying fine. There is no output.

I have used class in template as below, after removing this also nothing.
</__body id="{$page_alias}">
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Child Pages in Sidebar

Post by velden »

I'm sorry, I don't know why it doesn't work. Did not check the whole code.

Will not look into this further. Better invest your time learning Menu Manager. That has all those thing built in already.
singhabhishek251
Forum Members
Forum Members
Posts: 38
Joined: Wed May 22, 2013 8:11 am

Re: Child Pages in Sidebar

Post by singhabhishek251 »

Rolf wrote:

Code: Select all

{menu childrenof=$page_alias}
I tried this also but there is no output.
singhabhishek251
Forum Members
Forum Members
Posts: 38
Joined: Wed May 22, 2013 8:11 am

Re: Child Pages in Sidebar

Post by singhabhishek251 »

Thanks for all your help "velden", I understand that you may not give much time into individual issues.

Thanks for all you help, I found something with menu manager and it is working fine I hope. As I am able to see the output and now I will investigate how to customize the design of this output to make it look better.

Code: Select all

{menu template='simple_navigation.tpl' start_level='2' collapse='1'}
I hope others also can use this code.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Child Pages in Sidebar

Post by velden »

It's not about individual problems. It's about building your own Menu Manager in stead of using the excellent built-in version.

Have a look at the sample templates and read the modules help.

Note that you can 'Import' an sample template into the database (icon behind the templates). Give it a name and make it default (or use 'template=' parameter in {menu} call).

You can customize that template to suit your needs.
singhabhishek251
Forum Members
Forum Members
Posts: 38
Joined: Wed May 22, 2013 8:11 am

Re: Child Pages in Sidebar

Post by singhabhishek251 »

Thanks for the guideline velden, with individual issue I mean to say that you have to support a big community and help many others like me and giving much time for a small issue is definitely time consuming.

I will definitely play around with menu manager to learn now, only I was little concern about time for this because of lack of time as it was difficult to learn completely new thing in between some important work.
Post Reply

Return to “The Lounge”