Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Dynamic argument in template


Go to End


4 Posts   1175 Views

Avatar
bubu333

Community Member, 8 Posts

28 November 2012 at 3:42pm

Hi,I have a Title but it's so long,i want to cut string with 40 character and i write a function for do it.
function cutString($name,$limit)
{
....write code
}

And in template,i want to insert $Name and $Description(two field in database) into argument of cutString function
But it's not work.
I write <% control cutString($Name,40) %><% end_control %> not work
I write $cutString($Name,40) not work
I write $cutString(Name,40) not work
I don't know how can implement function with dynamic argument in template :(

Avatar
swaiba

Forum Moderator, 1899 Posts

28 November 2012 at 7:34pm

SS2.x.x or SS3.x.x?

Avatar
bubu333

Community Member, 8 Posts

28 November 2012 at 7:46pm

Version 2.4.7.Please help

Avatar
swaiba

Forum Moderator, 1899 Posts

28 November 2012 at 7:53pm

Answer is *not possible* sorry.

If you are using SS3 answer is - yes - possible.

Best I can advise in SS2.x.x is this http://www.silverstripe.org/template-questions/show/13619#post304007#post304007

Good luck!