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
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
I'm working with the Blog Index Thumbnail.
But how do i add the thumbnails? I can't seem to make it work.
But how do i add the thumbnails? I can't seem to make it work.
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>
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.
Heres my whole php code - here you can see it in real lifehttp://test.gamersnation.dk/news/...
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')) { ?>
Viewing 15 lines of 47 lines. View entire code block.
Heres my whole php code - here you can see it in real lifehttp://test.gamersnation.dk/news/...
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/...
Have you seen this add-on by Jordan? http://www.concrete5.org/marketplace/addons/page-list-teasers/...
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.
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
Edit: and right now all I see on the news page is 'bananas'... no thumbnail
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?
I've just tested the addon you linked, and it seems like it doesn't have Thumbnails included?
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.
You need to add the thumbnail part as you did in your previous code.
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!
Thank you mate, you are really helping me out here!
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.
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.
Lovely mate!
Do i still have to add somewhere in the php or no need to?
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>
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.
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/...