xhtml keeps changing my javascript, pass-through code is not working.

ssuh's Avatar

ssuh

09 Feb, 2012 08:58 PM

What options do I have to include javascript? I keep getting a wellformed error with text blocks when including javascript. The xhtml block keeps changing my javascript....

  1. 1 Posted by Eric L. Epps on 09 Feb, 2012 11:05 PM

    Eric L. Epps's Avatar

    I usually either have it as a separate .js file or put it in a text block and apply that block to a region just before the closing body tag. I've created regions called "script1" and "script2" so that, when a page needs custom JavaScript, I can easily put the JavaScript text block in one of those.

  2. 2 Posted by Charlie Holder on 20 Mar, 2012 01:22 PM

    Charlie Holder's Avatar

    Following up with some older posts.

    I also use external Javascript files when possible.

    When I'm using an XHTML Block for Javascript, I usually turn off HTML Tidy. Because of this, I usually use an XML Block instead depending on the content I'm trying to store. If you're trying to submit only Javascript (or even a small amount of straight HTML) I would use an XML Block. I think it's great for entering HTML content that wouldn't lend itself to being managed through the WYSIWYG interface.

    Hope this helps.

  3. Charlie Holder closed this discussion on 03 Apr, 2012 08:26 PM.

  4. ssuh re-opened this discussion on 30 May, 2012 08:11 PM

  5. 3 Posted by ssuh on 30 May, 2012 08:11 PM

    ssuh's Avatar

    Is there any way to get the CMS to recognize image links inside of a javascript file?

    If I use a document.write(image link).

    Steve

  6. 4 Posted by Artur on 30 May, 2012 09:03 PM

    Artur's Avatar

    Yes, File assets have "Rewrite links in file" checkbox that needs to be checked first. Then, anything that is a link to another File or Page needs to be wrapped in [system-asset] tags. For example:

    document.write('[system-asset]/path/to/file.jpg[/system-asset]')

  7. Artur closed this discussion on 30 May, 2012 09:03 PM.

  8. ssuh re-opened this discussion on 30 May, 2012 09:12 PM

  9. 5 Posted by ssuh on 30 May, 2012 09:12 PM

    ssuh's Avatar

    Does it work with string concatentation?

    document.write('[system-asset]<img src="/_assets/images/mastheads/general/' + images[foo] +' [/system-asset]'+ '" border="0" alt="' + alt[foo] + '" title="' + alt[foo] + '" align="left" />');

    Steve

  10. 6 Posted by Artur on 30 May, 2012 09:26 PM

    Artur's Avatar

    No, between [system-asset] tags there must be path only. No <img> tag or anything concatenated. The only place that concatenation can occur is formats. For example, this will work:

    #set( $s = 'starting' )
    [system-asset]/${s}-page[/system-asset]
    

    and will show a link to /starting-page correctly updated. However, even in this case, the link will not be managed by Cascade Server so that if you move or rename that page, the link will become broken.

    However, if you have full path between [system-asset] tags, then that link will be managed by Cascade Server so that if you move or rename the linked-to asset, the link itself will get automatically updated.

  11. Artur closed this discussion on 30 May, 2012 09:27 PM.

  12. ssuh re-opened this discussion on 30 May, 2012 09:30 PM

  13. 7 Posted by ssuh on 30 May, 2012 09:30 PM

    ssuh's Avatar

    Thanks. We have a random image masthead with some javascript. It justs a document write to an image src with an array.

    I guess we'll have to rethink this...

    Steve

  14. Bradley Wagner closed this discussion on 31 May, 2012 08:44 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

 

26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM