| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Truncating text with an Output Filter | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
Truncating text with an Output Filter
There's a guide here for making your own output filter.. http://kb.x-cart.com/display/XDD/Flexy+Guide
I found this method easier... create a file called ShortenText.php in your View folder of your theme classes like this... Code:
Then create a copy of the template you want to add the filter to and put it in your template theme folder ie skins/Customer/CustomerTheme/en/modules/XC/News/top_news_messages/list/parts/ I'm adding the filter to the news summary to show the same number of characters. My template looks like this... Code:
to give something like this on the page... <snip> they buy and... Read more It all works well but... how do I make so I can choose the number of characters to show from the template? IE something like {model.brief_description:ShortenText(100)} to show 100 characters.
__________________
Core version: 5.5.xx |
|||||||
|
#2
|
|||||||||
|
|||||||||
Re: Truncating text with an Output Filter
First of all it is extremely cool that you created your own modifier!
I don't know of any examples where a modifier is passed a value. I'm sure it could be done, but you might have to modify: Code:
Reading through the method above, I think it would have to have another argument added, like: protected function flexyModifierCall($callMethod, $expr, $params = NULL) Then you could pass it some parameters and use those in your call. But I am just not sure that it is wired that way. Probably I would just create a method that shortened the text with 2 arguments, value and length.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey XcartGuru X-cart Tutorials | X-cart 5 Tutorials Check out the responsive template for X-cart. |
|||||||||
|
#3
|
|||||||||
|
|||||||||
Re: Truncating text with an Output Filter
Quote:
I would just create a plain method with two arguments and used it in the template: PHP Code:
Code:
However, I believe you don't need this method in _every_ widget on the page. So, it makes sense to put it into the widget class where you need it instead of decorating the base \XLite\View\AView class.
__________________
Alex Solovev, Qualiteam --- User manual Video tutorials X-Cart FAQ You are welcome to press "Thanks" button if you find this post useful Click here to learn how to apply patches X-Cart Extensions |
|||||||||
|
|||
X-Cart forums © 2001-2020
|