Jump to content

Lower the character limit for Announcements summaries.


Recommended Posts

Without trying it, I'd guess it's this bit within the announcements.tpl around line 22.

       {if $announcement.text|strip_tags|strlen < 350}
            <p>{$announcement.text}</p>
        {else}
            <p>{$announcement.summary}
            <a href="{routePath('announcement-view', $announcement.id, $announcement.urlfriendlytitle)}" class="label label-warning">{$LANG.readmore} &raquo;</a>
            </p>
        {/if}

Change that "350" and if it's longer than that it should display the "...more" link. Again, it's not tested. 😉

Link to comment
Share on other sites

1 hour ago, bear said:

Without trying it, I'd guess it's this bit within the announcements.tpl around line 22.

 


       {if $announcement.text|strip_tags|strlen < 350}
            <p>{$announcement.text}</p>
        {else}
            <p>{$announcement.summary}
            <a href="{routePath('announcement-view', $announcement.id, $announcement.urlfriendlytitle)}" class="label label-warning">{$LANG.readmore} &raquo;</a>
            </p>
        {/if}

 

Change that "350" and if it's longer than that it should display the "...more" link. Again, it's not tested. 😉

I used the same thing a while ago, since you its not tested, I have tested it and it does work.

Link to comment
Share on other sites

Thanks guys,

I did experiment with that figure before posting - sorry, I should have mentioned that - and at least on my version, it doesn't work. Logically, though, it shouldn't because, the code is looking to see if the whole post is less than 350 characters. If it is, it displays the whole post, otherwise it displays the summary, but the character count for the summary isn't set by that 350 figure. I assume it's hard-coded somewhere, presumably as announcement.summary.

Incidentally, the character count for both announcement summaries is 341, though the word count is different.

Link to comment
Share on other sites

15 hours ago, bear said:

I wouldn't be surprised if it's hard coded behind the encryption then. Quite a lot of things that probably doesn't need to be is, and that makes things just that much harder. 

I think it's hard coded at 350 after tags removed - i've never seen a summary string longer than 296, so maybe it's changed to 300... ?

Xb6P9ex.png

17 hours ago, HarryAdney said:

Incidentally, the character count for both announcement summaries is 341, though the word count is different.

first number on the screenshot is a character count of 'summary'; second is character count of 'text' - top article is a copy&paste of @HarryAdney article.

On 21/10/2018 at 18:54, HarryAdney said:

Is there a way to lower the number of characters displayed in the announcements section on the home page? 

quick way (if you want to reduce the length) would be to just truncate it to x characters (showing last whole word) in the template (would work on both homepage and announcements)...

{$announcement.summary|truncate:150}<br>

jWgoZNM.png

ultimately, you could do it as a hook if you wanted to ('summary' is just a truncated stripped version of 'text') - so if you just wanted to reduce it, you could loop through the array and truncate it (similar to above), or if you wanted it longer than 350/300, then you'd just use 'text' as a source and create your 'summary' from that string... though, as you've already edited the template to change the layout, it would probably be simpler just to use the template edit to truncate it. thanks.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated