thumbnails in 5.3
Permalink 1 user found helpful
In 5.2, I used code like this:
<code>
$cobj->getAttribute('thumbnail')->getThumbnail(100,100)->src
</code>
After the 5.3 update, I see that I must add a getVersion and getURL instead of src but I still can't seem to get getThumbnail to work.
<code>
$cobj->getAttribute('thumbnail')->getVersion()->getURL()
</code>
I've searched the forums but all the examples seem to be pre 5.3.
<code>
$cobj->getAttribute('thumbnail')->getThumbnail(100,100)->src
</code>
After the 5.3 update, I see that I must add a getVersion and getURL instead of src but I still can't seem to get getThumbnail to work.
<code>
$cobj->getAttribute('thumbnail')->getVersion()->getURL()
</code>
I've searched the forums but all the examples seem to be pre 5.3.
this is what I'm using:
The code you posted works! Thank you!
I get a mysql "mysql error: [1146: Table 'techfocu_c5.btFile' doesn't exist" when I try and run this code. Sure enough, btFile does not, in fact, exist.
Looks like it's the LibraryFileBlockController::getFile method that's springing the error.
Am I missing something obvious? All the other variables/methods resolve as expected...
Looks like it's the LibraryFileBlockController::getFile method that's springing the error.
Am I missing something obvious? All the other variables/methods resolve as expected...
if you check out the block itself, it has much of the methods referencing the models of type: File and File_Version and the concrete/helpers/file.php which has more to do with system paths and less (well nothing) to do with actually referencing files.
The library_file block imo and from what I have read has been "deprecated" but kept around to facilitate legacy blocks working.
File::getVersion or something like that is more current.
The library_file block imo and from what I have read has been "deprecated" but kept around to facilitate legacy blocks working.
File::getVersion or something like that is more current.
but, for example, if I am trying to reference a page attribute of type file/image -- just output it on a page -- what method(s) would you use to access it? I don't see any documentation about an object of type File.
$imgHelper = Loader::helper('image'); $thumb = $cobj->getAttribute('thumbnail'); $imgHelper->getThumbnail($thumb, 100, 100);
Or you can give this block a try:
http://www.codium.co.nz/page_block_for_concrete5/...
I already thought that such an ugly code doesn't make much sense ;-) But it worked...
But yours is much nicer!
But yours is much nicer!
that block is nice, did you send a link to Andrew? Would be nice to have it in the marketplace!
already did :-)
Glad you liked it!
Glad you liked it!
Glad to see that this works as well.
the block is great.
i've put the following to controller.php
and created a template templates/temp.php
to display the number of guestbook entries, but the result is always 0, whatever the number of guestbook entries is.
Any idea, what i'm doing wrong?
i've put the following to controller.php
public function getBlocks() { return $this->page->getBlocks(); }
and created a template templates/temp.php
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); ?> <h3><a href="<?= $controller->getLink(); ?>"><?= $controller->getName(); ?></a></h3> <p><?= $controller->getDescription(); ?></p> <?php $blocks = $controller->getBlocks(); foreach($blocks as $b) { if ($b->getBlockTypeHandle() == 'guestbook') { $bi = $b->getInstance(); $entries = $bi->getEntries(); print "Comments: " . count($entries); } }
Viewing 15 lines of 16 lines. View entire code block.
to display the number of guestbook entries, but the result is always 0, whatever the number of guestbook entries is.
Any idea, what i'm doing wrong?
Hi synlag
Have also 0. When i look in the array:
The result is:
63
0
Comments:
1
1
0
It's not the right way to read out the entrys - i have 3 comments in the guestbook at the above example :-/
Can someone help us?
thanks
Have also 0. When i look in the array:
$bi = $b->getInstance(); foreach ($bi as $c) { echo $c ."<br>"; }
The result is:
63
0
Comments:
1
1
0
It's not the right way to read out the entrys - i have 3 comments in the guestbook at the above example :-/
Can someone help us?
thanks
Ok, I just had a look at the guestbook controller, and the function getEntries uses the global variable $c which is set to the current page. What you need to call (provided you're inside my page block) is:
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); ?> <h3><a href="<?= $controller->getLink(); ?>"><?= $controller->getName(); ?></a></h3> <p><?= $controller->getDescription(); ?></p> <?php $blocks = $page->getBlocks(); foreach($blocks as $b) { if ($b->getBlockTypeHandle() == 'guestbook') { $bi = $b->getInstance(); $entries = GuestBookBlockEntry::getAll($bi->bID, $page->cID, 'ASC'); print "Comments: " . count($entries); } }
Viewing 15 lines of 16 lines. View entire code block.
Thank you for your answer!
I receive following error:
Catchable fatal error: Object of class Page could not be converted to string in /home/aroundch/public_html/around/concrete/libraries/3rdparty/adodb/adodb.inc.php on line 983
The $page var is wrong, i need the cID ($c->getCollectionID()) right? But how can i read out the cID?
Thank you
I receive following error:
Catchable fatal error: Object of class Page could not be converted to string in /home/aroundch/public_html/around/concrete/libraries/3rdparty/adodb/adodb.inc.php on line 983
The $page var is wrong, i need the cID ($c->getCollectionID()) right? But how can i read out the cID?
Thank you
Still assuming you're inside my "page block" like synlag is. If you're anywhere else, just replace the $page variable with whatever variable is pointing to the collection you want to get the comments from. EG: inside the page list block use the $cobj variable that's inside the for loop. Makes sense?
Thank you very much - it works!
thx a lot!
Hi,
I'm still having troubles with this. Perhaps I'm misunderstanding. What I'm trying to do is generate thumbnails of images contained within pages and display them in the page list. Is this possible?
thanks
Nathan
I'm still having troubles with this. Perhaps I'm misunderstanding. What I'm trying to do is generate thumbnails of images contained within pages and display them in the page list. Is this possible?
thanks
Nathan
sure, this is no problem but it needs some php stuff..
This tutorials shows you how to display pictures specified in the page properties:
http://www.codeblog.ch/2009/03/concrete5-templates/...
but you can also extract blocks using a code like this (I assume you know php, oop):
This tutorials shows you how to display pictures specified in the page properties:
http://www.codeblog.ch/2009/03/concrete5-templates/...
but you can also extract blocks using a code like this (I assume you know php, oop):
$contentBlocks = array(); $c = new Page::getByPath('/about'); $blocks = $c->getBlocks("sidebar"); foreach($blocks as $b) { if ($b->getBlockTypeHandle() == 'content') { $contentBlocks[] = $b; } }
as I can get thumbnails of all images are seen and not only one.
Example this web:http://www.varelalamar.com/index.php/media/...
And load more fast
Thank.
Example this web:http://www.varelalamar.com/index.php/media/...
And load more fast
Thank.
This might sound like a pretty stupid question - how do you select the post thumbnail for a post in the c5 menues / backend?
I´m using the code by matogertel in a custom block.
I´m using the code by matogertel in a custom block.
This Thread is 11 months old...
and your question isn't really clear
Mike
and your question isn't really clear
Mike
Been looking for this PHP snippet for ages.
Thank you for sharing.
Thank you for sharing.
where do we insert these 'codes' im a newb and I have no idea whats going on.. seriously though, Im looking for some simple help and everything I read on here is about inserting codes? do I put this in my terminal?
@warrenp:
All depends on which code you want to insert?
For instance, the comment code would be within a page-list. So it shows the number of comments for each "post".
I'll be monitoring this post, If you reply, It shouldn't be long before I reply back...if your issue wasn't resolved before :P
All depends on which code you want to insert?
For instance, the comment code would be within a page-list. So it shows the number of comments for each "post".
I'll be monitoring this post, If you reply, It shouldn't be long before I reply back...if your issue wasn't resolved before :P
You may get thumbnail image src like this also.
$imgFile = File::getByID($objFile->fID); //for image
$imgSrc = $imgFile->getRelativePathFromID($objFile->fID);
echo "<img src='$imgSrc' />";
$imgFile = File::getByID($objFile->fID); //for image
$imgSrc = $imgFile->getRelativePathFromID($objFile->fID);
echo "<img src='$imgSrc' />";