ldriver
I'm new here

Can CMS_INPUT_TEXTAREA parse CMS_REF values?

Jump to solution

I have a CMS_INPUT_TEXTAREA where custom scripts can be entered, and I want to use CMS_REF(media:"file"), for a JS file I have in the media store, but it doesn't seem to be able to parse, it keeps showing in the html as the literal CMS_REF.  Is there a way to parse that or another technique I can use?

0 Kudos
1 Solution

Accepted Solutions

Hi,

I don't think this is possible. But probably you could alter your form for this use case a little bit. You could give the editor the option to enter script code in the CMS_TEXT_AREA and to select script files from the media store that should be included using a FS_REFERENCE. That way you wouldn't have to parse the text in the text area.

Hope that helps.

Regards

Tim

View solution in original post

0 Kudos
5 Replies
MichaelaReydt
Community Manager

Hello,

I am not sure if I understand your scenario.

You first describe the custom scripts before you mention your JS file. Do they have any context to each other?

Could you show us the part of your code where you use the CMS_REF to link the JS file?

Best regardsMichaela

0 Kudos

Hi Michaela, thanks for the reply.  I have a page template that has input for custom scripts:

custom_scripts2.png

When we're building the pages to add a custom script on the page if needed.  The type for this is CMS_INPUT_TEXTAREA.

I was wondering if there was a way to do this in that field:

<script type="text/javascript" src="$CMS_REF(media:"script")$"></script>

Right now, it seems that the CMS_REF won't parse, it shows up as the literal string $CMS_REF(media:"script")$, and I need to move it (for now) to the output channel in the HTML, which is not ideal because then all pages created with this template with include the script, where I only want it include where it's added in custom page scripts.  Is there something I can do to get that work, or another technique?

0 Kudos

Hi,

I don't think this is possible. But probably you could alter your form for this use case a little bit. You could give the editor the option to enter script code in the CMS_TEXT_AREA and to select script files from the media store that should be included using a FS_REFERENCE. That way you wouldn't have to parse the text in the text area.

Hope that helps.

Regards

Tim

0 Kudos

Thanks for the reply.  Good idea, that solves my problem and is simple.

0 Kudos

Why not use "stTextArea.parse" ??? Then all text in the area will be parsed. I think that is what you want.

0 Kudos