Keyword

Introtext word limit

More
13 years 11 months ago #80339 by Jakub Jedynak
Replied by Jakub Jedynak on topic Introtext word limit
Use new 'dummy' category with desired paramteres ('word limit') and in master and child categories inherit settings from 'dummy' category.


caron rose said:Surely the we should be able to use the intro text limit for multiple categories. I have a Master Category, with introtext word limit set at 12 words. I have 2 sub cats and want the layout of the category page to "obey" the params of the master cat. Works fine if I only point the menu link at one of the sub cats - but as soon as I change to multiple cats (i.e., both of them) I lose the intro text word limit that was set. Has anyone figured this out or is it just something we have to deal with?

Please Log in or Create an account to join the conversation.

More
13 years 9 months ago #80340 by Darrell Mobley
Replied by Darrell Mobley on topic Introtext word limit
The reality is the code is not written to do what you want it to do. If you want to limit the word count of the Subcategories descriptions, you will have to modify the code.

As referenced in your post, you are looking at the Introtext limit. That is not what is displayed on category pages with subcategories shown. Instead of "Introtext", it uses "subCatDescription", a parameter that is written to the database.

Here's how to modify your code:

In the K2 administrative backend, editing a category, if you look at the parameters section, click on "Category view options" and search for "Sub-category description". There should be a place there to specify how many words to limit the description to, but there is not.

So open up /administrator/components/com_k2/models/category.xml

Go down to line 133, where it has a parameter for sub-category image. Insert this text before line 133:

<param name="subCatDescriptionTextWordLimit" type="text" default="" size="4" label="Sub-category description word limit" description="Limit the sub-category descriptions to this number of words. If this option is enabled, all HTML tags in the introtext will be cleaned up to make sure the site markup will not break." />

The description of the Introtext word limit when you hovered over it doesn't really address the word count: "If this option is enabled, all HTML tags in the introtext will be cleaned up to make sure the site markup will not break." The wording above makes more sense.

Save the file. Now, open /components/com_k2/templates/default/category.php

Go down to line 98, where it is referencing subCatDescription. Replace line 98 with the following code:

<?php if($this->params->get('subCatDescription')):
if ($item->params->get('subCatDescriptionTextWordLimit')) {
$subCategory->description = K2HelperUtilities::wordLimit($subCategory->description, $item->params->get('subCatDescriptionTextWordLimit'));
} ?>

Set the word count in your categories and the category descriptions will display like you want.

Be sure that if your template uses custom HTML in the template's directory, references to the $item object will probably need changing to the $this object. Such as $item->params->get('subCatDescriptionTextWordLimit') would become $this->params->get('subCatDescriptionTextWordLimit').

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago #80341 by Ruud
Replied by Ruud on topic Introtext word limit
Tried this but could not get it to work, even after figuring out that the line numbers were not correct (I'm using 2.4.1) and after correcting the incomplete php code (end if is missing). I get the box to set the word limit but I get NO description.

 

BTW: I did change the $item to $this.... which solved the errors I kept getting. Replacing the category.php file with the original gives me the entire Description again so the key is in there somehow.

 

Any thoughts? Should I change this line too? <?php if($this->params->get('subCatDescription')): ?>

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago #80342 by L Nathan
Replied by L Nathan on topic Introtext word limit
Ei Ruud U Fix it ? 

U got introtext/wordlimit/automatic readmore for multiple categories ?!

 

 

How u Fix this ?!

[]'s

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago #80343 by aneesh
Replied by aneesh on topic Introtext word limit
Hi! I'm kind of new to Joomla and K2. First of all, you guys are awesome here, so much of caring and sharing is happening in Open source world!!

 

Well, I browsed through many forums and all of those didn't solve my problem. This was what I wanted to get. I added a new Menu item, which suppose to fetch all the latest articles from various categories and display it on my home page. I tried to work around with controlling introtext length in Categories, etc. But it didn't help me. For a last resort I simply tried to add "Read more" (In K2 article editor, you will need to enable JCE editor in Site >> Global configuration >> Default WYSIWYG Editor >> Editor JCE) after a paragraph in the article and there you go!! It did what I wanted, a neatly put home page with few lines from latest articles with a Read more link..!!

 

This may be a stupid solution for those advanced users tho, hehe...

Thanks!!

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago #80344 by Ruud
Replied by Ruud on topic Introtext word limit
Hi aneesh,

 

Reading your post it looks like you are limiting the number of words displayed of an Item, right? What I am trying to do is after selecting a category (in Catalog Mode) displaying its subcategories including a few words from their description. Would the "Read More" work for that too? 

 

O and there are no stupid solutions, as long as they work!

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago #80345 by aneesh
Replied by aneesh on topic Introtext word limit
Hi Ruud,

 

I get what you mean, I didn't try that. I'm now trying to add "Read More" in every articles that I write and see if it works...'ll post updates here :)
Ruud said:

Hi aneesh,

 

Reading your post it looks like you are limiting the number of words displayed of an Item, right? What I am trying to do is after selecting a category (in Catalog Mode) displaying its subcategories including a few words from their description. Would the "Read More" work for that too? 

 

O and there are no stupid solutions, as long as they work!

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago #80346 by David Pérez
Replied by David Pérez on topic Introtext word limit
Hey guys, I might have found a solution, at least it's working for me, it needs a bit of editing but it does the trick, just test it at your own risk cos it may have side effects.

community.getk2.org/forum/topics/how-fix-introtext-word-limit?commentId=3536014:Comment:170446

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum