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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Including $Classes in URLs


Reply

5 Posts   648 Views

Avatar
marc79

26 May 2011 at 1:07am Community Member, 65 Posts

Hello,

I am building a site that includes music samples and want to be able to call a track, saved in the assets folder, based on the track and volume you are viewing.

rather than storing an extra column in the database with all the full src I was hoping to be able to name the tracks accordingly, upload them to the assets folder and then call them with something like the below but it doesn't work.

<embed src="/assets/music/$VolumeNumber/$TrackNumber.mp3" autostart="False" height="16px" width="17px" volume="45"/></td>

Is there a way to make this work or do I need to take a different approach?

Many thanks

Marc

Avatar
marc79

26 May 2011 at 1:31am Community Member, 65 Posts

So I have found that adding in ' works tho it is quite messy so if there is a better way of doing this I'd love to know.

I now have:

<embed src="/assets/music/volume'$VolumeNumber'/track-'$TrackNumber'.mp3" autostart="False" height="16px" width="17px" volume="45"/></td>

which gives me something like:

<embed src="/assets/music/volume'2'/track-'2'.mp3" autostart="False" height="16px" width="17px" volume="45"/></td>

Avatar
Devlin

26 May 2011 at 2:35am (Last edited: 26 May 2011 2:35am), Community Member, 215 Posts

You should escape variables in templates with curly brackets.

<embed src="/assets/music/{$VolumeNumber}/{$TrackNumber}.mp3" autostart="False" height="16px" width="17px" volume="45"/></td>

Avatar
banal

26 May 2011 at 2:36am (Last edited: 26 May 2011 2:37am), Community Member, 901 Posts

Did you try curly brackets instead of single quotes? Something like this should work:

<embed src="/assets/music/volume{$VolumeNumber}/track-{$TrackNumber}.mp3" autostart="False" height="16px" width="17px" volume="45"/></td>

Maybe I completely misread your question though ;)

Edit: Devlin beat me to it :)

Avatar
marc79

26 May 2011 at 2:47am Community Member, 65 Posts

Thank you both. That's exactly what I was looking for!