Pagelist custom attributes

Permalink
Hi, I can't figure out what I am doing wrong with my custom Pagelist template.

I have made custom attribute and can load them on the page. But they are not working in the pagelist. I have tried using $cobj but gives me the following error: "Call to a member function getCollectionAttributeValue() on array".

<?php
defined('C5_EXECUTE') or die("Access Denied.");
$th = Loader::helper('text');
$c = Page::getCurrentPage();
//$cobj = $nh->getTrailToCollection($c);
?>
    <?php foreach ($pages as $page):
        $title = $th->entities($page->getCollectionName());
        $url = $nh->getLinkToCollection($page);
        $target = ($page->getCollectionPointerExternalLink() != '' && $page->openCollectionPointerExternalLinkInNewWindow()) ? '_blank' : $page->getAttribute('nav_target');
        $target = empty($target) ? '_self' : $target;
        $thumbnail = $page->getAttribute('productimage');
        $description = $page->getCollectionDescription();
        $description = $controller->truncateSummaries ? $th->wordSafeShortText($description, $controller->truncateChars) : $description;
        $description = $th->entities($description);

 
Kurtopsy replied on at Permalink Best Answer Reply
Kurtopsy
Be sure to define the variable and attribute in the loop.
$attributeName1 = $page->getAttribute('attributename1');


Then echo that variable in your span.
echo $attributeName1
studio4graphics replied on at Permalink Reply
Thank you, that works great.

In previous version (5.6) I had it like the example code below. Is this due to a change in version of concrete5 or is this a another solution with php?

<?php  
   defined('C5_EXECUTE') or die("Access Denied.");
   $textHelper = Loader::helper("text");
   $imgHelper = Loader::Helper('image');
   if (count($cArray) > 0) { ?>
   <?php  
   for ($i = 0; $i < count($cArray); $i++ ) {
      $cobj = $cArray[$i];
      if ($cobj->getCollectionID() == Page::getCurrentPage()->getCollectionID()) { continue; } //skip current page
      $target = $cobj->getAttribute('nav_target');
      $title = $cobj->getCollectionName();
      $c = $cobj->getCurrentPage();
      $date = $cobj->getCollectionDatePublic('j M Y'); ?>
<div>
<?php echo($cobj->getAttribute('attributename1')->getVersion()->getRelativePath());?>
Kurtopsy replied on at Permalink Reply
Kurtopsy
You're welcome! Change with Concrete5 not PHP.