Hi,
I am fairly new to silverstripe and need some help with slugs.
I have a database containing products categorised by Type and Range
Slugs are used to access the correct information from the database using the following format
www.mydomain.com/products/thetype/therange/theproduct
ie. www.mydomain.com/products/computers/desktop/computermodel
All of this was written by someone else, and it works very well.
I need to create using the same slug format, some information blocks that would be accessible via www.mydomain.com/products/thetype/therange/informationblock1
In my ProductRange class, I have
private static $has_many = array(
'InformationBlocks' => 'InformationBlock'
);
in my InformationBlock class, I have
private static $has_one = array(
'Range' => 'ProductRange'
);
This allows me to create multiple information blocks in the backend and it all works well
In the frontend pages, I am able to display all my information blocks, depending on which range I am viewing
<% loop $InformationBlocks %>
<li<% if $MultipleOf(3) %> class="last"<% end_if %>>
<h3>$Title</h3>
<img src="$Image.SetWidth(600).CroppedImage(600,400).URL"
alt="$Image.Title" title="$Image.Title" >
$Body
<a href="$Top.Link()$Top.Type.Slug/$Top.Range.Slug/$Slug">Visit</a>
</li>
<% end_loop %>
The issue I have, is that silverstripe does not have a value for $Slug the link to the information block.
<a href="$Top.Link()$Top.Type.Slug/$Top.Range.Slug/$Slug">Visit</a>
I do not understand how the $Slug variable gets created by Silverstripe and why it adds it for the type and Range but not for the information blocks
I set my InformationBlock class as follow thinking it would help, but it has not done the trick
class InformationBlock extends SlugModel
Would anyone have a suggestion?