test
Viewing 15 posts - 1 through 15 (of 23 total)
  • Author
    Posts
  • nooran Developer
    #194791

    Hello,

    I’m using JA Purity III. I’m wondering if there is a way to force a character limitation intro text as featurestatus without having to insert the read more horizontal line.

    Many thanks for your help and support.

    Happy Valentine’s Day & Best Regards
    Raffet Ali

    zomidaily Friend
    #522767

    As a leader of Joomla template club, JoomlaArt really need to have that feature. There is third party extension http://extensions.joomla.org/extensions/news-display/article-elements/articles-summary/17979 but I still prefer if this feature can be added to the template core.

    Regards,
    Joseph

    nooran Developer
    #522788

    The extension seems very good. However, as you said, it would be perfect if this feature added to Joomlart template core..
    Because I think too many extensions are not good for the overall site speed.

    I tried another way, from the MySQL admin database:
    1- I clicked on “com_content”
    2- Then clicked on “Structure”
    3- from “introtext” field, I clicked on “Change” icon.
    4- there is “Length/Values”, I put the 100 and saved them all…

    But unfortunately, it didn’t work… I think if someone has a good knowledge on MySQL database, can figure out how to make it work from the database,,,

    It didn’t work with me, but I think it’s somewhere there…

    Ninja Lead Moderator
    #522979

    I’m not sure changing in database like that can help, you can try to apply the following cut_string function into your site:


    <?php
    function cut_string($title, $max)
    {
    if($title!=''){
    if(is_array($title)) list($string, $match_to) = $title;
    else { $string = $title; $match_to = $title{0}; }

    $match_start = stristr($string, $match_to);
    $match_compute = strlen($string) - strlen($match_start);

    if (strlen($string) > $max)
    {
    if ($match_compute < ($max - strlen($match_to)))
    {
    $pre_string = substr($string, 0, $max);
    $pos_end = strrpos($pre_string, " ");
    if($pos_end === false) $string = $pre_string."...";
    else $string = substr($pre_string, 0, $pos_end)."...";
    }
    else if ($match_compute > (strlen($string) - ($max - strlen($match_to))))
    {
    $pre_string = substr($string, (strlen($string) - ($max - strlen($match_to))));
    $pos_start = strpos($pre_string, " ");
    $string = "...".substr($pre_string, $pos_start);
    if($pos_start === false) $string = "...".$pre_string;
    else $string = "...".substr($pre_string, $pos_start);
    }
    else
    {
    $pre_string = substr($string, ($match_compute - round(($max / 3))), $max);
    $pos_start = strpos($pre_string, " "); $pos_end = strrpos($pre_string, " ");
    $string = "...".substr($pre_string, $pos_start, $pos_end)."...";
    if($pos_start === false && $pos_end === false) $string = "...".$pre_string."...";
    else $string = "...".substr($pre_string, $pos_start, $pos_end)."...";
    }

    $match_start = stristr($string, $match_to);
    $match_compute = strlen($string) - strlen($match_start);
    }

    return $string;
    }else{
    return $string ='';
    }
    }

    echo cut_string("Profesionální fotograf zachytí momenty radosti a štestí Vašeho dítete v jeho prirozeném prostredí a to na hrištích, pri hre, sportu, ci jiného konícku, budete tak mít na vždy uchovány vzpomínky, profesionálne zpracované tak jak si budete prát", 60);
    ?>

    nooran Developer
    #522994

    Hello Ninja Lead,

    Thanks for the reply…but in which php file to add this code?

    And is it about the last coding:

    echo cut_string("Profesionální fotograf zachytí momenty radosti a štestí Vašeho dítete v jeho prirozeném prostredí a to na hrištích, pri hre, sportu, ci jiného konícku, budete tak mít na vždy uchovány vzpomínky, profesionálne zpracované tak jak si budete prát", 60);
    ?>

    Is it necessary to be included into the code, or it just an example?

    Best

    Ninja Lead Moderator
    #523180

    It depends on content on specific part of your website where you want to limit the intro text.

    For example, if you want to achieve that with item in page that has menu item type xLayout – Blog, you can follow these steps:

    – Open the templates/purity_iii/html/com_content/category/xblog_item.php file

    Underneath this line:

    defined('_JEXEC') or die;

    add this code snippet:


    if(!function_exists('cut_string')){
    function cut_string($title, $max)
    {
    if($title!=''){
    if(is_array($title)) list($string, $match_to) = $title;
    else { $string = $title; $match_to = $title{0}; }

    $match_start = stristr($string, $match_to);
    $match_compute = strlen($string) - strlen($match_start);

    if (strlen($string) > $max)
    {
    if ($match_compute < ($max - strlen($match_to)))
    {
    $pre_string = substr($string, 0, $max);
    $pos_end = strrpos($pre_string, " ");
    if($pos_end === false) $string = $pre_string."...";
    else $string = substr($pre_string, 0, $pos_end)."...";
    }
    else if ($match_compute > (strlen($string) - ($max - strlen($match_to))))
    {
    $pre_string = substr($string, (strlen($string) - ($max - strlen($match_to))));
    $pos_start = strpos($pre_string, " ");
    $string = "...".substr($pre_string, $pos_start);
    if($pos_start === false) $string = "...".$pre_string;
    else $string = "...".substr($pre_string, $pos_start);
    }
    else
    {
    $pre_string = substr($string, ($match_compute - round(($max / 3))), $max);
    $pos_start = strpos($pre_string, " "); $pos_end = strrpos($pre_string, " ");
    $string = "...".substr($pre_string, $pos_start, $pos_end)."...";
    if($pos_start === false && $pos_end === false) $string = "...".$pre_string."...";
    else $string = "...".substr($pre_string, $pos_start, $pos_end)."...";
    }

    $match_start = stristr($string, $match_to);
    $match_compute = strlen($string) - strlen($match_start);
    }

    return $string;
    }else{
    return $string ='';
    }
    }
    }

    + Find the following line of code:

    <?php echo $this->item->introtext; ?>

    change it to

    <?php echo cut_string($this->item->introtext,10); ?>

    Hope it helps.

    nooran Developer
    #523348

    Hello,

    It worked fine.. Many thanks to you.
    However, it only works with “xLayout – Blog” which I couldn’t make articles display as “2 columns” or to limit featured articles to be only 4 or 2, these two features are there when I change to “Featured Articles” of normal Joomla.

    So, it is please possible to help me do the same thing but on “Featured Articles” of Joomla, as I always use it?

    Again, thank you so much for your help and support.

    Best

    Ninja Lead Moderator
    #523385

    With Featured Articles, you can apply the same solution above into the templates/purity_iii/html/com_content/featured/default_item.php file.

    nooran Developer
    #523431

    Yes… worked fine…

    Many thanks to you.

    Best

    annesinger Friend
    #570041

    @ninja Lead

    Can you please assist me.

    I have JA_Decor template.

    Trying to increase the intro text word/character limit on the blog layout and masonry layout pages.
    They are very similar layout views.
    I am happy to edit the code, or create layout overrides. Can you just let me know what code to put where in order to adjust the intro text limit.

    I assume these overides will not effect intro text used elsewhere on the site.

    Thanks

    annesinger Friend
    #735113

    @ninja Lead

    Can you please assist me.

    I have JA_Decor template.

    Trying to increase the intro text word/character limit on the blog layout and masonry layout pages.
    They are very similar layout views.
    I am happy to edit the code, or create layout overrides. Can you just let me know what code to put where in order to adjust the intro text limit.

    I assume these overides will not effect intro text used elsewhere on the site.

    Thanks

    Ninja Lead Moderator
    #570106

    @annesinger: Yes, you can apply the same solution into: templates/ja_decor/html/com_content/category/masonry_item.php file

    annesinger Friend
    #570154

    @ninja Lead,

    Thanks for the response. I now understand what code to use and where to put it.

    Still a little confused as I think that code is probably more than I need. Looking for where to set the exact word limit, maybe you can point this out in the code.

    Also I am happy to add the read more line to each article, because it appears this is necessary to have the read more button appear in the masonry / blog layouts.

    I’m not sure exactly what this code is doing, appears it is overriding the need to add a read more marker to the article.

    Does this mean every article will have intro text in that view?
    This is good, just need to know how to use it.

    Ninja Lead Moderator
    #570277

    @annesinger: Look at the code below with my red mark, you can see the number to limit word

    <?php echo cut_string($this->item->introtext,10); ?>

    Ninja Lead Moderator
    #735343

    @annesinger: Look at the code below with my red mark, you can see the number to limit word

    <?php echo cut_string($this->item->introtext,10); ?>

Viewing 15 posts - 1 through 15 (of 23 total)

This topic contains 22 replies, has 6 voices, and was last updated by  Ninja Lead 8 years, 3 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum