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".
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);
Viewing 15 lines of 54 lines. View entire code block.
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?
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());?>
Viewing 15 lines of 50 lines. View entire code block.
You're welcome! Change with Concrete5 not PHP.
Then echo that variable in your span.