Page List Teasers AddOn - Get Date of Child Page?

Permalink 1 user found helpful
Hi All,

How do I get the date of the child page when using the page list teasers custom template for the page list block?

Thanks

Dave

madesimplemedia
 
irsah replied on at Permalink Reply
irsah
I think there are add-ons for this in marketplace, keep you posted. But you could add this code to get the date in the pagelist teaser template;-

...code...
<div class="ccm-page-list">
   <?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;
      $teaser = $plth->getPageTeaser($page, 'Main', $teaserBlockCount, $teaserTruncateChars);
      // Add date for each pages 
      $date = date('F j, Y', strtotime($page->getCollectionDatePublic())); 
      ?>
      <h3 class="ccm-page-list-title">
         <a href="<?php  echo $url; ?>" target="<?php  echo $target; ?>"><?php  echo $title; ?></a>
      </h3>
      <div class="ccm-page-list-description">


I think it's in public_html/packages/page_list_teaser/blocks/page_list/templates/teaser.php

Of course best to copy that file and create a new template in your_root/blocks/page_list/templates/your_new_pagelist_teaser/view.php whereas view.php renamed from teaser.php.

Hope it helps,
Irsah
madesimplemedia replied on at Permalink Reply
madesimplemedia
Thanks for your reply Irsah.

I have something similar already in my copy of the page list teaser file:
<div class="news-article">
        <h3 class="ccm-page-list-title"><a <?php   echo $target?>href="<?php   echo $nh->getLinkToCollection($cobj)?>"><?php   echo $title?></a></h3>
        <?php  $date = date('F j, Y', strtotime($page->getCollectionDatePublic())); ?>
        <div class="post-date"><?php echo $date; ?></div>
        <div class="ccm-page-list-description">
            <?php   $plth->output_page_blocks($cobj, $excerptBlocks, $truncateChars); ?>
        </div>
        <a href="<?php   echo $nh->getLinkToCollection($cobj)?>" class="read-article">Read Article</a>
    </div>


But this just shows the date of the parent page for each article - not the date of the child page.
irsah replied on at Permalink Reply
irsah
Oh got it.. I have it somewhere and i'll keep you posted asap.
madesimplemedia replied on at Permalink Reply
madesimplemedia
You're a star, thanks! :)
irsah replied on at Permalink Reply
irsah
Look thru your code, there were corrections have to be made for getting the date/links/title/description for each page before calling it in the html markup (array of pages). It's much easier and cleaner :-) hope it worked out.

Your welcome Dave.
madesimplemedia replied on at Permalink Reply
madesimplemedia
I get syntax errors when I put your code in, do you have a complete example of the teasers page?
irsah replied on at Permalink Reply
irsah
Ok i'll send it thru attachment.
irsah replied on at Permalink Reply 1 Attachment
irsah
Here's the file. Syntax error probably occurs because rss/pagination was loaded but you can un select in the front end options to do not want to display them.
madesimplemedia replied on at Permalink Reply
madesimplemedia
Thanks although now I get

Fatal error: Call to undefined method PageListTeasersHelper::getPageTeaser() in path-to-site\httpdocs\packages\page_list_teasers\blocks\page_list\templates\news_list.php on line 17


Sorry not a developer so not sure if this is an easy fix or not?
irsah replied on at Permalink Reply 1 Attachment
irsah
Ok I see, because the page_list teaser add on is using its own helpers. My bad.

Do you have the original teaser.php file in packages/page_list_teaser/blocks/page_list/templates/ folder?

Copy that file and rename it and paste in the same folder above. Edit and add in the additional code like " $date=... " and the marked html code for echoing the date in that new file.

I'll try to update the attachment for you later.

*edit* Updated attachment, just download, rename the file ie new_teaser.php and upload that file in your_root/packages/page_list_teaser/blocks/page_list/templates/ folder.

Incl image for the working page_list teaser with date using the above attached file.
madesimplemedia replied on at Permalink Reply
madesimplemedia
I think I have done all that already.

If you get a chance later to update the attachment I would be most grateful :)
madesimplemedia replied on at Permalink Reply
madesimplemedia
Did you manage to find the code in the end? :)
irsah replied on at Permalink Reply
irsah
It's in the same file attached previously. I've also attached an image which shows the output from the page_list teaser block thru that code.

Hope it helps