- Posts: 10
COMMUNITY FORUM
Shorten title length all title items
- keichi
-
Topic Author
- Offline
- New Member
Less
More
11 years 1 month ago #127894
by keichi
Shorten title length all title items was created by keichi
Hi everyone.
Lets suppose an article with a long title , i.e. "John Doe, His Life, His Work, His Expectations and His Writings"
I'd like display the following title "John D, His Life,....." in all layout&view (categories, users, tag, etc).. I need display all titles cause, other way break my desing.
Thanks.
Lets suppose an article with a long title , i.e. "John Doe, His Life, His Work, His Expectations and His Writings"
I'd like display the following title "John D, His Life,....." in all layout&view (categories, users, tag, etc).. I need display all titles cause, other way break my desing.
Thanks.
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
Less
More
- Posts: 8743
11 years 1 month ago #127895
by Lefteris
Replied by Lefteris on topic Re: Shorten title length all title items
Hi. There is no automatic way to do this. You need to write some code. There are two ways:
1. Using CSS. You can use the "text-overflow" rule. Details can be found at developer.mozilla.org/en-US/docs/Web/CSS/text-overflow .
2. Using PHP. You will have to create overrides for K2 templates. First read getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates to get familiar with K2 templates. Then you will be able to use something like that:
Note that this example refers to the item.php layout. Code for other layouts should be similar.
1. Using CSS. You can use the "text-overflow" rule. Details can be found at developer.mozilla.org/en-US/docs/Web/CSS/text-overflow .
2. Using PHP. You will have to create overrides for K2 templates. First read getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates to get familiar with K2 templates. Then you will be able to use something like that:
<?php echo K2HelperUtilities::characterLimit($this->item->title, 10); ?>
Note that this example refers to the item.php layout. Code for other layouts should be similar.
Please Log in or Create an account to join the conversation.
- keichi
-
Topic Author
- Offline
- New Member
Less
More
- Posts: 10
11 years 4 weeks ago #127896
by keichi
Hi, thanks a lot.
Where do I need to put this code, I mean, before or after which line inside the category layout?
Replied by keichi on topic Re: Shorten title length all title items
Lefteris Kavadas wrote: Hi. There is no automatic way to do this. You need to write some code. There are two ways:
1. Using CSS. You can use the "text-overflow" rule. Details can be found at developer.mozilla.org/en-US/docs/Web/CSS/text-overflow .
2. Using PHP. You will have to create overrides for K2 templates. First read getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates to get familiar with K2 templates. Then you will be able to use something like that:
<?php echo K2HelperUtilities::characterLimit($this->item->title, 10); ?>
Note that this example refers to the item.php layout. Code for other layouts should be similar.
Hi, thanks a lot.
Where do I need to put this code, I mean, before or after which line inside the category layout?
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
Less
More
- Posts: 8743
11 years 4 weeks ago #127897
by Lefteris
Replied by Lefteris on topic Re: Shorten title length all title items
@keichi
This depends on you. You need to place it wherever you want the title to be displayed. If you don't want to change the current position of the title just place it where your current title is.
This depends on you. You need to place it wherever you want the title to be displayed. If you don't want to change the current position of the title just place it where your current title is.
Please Log in or Create an account to join the conversation.