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.

We've moved the forum!

Please use for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

Insert html shortcode | WYSIWYG? | page specific

Go to End

2 Posts   1225 Views


Community Member, 16 Posts

22 August 2016 at 9:14pm

A number of pages on my site must include an audio player that allows visitors to play a self-hosted track that relates specifically to the viewed page. Normally I would embed the following html to the player's engine straight into the page's code but with Silverstripe's WYSIWYG Editor that's not an option, as it rejects the inclusion of 'copied-in' code in html viewing mode.

I have not yet investigated whether it's possible to modify the editor to accept 'copied-in' code; not sure whether that could be an option too...

So, I am now looking for ways to inject code - such as the following - through my WYSIWYG in the appropriate pages:

<!-- Start of audio player body section html codes -->
<div id="AUDIOPLAYER_ID" style="display:block;position:relative;width:360px;height:auto;margin:0px auto 0px;">
<ul class="AUDIOPLAYER_CLASS" style="display:none;">
<li data-artist="TRACK_ARTIST" data-title="TRACK_TITLE" data-album="ALBUM_NAME" data-info="TRACK_INFO" data-image="TRACK_IMAGE" data- duration="TRACK_MINS">
<div class="TRACKSOURCE" data-src="SELF_HOST_TRACK_URL" data-type="audio/mpeg" />
<!-- End of body section HTML codes -->

Note: For what it's worth, each audio player will have its own ID "AUDIOPLAYER_ID" to ensure pages can hold multiple players.

Can anyone share any wisdom on how to achieve this best, either through shortcodes or through a WYSIWYG intervention?

Heaps of thanks in advance!


Forum Moderator, 1899 Posts

23 August 2016 at 7:36pm