Page 1 of 1

[Solved] Inactive page details showing when they need to be hidden.

Posted: Fri Dec 19, 2008 5:13 pm
by Weon
Hi there.

In this post I got some great help from people showing me how to display a blob of copy from each child page of the current page.  The code went like this:

Code: Select all

global $gCms;

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

$nodes = $currentNode->getChildren();

if ($currentNode->hasChildren()) {
  foreach ($nodes as $node) {

     $content= $node->getContent();

$page_alias = $content->Alias();
$cgsimple = $smarty->get_template_vars('cgsimple');
$Sum = $cgsimple->get_page_content($page_alias, 'extra1');

     $url = $content->GetURL();
    if ($url == "#") { /* section header has no link by default */
      $url = "index.php?page=".$content->Alias();
    }

    echo "<h3><a href=\"".$url."\"  title=\"".$content->TitleAttribute()."\">".$content->MenuText()."</a></h3>\n";
    echo "<p>".$Sum." <a href=\"".$url."\"  title=\"".$content->TitleAttribute()."\">[read more...]</a></p>\n";

  }
}
However, this will display the details of pages that are set to inactive as well as those that are active.

I have been playing with the code but my very limited knowledge has failed to come up with a solution. Basically I need to know how to check the statud and if the page isn't active then I need it to be skipped.

I have been searching these forums using words like active, inactive, page, status, isactive but am drawing a blank.

Please can someone help?

Also, if someone can pont me to some kind of Codex for CMSMS that would be great! There is one for WordPress that I can go to and just do a search for any tag or attirbut that I come across and then learn about it!

Re: Inactive page details showing when they need to be hidden.

Posted: Fri Dec 19, 2008 5:35 pm
by Weon
OK, finally managed to find something in this thread that helped me achieve what I was trying to do.

So here is my code now with the new IF statement highlighted (had to use QUOTE to get the bold to work!):
global $gCms;

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

$nodes = $currentNode->getChildren();

if ($currentNode->hasChildren()) {
  foreach ($nodes as $node) {
     $content= $node->getContent();
       if ($content->Active()){

$page_alias = $content->Alias();
$cgsimple = $smarty->get_template_vars('cgsimple');
$Sum = $cgsimple->get_page_content($page_alias, 'extra1');

     $url = $content->GetURL();
    if ($url == "#") { /* section header has no link by default */
      $url = "index.php?page=".$content->Alias();
    }

    echo "TitleAttribute()."">".$content->MenuText()."\n";
    echo "".$Sum." TitleAttribute()."">[read more...]\n";

   }
  }
}
So sorted eventually.  Elementary to most but tricky for me.

So, about that Codex...