wrong url in page-list - FIXED

Permalink
FIXED

Hi.

I'm trying to build a page-list in 5.6 with a custom attribute, it works fine except the url. It does not output the url of the page it should like to but it outputs the current url of the page. How can I make so that it will generate the correct url for each link in the page-list?

Thanks!

<?php
defined('C5_EXECUTE') or die(_("Access Denied."));
$textHelper = Loader::helper("text");
if (count($cArray) > 0) { ?>
<?php
for ($i = 0; $i < count($cArray); $i++ ) {
   $cobj = $cArray[$i];
   $url = $nh->getLinkToCollection($page);
   $title = $cobj->getCollectionName();
   $target = empty($target) ? '_self' : $target;
   $footer_item = $cobj->getAttribute('footer_menu');
   ?>
   <?php  if ($meet_team == '1') { ?>
      <ul class="ccm-page-list-title">
         <li><a href="<?php echo $url ?>" target="<?php echo $target ?>"><?php echo $title ?></a></li>


I fixed it by using those code:

<?php
defined('C5_EXECUTE') or die("Access Denied.");
$rssUrl = $showRss ? $controller->getRssUrl($b) : '';
$th = Loader::helper('text');
//$ih = Loader::helper('image'); //<--uncomment this line if displaying image attributes (see below)
//Note that $nh (navigation helper) is already loaded for us by the controller (for legacy reasons)
?>
<div class="ccm-page-list">
<ul class="ccm-page-list-title">
   <?php foreach ($pages as $page):
      // Prepare data for each page being listed...
      $title = $th->entities($page->getCollectionName());
      $url = $nh->getLinkToCollection($page);
      $target = ($page->getCollectionPointerExternalLink() != '' && $page->openCollectionPointerExternalLinkInNewWindow()) ? '_blank' : $page->getAttribute('nav_target');
      $target = empty($target) ? '_self' : $target;