-
AuthorPosts
-
nooran Developer
nooran
- Join date:
- June 2013
- Posts:
- 119
- Downloads:
- 8
- Uploads:
- 21
- Thanks:
- 32
- Thanked:
- 6 times in 1 posts
February 14, 2014 at 5:56 pm #194791Hello,
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 Alizomidaily Friendzomidaily
- Join date:
- March 2013
- Posts:
- 132
- Downloads:
- 0
- Uploads:
- 4
- Thanks:
- 7
- Thanked:
- 9 times in 1 posts
February 15, 2014 at 2:13 am #522767As 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,
Josephnooran Developernooran
- Join date:
- June 2013
- Posts:
- 119
- Downloads:
- 8
- Uploads:
- 21
- Thanks:
- 32
- Thanked:
- 6 times in 1 posts
February 15, 2014 at 7:35 am #522788The 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 ModeratorNinja Lead
- Join date:
- November 2014
- Posts:
- 16064
- Downloads:
- 310
- Uploads:
- 2864
- Thanks:
- 341
- Thanked:
- 3854 times in 3563 posts
February 17, 2014 at 8:00 am #522979I’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 Developernooran
- Join date:
- June 2013
- Posts:
- 119
- Downloads:
- 8
- Uploads:
- 21
- Thanks:
- 32
- Thanked:
- 6 times in 1 posts
February 17, 2014 at 9:31 am #522994Hello 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 ModeratorNinja Lead
- Join date:
- November 2014
- Posts:
- 16064
- Downloads:
- 310
- Uploads:
- 2864
- Thanks:
- 341
- Thanked:
- 3854 times in 3563 posts
February 18, 2014 at 9:48 am #523180It 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.
1 user says Thank You to Ninja Lead for this useful post
nooran Developernooran
- Join date:
- June 2013
- Posts:
- 119
- Downloads:
- 8
- Uploads:
- 21
- Thanks:
- 32
- Thanked:
- 6 times in 1 posts
February 19, 2014 at 7:07 am #523348Hello,
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 ModeratorNinja Lead
- Join date:
- November 2014
- Posts:
- 16064
- Downloads:
- 310
- Uploads:
- 2864
- Thanks:
- 341
- Thanked:
- 3854 times in 3563 posts
nooran Developernooran
- Join date:
- June 2013
- Posts:
- 119
- Downloads:
- 8
- Uploads:
- 21
- Thanks:
- 32
- Thanked:
- 6 times in 1 posts
February 19, 2014 at 2:17 pm #523431Yes… worked fine…
Many thanks to you.
Best
May 10, 2015 at 2:58 pm #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
May 10, 2015 at 2:58 pm #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 ModeratorNinja Lead
- Join date:
- November 2014
- Posts:
- 16064
- Downloads:
- 310
- Uploads:
- 2864
- Thanks:
- 341
- Thanked:
- 3854 times in 3563 posts
May 11, 2015 at 6:58 am #570106@annesinger: Yes, you can apply the same solution into: templates/ja_decor/html/com_content/category/masonry_item.php file
May 11, 2015 at 12:08 pm #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 ModeratorNinja Lead
- Join date:
- November 2014
- Posts:
- 16064
- Downloads:
- 310
- Uploads:
- 2864
- Thanks:
- 341
- Thanked:
- 3854 times in 3563 posts
May 12, 2015 at 7:00 am #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 ModeratorNinja Lead
- Join date:
- November 2014
- Posts:
- 16064
- Downloads:
- 310
- Uploads:
- 2864
- Thanks:
- 341
- Thanked:
- 3854 times in 3563 posts
May 12, 2015 at 7:00 am #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); ?>
-
AuthorPosts
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