Adds extra methods to Silverstripe DBStrings to help manipulate them.
Adds extra methods to Silverstripe DBStrings to help manipulate them.
Composer is the recommended way of installing SilverStripe modules.
composer require gorriecoe/silverstripe-dbstringextras
Replace all occurrences of the search string with the replacement string.
PHP
$this->obj('MyString')->StrReplace('Search value', 'Replacement value')
Template
{$MyString.StrReplace('Search value', 'Replacement value')}
Input = Output
Ullamcorper Tellus Search value Egestas
=
Ullamcorper Tellus Replacement value Egestas
Converts this camel case and hyphenated string to a space separated string.
PHP
$this->obj('MyString')->Nice()
Template
{$MyString.Nice}
Input = Output
UllamCorper1tspHTML_-_Bibendum-egestas-1-1
=
Ullam Corper 1tsp HTML - Bibendum egestas 1-1
Converts this camel case string to a hyphenated, kebab or spinal case string.
PHP
$this->obj('MyString')->Hyphenate()
Template
{$MyString.Hyphenate}
Input = Output
Ullamcorper Tellus Sollicitudin Bibendum Egestas
=
ullamcorper-tellus-sollicitudin-bibendum-egestas
Removes spaces from this string.
PHP
$this->obj('MyString')->RemoveSpaces()
Template
{$MyString.RemoveSpaces}
Input = Output
Ullamcorper Tellus Sollicitudin Bibendum Egestas
=
UllamcorperTellusSollicitudinBibendumEgestas
Converts square brackets [] within this string to a spans with css class.
PHP
$this->obj('MyString')->Highlight()
Template
{$MyString.Highlight}
or
{$MyString.Highlight('MyClass')}
Input = Output
Ullamcorper [Tellus] Sollicitudin Bibendum Egestas
=
Ullamcorper <span class="highlight">Tellus</span> Sollicitudin Bibendum Egestas
Separates this string by lines into an ArrayList.
Template
<% loop MyString.SplitLines %>
<div>
{$Line}
</div>
<% end_loop %>
Input = Output
Maecenas sed diam eget risus varius blandit sit amet non magna.
Etiam porta sem malesuada magna mollis euismod.
=
<div>
Maecenas sed diam eget risus varius blandit sit amet non magna.
</div>
<div>
Etiam porta sem malesuada magna mollis euismod.
</div>
Separates this string by specified the delimiter.
Template
<% loop String.Explode(',') %>
<li>
{$Value}
</li>
<% end_loop %>
Input = Output
Aenean,Purus,Dolor,Magna
=
<li>Aenean</li>
<li>Purus</li>
<li>Dolor</li>
<li>Magna</li>
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem