![]() |
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:
<?php 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. |
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. |
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. |
All times are GMT -8. The time now is 11:42 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.