Page List Block - How to show a Thumbnail?

Permalink 1 user found helpful
Hello everyone!

I'm working on a News website, where my client wants to have a News viewer with thumbnails. But with my low knowledge of Page-List Blocks, how do i make my block template show a thumbnail which the client can add him self?

I would appreciate any answer, but i would prefer a answer that basicly explains what does what?

Thanks up front!

//Stenkilde

Stenkilde
 
adajad replied on at Permalink Reply
adajad
Take a look at the built in blog feature in composer (if you installed with sample content) and the use of the custom template "Blog Index Thumbnail".

You can also have a look at the below links:
http://www.concrete5.org/documentation/how-tos/developers/create-a-...
http://www.concrete5.org/documentation/how-tos/editors/manually-set...
http://www.concrete5.org/marketplace/addons/simple-news/...
Stenkilde replied on at Permalink Reply
Stenkilde
I'm working with the Blog Index Thumbnail.
But how do i add the thumbnails? I can't seem to make it work.
adajad replied on at Permalink Reply
adajad
If you look at the 'Blog Index Thumbnail' custom template you can see they are looking for a block called 'Thumbnail Image', so all you need to do is create a block and give it the name 'Thumbnail Image'.
<div class="image-link">
    <a <?php   if ($target != '') { ?> target="<?php  echo $target?>" <?php   } ?> href="<?php  echo $nh->getLinkToCollection($cobj)?>">
    <?php  
    $ts = $cobj->getBlocks('Thumbnail Image'); 
    if (is_object($ts[0])) { 
        $tsb = $ts[0]->getInstance();
        $thumb = $tsb->getFileObject();
        if($thumb){
            $imgHelper->outputThumbnail($thumb, 220, 220, $title);
        }
    }
    ?></a>
</div>
Stenkilde replied on at Permalink Reply
Stenkilde
I've got it to work now!

Now i'm just having a problem, that even though there is no "news" on the page. It still shows a Thumbnail.

<?php 
   defined('C5_EXECUTE') or die(_("Access Denied."));
   $textHelper = Loader::helper("text"); 
   // now that we're in the specialized content file for this block type, 
   // we'll include this block type's class, and pass the block to it, and get
   // the content
   if (count($cArray) > 0) { ?>
   <div class="ccm-page-list">
<?php 
   for ($i = 0; $i < count($cArray); $i++ ) {
      $cobj = $cArray[$i]; 
      $title = $cobj->getCollectionName(); ?>
   <div class="pageListItem">
   <?php
   if($cobj->getAttribute('news_thumbnail')) { ?>


Heres my whole php code - here you can see it in real lifehttp://test.gamersnation.dk/news/...
adajad replied on at Permalink Reply
adajad
Well, you need to check if the page has a content block, and if it does then include the page in the page list and pull the text from the content block.

Have you seen this add-on by Jordan? http://www.concrete5.org/marketplace/addons/page-list-teasers/...
Stenkilde replied on at Permalink Reply
Stenkilde
Well, as you can see on the link i gave you. There is a huge picture in the middle of anything. There is no post written through composer, and all the site /news actually need is a Page list to show all the news there is written on the page.
adajad replied on at Permalink Reply
adajad
Since you are using an attribute as thumbnail instead of a block, then the attribute isn't set until you create the page, and why create a page without any content?

Edit: and right now all I see on the news page is 'bananas'... no thumbnail
Stenkilde replied on at Permalink Reply
Stenkilde
It's under development, and i'm working on it right as we speak. In in between my comments i edit it on and off.

I've just tested the addon you linked, and it seems like it doesn't have Thumbnails included?
adajad replied on at Permalink Reply
adajad
No it doesn't, but it does pull content from the actual page instead of from the description.

You need to add the thumbnail part as you did in your previous code.
Stenkilde replied on at Permalink Reply
Stenkilde
Alright, seems like i got it all broken down now. So now i just have to fiddle abit with it, and everything is going to be fine!

Thank you mate, you are really helping me out here!
adajad replied on at Permalink Reply
adajad
Something like:
http://pastie.org/6378015#7,14-15,26...

Edit: Forgot to add an if statement to not show the thumbnail image if there is none.
Stenkilde replied on at Permalink Reply
Stenkilde
Lovely mate!

Do i still have to add
<div class="thumbnail"> 
        <?php
   if($cobj->getAttribute('news_thumbnail')) { ?>
      <img src="<?php echo ($cobj->getAttribute('news_thumbnail')->getVersion()->getRelativePath());?>">
   <?php } ?>
         </div>
somewhere in the php or no need to?
adajad replied on at Permalink Reply
adajad
Try out my pastie-code above, but make sure you have an if-statement to only show the img tag if there is a $image.