Nothing displays when truncating getCollectionDescription in page_list block
Permalink
Hi There,
We're having an issue where a page doesn't display if we try to truncate the page description in a page list block - we're using Jordan's templates.
At the top of the foreach loop we have this:
Then we're outputting it using this:
If we comment out the above the page/results shows but if left in nothing displays (just a blank html page).
It displays fine on our DEV server, just not locally in MAMP - have upgraded MAMP but still no luck. If I downgrade php to 5.3 in MAMP it works. But anything in php 5.4 doesn't.
Can anyone see what we're doing wrong?
Any pointers in the right direction would be much appreciated.
Cheers
Ben
We're having an issue where a page doesn't display if we try to truncate the page description in a page list block - we're using Jordan's templates.
At the top of the foreach loop we have this:
// PREPARE PAGE DESCRIPTION AND TRUNCATE IF TRUNCATE IS ON $description = $page->getCollectionDescription(); // get page description if ($controller->truncateSummaries) { $description = $th->shortenTextWord($description, $controller->truncateChars); // truncate if using concrete5.4.2.2 or higher } $description = $th->entities($description); // output truncated description
Then we're outputting it using this:
<?php // output description if one has been set if ($description) { ?> <p><?php echo $description ?></p> <? } ?>
If we comment out the above the page/results shows but if left in nothing displays (just a blank html page).
It displays fine on our DEV server, just not locally in MAMP - have upgraded MAMP but still no luck. If I downgrade php to 5.3 in MAMP it works. But anything in php 5.4 doesn't.
Can anyone see what we're doing wrong?
Any pointers in the right direction would be much appreciated.
Cheers
Ben
So have been commenting stuff out in an attempt to find the root cause and if I comment out this from the same page_list template:
And comment back in my description:
Then the page loads but I see the following error:
Am I doing something wrong with the way I'm truncating the text?
$img = $page->getAttribute('main_image'); // handle of image attribute if ($img) { // if image is set, output $thumb = $ih->getThumbnail($img, 220, 9999); // ($img, width, height, TRUE) } // using 9999 effectively means 'no maximum size' | TRUE = crop instead of resize
And comment back in my description:
$pageDescription = $page->getCollectionDescription(); // get page description if ($controller->truncateSummaries) { $description = $th->shortenTextWord($description, $controller->truncateChars); // truncate if using concrete5.4.2.2 or higher } $description = $th->entities($description); // output truncated description
Then the page loads but I see the following error:
Warning: strip_tags() expects parameter 1 to be string, object given in /Users/username/Sites/site-name/concrete/core/helpers/text.php on line 142 - See more at: http://site-name/news-and-updates/#sthash.OIFa88DL.dpuf
Am I doing something wrong with the way I'm truncating the text?
So if I hard code the truncation like this:
The description works, but if I comment in the image thumb code:
Then the page doesn't display again.
$description = $page->getCollectionDescription(); // get page description $description = $th->shortenTextWord($description, 300); // truncate description - amount of characters to show, concrete5.4.2.2 or higher
The description works, but if I comment in the image thumb code:
$img = $page->getAttribute('main_image'); // handle of image attribute if ($img) { // if image is set, output $thumb = $ih->getThumbnail($img, 220, 9999); // ($img, width, height, TRUE) } // using 9999 effectively means 'no maximum size' | TRUE = crop instead of resize
Then the page doesn't display again.
OK, after lots of testing, I've tracked this down to an image attribute we have:
If we create a new attribute (test_image), apply it to the first news story, then alter the page_list template to pull it, everything works.
Is it possible for an image attribute to become corrupt somehow?
main_image
If we create a new attribute (test_image), apply it to the first news story, then alter the page_list template to pull it, everything works.
Is it possible for an image attribute to become corrupt somehow?
We don't full understand how cache works but just incase it was a corrupt cache file from generating the thumb, we deleted all files in the cache directory and tried to use main_image again.
No joy
No joy
Is there a way to output php errors or trace what might be going on with this block template?