Truncate Summaries
Permalink 2 users found helpful
Concrete5 ver. 5.5.1.
Block Page List.
Type of Pages Blog Entry.
In custom template "Blog Index "the Truncate Summaries does not working properly.
Iam setting for example Truncate descriptions after 250 characters and the truncate does not work.
I have set a description of an article of course...
Any suggestion?
Thanks
Block Page List.
Type of Pages Blog Entry.
In custom template "Blog Index "the Truncate Summaries does not working properly.
Iam setting for example Truncate descriptions after 250 characters and the truncate does not work.
I have set a description of an article of course...
Any suggestion?
Thanks
Any help please!!!
how does it now work? does it not cut the article? cut it to 100? more details would help.
Exactly not cut the article...
Can anyone advice me please ?
Might be a silly question but have you tried clearing the cache?
Yes I have cleared the cache files. The issue is that the "Blog Index" custom template does not truncate the article description characters...
Is this a bug of C5-5.5.1 ? Iam trying to understand. Nobody have the same problem with this template?
Ya, you might be right on this.
in /concrete/blocks/page_list/templates/blog_index.php
Maybe modify it to try this.
It looks like the blog_index is set to show the 'Main' Area of the blog page not the page description so I grabbed that in a buffer and cleaned and shortened it. Let me know if it works.
EDIT: updated as per @jjcdesign's comment below.
in /concrete/blocks/page_list/templates/blog_index.php
<div class="excerpt"> <?php $a = new Area('Main'); $a->disableControls(); $a->display($cobj); ?> </div>
Maybe modify it to try this.
<div class="excerpt"> <?php $a = new Area('Main'); $a->disableControls(); if($truncateChars) { $th = Loader::helper('text'); ob_start(); $a->display($cobj); $excerpt = ob_get_clean(); echo $th->entities($th->shorten($excerpt,$truncateChars)); } else { $a->display($cobj); } ?> </div>
It looks like the blog_index is set to show the 'Main' Area of the blog page not the page description so I grabbed that in a buffer and cleaned and shortened it. Let me know if it works.
EDIT: updated as per @jjcdesign's comment below.
There is a fatal error:
Fatal error: Call to a member function entities() on a non-object in /home/easynetg/public_html/c5/concrete/blocks/page_list/templates/blog_index.php on line 42
this line of code is:
$textHelper->entities($textHelper->shorten($excerpt,$truncateChars));
Fatal error: Call to a member function entities() on a non-object in /home/easynetg/public_html/c5/concrete/blocks/page_list/templates/blog_index.php on line 42
this line of code is:
$textHelper->entities($textHelper->shorten($excerpt,$truncateChars));
oops, that should be this.
$th->entities($th->shorten($excerpt,$truncateChars));
FYI: I'm not sure if you know this as you are new around here. But the people helping in the forums aren't concrete5 employees, we're just helping out.
$th->entities($th->shorten($excerpt,$truncateChars));
FYI: I'm not sure if you know this as you are new around here. But the people helping in the forums aren't concrete5 employees, we're just helping out.
Thanks a lot mkly!!!
It seems to be working properly!
The page type of this page must be only "Blog Entry"? or I can use and another type of page like "Right Sidebar" for example?
It seems to be working properly!
The page type of this page must be only "Blog Entry"? or I can use and another type of page like "Right Sidebar" for example?
Thanks for testing it and letting me know. I'll try to wrap it up into a patch to send back to the core. It's very cool of you to do.
From the look of the code, I'm pretty sure it only looks for areas called "Main". So any page that has a "Main" I think it will take the first block from main and spit it out. You might run into trouble if the first block isn't a content block or something like that. I'd would test it out and see what happens. From what I can tell it should work.
From the look of the code, I'm pretty sure it only looks for areas called "Main". So any page that has a "Main" I think it will take the first block from main and spit it out. You might run into trouble if the first block isn't a content block or something like that. I'd would test it out and see what happens. From what I can tell it should work.
I changed it, but for me it's still not working. Showing all content, whatever I do. Cleared cache already...
Any ideas?
Edit: I was in the wrong template folder, but still not working the way I would expect it.
If I use the given code above, just the Titles are showing, but no text content.
Any ideas?
Edit: I was in the wrong template folder, but still not working the way I would expect it.
If I use the given code above, just the Titles are showing, but no text content.
I get the same when applying the suggested modification - no text displayed at all rather than the description truncated to the number of characters selected when editing the page list block.
Any suggestions?
Any suggestions?
I had the same problem but managed to solve it by adding "echo"
echo $th->entities($th->shorten($excerpt,$truncateChars));
Thanks for this, works great now with text, but where I have a blog entry with an image at the start of my text, it also strips that out. Any idea how to prevent the image from being removed?
Brilliant. Worked a treat. Thank you.
Note, mkly corrected/edited his first post so that the code there is now correct, i.e. you need the "echo".
Note, mkly corrected/edited his first post so that the code there is now correct, i.e. you need the "echo".