How can I remove spaces output in my template? For example I have a $Brand some of these output as two words as the are in my php variables as TommyHilfiger. Output becomes "Tommy Hilfiger". This is great for front end display but how can I render it as TommyHilfiger or Tommy-Hifiger? I want to use them as css classes in my html. Like $Brand.Nospaces for example. Or does it need to be done in the PHP?
PHP
<?php
class ProductPage extends Page {
// Contact object's fields
public static $db = array(
'Brand' => 'Varchar(255)'
);
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Details",
new DropdownField("Brand", "Brand",
array(
"Adidas" => "Adidas",
"AmericanSportsTeams" => "American Sports Teams",
"United Colors of Benetton" => "United Colors of Benetton",
"Valentino" => "Valentino",
)
)
);
return $fields;
}
}
class ProductPage_Controller extends Page_Controller {
}
Template ProductPage.ss
<% loop Children %>
<li class="$Brand">
<a href="$Link">
<figure style="background-image: URL(<% loop $ProductImages.limit(1,1) %>$Fill(400,600).URL<% end_loop %>);">
<img src="<% loop $ProductImages.limit(1) %>$Fill(400,600).URL<% end_loop %>" alt="$Title"
class="snipcart-add-item"
data-item-id="P$ID $MenuTitle"
data-item-max-quantity="1"
data-item-stock="1"
data-item-name="$Title"
data-item-price="<% if $SalePrice %>$SalePrice<% else %>$Price<% end_if %>"
data-item-description="$Content"
data-item-image="<% loop $ProductImages.limit(1) %>$Pad(50,50).URL<% end_loop %>">
</figure>
<div id="pro-deets">
<h3>$Title</h3>
$Brand
</div></a>
</li>
<% end_loop %>
Maybe with:
$filter = URLSegmentFilter::create(); $className = $filter->filter($title);
I'm just not clear how to apply this to $Brand it would need to put in the template as $BrandNoSpace or something as I need to use $Brand with its spaces too for the displayed txt.