Tip: How to add Page List with Custom Template in your Pagetype

Permalink
I was digging here and there to know how to do this. And I found it. Just thought I'd share this with you guys.

This goes into your custom Pagetype file in your theme. And also, this is for when you have your own custom template for Page List block in /concrete5/blocks/page_list/templates.

Have fun.
<?php 
   $pl_block = BlockType::getByHandle('page_list');
   $pl_block->controller->num = 5; // how many page items to list
   $pl_block->controller->cParentID = '165'; // page ID of parent
   $pl_block->render('templates/mytemplate');
?>

 
cmsdev replied on at Permalink Reply
Hello,

I am using the easy news add on and I am trying to create a template for for the easy news list block or page list block to:

1) style the title/heading link, preview text, background ect

2) add a Read more... link to the bottom of the news article preview

Any ideas I'm very stuck?


Many thanks.
kidino replied on at Permalink Reply
I am not very familiar with the Add-Ons in the marketplace. I am new to Concrete5 myself. In fact, this is my first site with Concrete5. But I do have PHP and Wordpress experience.

But for your situation, I assume you want to have:

- a top News page, which lists all the news
- actual news article pages, all go under News

Here's how I would do it without the Add-On.

I'd create a page called News, and then all the news articles go under that page. And when I want to list out all the news, I would just use the Page List block.

You can customize the look and feel of the Page List block by choosing a different custom template. You see that option when you click on the Page List block.

If you know PHP, you can also create your own template for the Page List. Just look into /concrete/blocks/page_list/templates use one of the files, copy it and renaming it to something else, mynews_list.php for example. When it's there, next time you click on a Page List block, and then the Custom Templates, you will see the option to choose your new template.

I hope this helps.
cmsdev replied on at Permalink Reply
Thanks very much for your informative reply.

I will follow your instructions and see how it goes.

Thanks again.