Jump to:

23368 Posts in 18143 Topics by 2863 members

General Questions

SilverStripe Forums » General Questions » Including $Classes in URLs

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

Page: 1
Go to End
Author Topic: 611 Views
  • marc79
    Avatar
    Community Member
    65 Posts

    Including $Classes in URLs Link to this post

    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

  • marc79
    Avatar
    Community Member
    65 Posts

    Re: Including $Classes in URLs Link to this post

    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>

  • Devlin
    Avatar
    Community Member
    215 Posts

    Re: Including $Classes in URLs Link to this post

    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>

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Including $Classes in URLs Link to this post

    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

  • marc79
    Avatar
    Community Member
    65 Posts

    Re: Including $Classes in URLs Link to this post

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

    611 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.