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

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
Weon
Forum Members
Forum Members
Posts: 23
Joined: Sun Dec 07, 2008 10:42 am

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

Post 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!
Last edited by Weon on Fri Dec 19, 2008 5:46 pm, edited 1 time in total.
Weon
Forum Members
Forum Members
Posts: 23
Joined: Sun Dec 07, 2008 10:42 am

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

Post 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...
Last edited by Weon on Fri Dec 19, 2008 5:45 pm, edited 1 time in total.
Post Reply

Return to “Developers Discussion”