Jump to content
HarryAdney

Lower the character limit for Announcements summaries.

Recommended Posts

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

  • Thanks 1

Share this post


Link to post
Share on other sites

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. 😉

  • Thanks 1

Share this post


Link to post
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.

  • Like 1
  • Thanks 1

Share this post


Link to post
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.

  • Like 2

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Awesome solution. I should have looked up the Smarty modifier but didn't even think of it. 

Many thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By HarryAdney
      Is there a way to disable comments in the Announcements function in WHMCS? Ideally I'd like to do that on individual announcement, allowing them on some but disabling them on others.
      Thanks.
    • By WHMCS ChrisD
      Hi Everyone,
      The WHMCS Forums were launched over 12 years ago and in that time have seen a number of iterations and updates.
      Today, we’re excited to announce that we're getting ready to introduce the next incarnation of the WHMCS Community and with it, a brand-new look and feel, along with a whole host of new features and functionality - starting with in-line post reactions & a new reputation structure as well as a new question & answer format for certain forum categories.
      Preparations are already well underway to migrate from the current forums to our new Community powered by the Invision Community Suite. The current community is home to a wealth of knowledge and information and we’ll be migrating all existing threads and posts as well as user accounts and private messages to the new WHMCS Community to ensure that none of this is lost.
      I’m personally very excited about the opportunities our new platform unlocks. Over the coming months, we’ll be rolling out a range of new features and functionality in our community, taking inspiration from the responses we received earlier in the year about how we can improve your experience.
      Stay tuned for updates in the coming weeks as we move nearer to the switch over, in the meantime, here’s a sneak preview of what’s to come.

      The team and I are excited to bring our new community to you in September, and I will be posting more information on the changes in future posts.
    • By nimonogi
      This addon will 301 redirect to the correct Search Engine Friendly URL.
       
      THE PROBLEM:
      After changing some knowledgebase article's titles, I've noticed that articles can be accessed through old URI as well. Even worse, can be accessed using any URI as long as it has the ID inside the path. Announcements have the same behavior as well.
       
      For example, all URLs below will show the same content:
      1: yourdomain.com/knowledgebase/15/Transferring-Your-Domain-from-NameCheapcom.html
      2: yourdomain.com/knowledgebase/15/Transfer-your-Domain-from-NameCheap.html
      3: yourdomain.com/knowledgebase/15/JUST-ANYTHING.html
       
      This is a extremely negative for SEO as it produce duplicate content.
       
      SOLUTION:
      This addon will fix that by 301 redirecting to the correct Search Engine Friendly URL.
       
      For More Details please visit our WHMCS Addons page.
    • By gbotica
      Title says it all ... this was reported as a bug in 6.0.1, but it's still not fixed in 6.1.1.
       
      Any ETA on fixing this WHMCS?
       
      http://forum.whmcs.com/showthread.php?103666-Back-button-in-v6-01-Announcements-produces-404
    • By ModulesGarden
      Our Time Tracking Center For WHMCS has been bolstered up to help you ensure the highest efficiency of time and assets management in your company!
       
      Among numerous new conveniences, version 1.3.0 introduces the ability to define the urgency level and set the extra hourly rate per each task. What is more, 'Start Counter' button has been implemented in a ticket system to let you supervise the time spent on responding and bill your clients for it accordingly!
       
      Changelog - v1.3.0:
       


      New Feature: Bill for time spent on solving tickets
      New Feature: Define task urgency
      New Feature: Define 'Extra Hourly Rate' per task
      New Feature: Decide if prepaid hours should be reset each month
      New Feature: Reset prepaid hours of recurring product each month
      New Feature: Edit number of hours & incidents pre-purchased per client
      New Feature: Edit billable items
      New Feature: Define product to which 'Buy Additional Hours' is linked
      Improvement: Minor tweaks
      Bug Fix: Minor fixes

      Find Out More About Time Tracking Center For WHMCS!
       
       
       
      It gives us great pleasure to announce that our gripping promotion is back! Do not hesitate and jump at the chance to save up to $500 on your project - simply submit your request and our advisor will provide you with all further details!
       
       
       
      See what's on the list of latest releases:
       

      Hosting Renewals For WHMCS – v2.5.7
      WWD GoDaddy Domains For WHMCS – v2.2.3
      Bulk Orders Center For Magento – v1.2.0
      Liquid Web Storm Servers For WHMCS – v1.1.3

       
       
      Coming soon:
       

      DNS Manager For WHMCS – v.2.2.0
      Proxmox VPS & Cloud For WHMCS – v2.1.0
      DirectAdmin Extended For WHMCS – v2.0.0

       
       
      Need Custom Software Development For Your Business?
       

      Get Your Free Quote Now!

      Specially for you we will adapt an application and its design to your own needs, create a new module or even a completely new system built from scratch!
  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

By using this site, you agree to our Terms of Use & Guidelines