Help with custom template for page list
Permalink
I have a custom template for a page list block.
In it I output a thumbnail using:
(I stole the code from blog_index_thumbnail.php).
I would like to edit the code so that it doesn't output the thumbnail if the thumbnail is the default thumbnail. e.g. the user didn't select a different image for the page thumbnail when creating the page - the default image I use is called "defaultthumb.png".
I hope I have explained well!
In it I output a thumbnail using:
<?php $ts = $cobj->getBlocks('Thumbnail Image'); if (is_object($ts[0])) { $tsb = $ts[0]->getInstance(); $thumb = $tsb->getFileObject(); if($thumb){ $imgHelper->outputThumbnail($thumb, 50, 50, $title); } } ?>
(I stole the code from blog_index_thumbnail.php).
I would like to edit the code so that it doesn't output the thumbnail if the thumbnail is the default thumbnail. e.g. the user didn't select a different image for the page thumbnail when creating the page - the default image I use is called "defaultthumb.png".
I hope I have explained well!
Awesome, thanks 12345j.
I got this error:
Warning: Missing argument 2 for ImageHelper::getThumbnail(), called in /home/pjlittle/public_html/pjl_tf/blocks/page_list/templates/news_index_thumbnail.php on line 29 and defined in /home/pjlittle/public_html/pjl_tf/updates/concrete5.5.2.1/concrete/helpers/image.php on line 194
Line 29 is:
So I passed it some more parameters and changed the line to:
I'm quite new to C5/php is this the correct thing to do?
Also I can see that the image filename C5 spits out to the browser is not the filename I uploaded in filemanager (it is actually 70438a66073d0eb4d72790976d22c7e6.png) - so I used that instead.
Seems to work with these amends, very grateful for your help and especially the explanation.
I got this error:
Warning: Missing argument 2 for ImageHelper::getThumbnail(), called in /home/pjlittle/public_html/pjl_tf/blocks/page_list/templates/news_index_thumbnail.php on line 29 and defined in /home/pjlittle/public_html/pjl_tf/updates/concrete5.5.2.1/concrete/helpers/image.php on line 194
Line 29 is:
$src = $imgHelper->getThumbnail($thumb);
So I passed it some more parameters and changed the line to:
$src = $imgHelper->getThumbnail($thumb, 50, 50, 0);
I'm quite new to C5/php is this the correct thing to do?
Also I can see that the image filename C5 spits out to the browser is not the filename I uploaded in filemanager (it is actually 70438a66073d0eb4d72790976d22c7e6.png) - so I used that instead.
Seems to work with these amends, very grateful for your help and especially the explanation.
yeah, thats just a mistake on my part, you did the right thing.
I just typed this up on the forums though, so it could have errors.
Basically, what you want to do is to call the getThumbnail function on your thumb so you can get some information about the image. Then you get the image url. From this, you split the string into a different part whenever theres a /. Whats after the last slash should be the file name, so we just check that this name isn't the same as your default. There are other ways to do it but this should sustain code changes.
If it doesn't work or you have any other questions feel free to post here again.