ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Javascript array isn't allowing EE tags to be read by template

September 17, 2009 3:01am

Subscribe [3]
  • #1 / Sep 17, 2009 3:01am

    Blue Coast Web

    32 posts

    Hi,

    I’m trying to implement this slideshow:
    http://smoothslideshow.jondesign.net/index.html

    I got everything working just fine with static HTML, but when I try to replace the array information with EE tags, it doesn’t read anymore.

    There are four variables the array uses: image URL, a link the image goes to when clicked, an image title, and an image description.

    I’m using Field Frame’s FFMatrix feature to give me these four variables (my field type is called {homephoto} and the four variables are self explanatory).

    I’ve wrapped the repeating array code like so, assuming it will repeat for as many rows as I have in FFMatrix:

    {homephoto}
    mySlideData[countArticle++] = new Array(
    '{site_url}{image}',
    '{imagelink}',
    '{image1title}',
    '{imagedesc}'
    );
    {/homephoto}

    I’m getting along fine with EE but I’m afraid I’m new with JavaScript. I have added the argument to my config file to not disrupt JavaScript code to no avail. I think the problem is that JavaScript treats array information very literally, so it outputs the raw EE tags instead of letting the template read them.

    I’ve tried using different encoding for the curly braces, and tried using PHP “echo” and “print” to spit out the array information, again to no avail.

    Anyone have any workarounds in JavaScript that will let EE tags be read inside an array?

  • #2 / Sep 17, 2009 3:27am

    John Henry Donovan

    12339 posts

    bcw,

    What is your debug preference set to?

    Admin ›  System Preferences ›  Output and Debugging Preferences

  • #3 / Sep 17, 2009 3:28am

    Blue Coast Web

    32 posts

    $conf[‘debug’] = “1”;

  • #4 / Sep 17, 2009 3:32am

    John Henry Donovan

    12339 posts

    bcw,

    What type of template are you using?

    Does this work for you?

    {homephoto}
    {site_url}{image}
    
    {imagelink}
    
    {image1title}
    
    {imagedesc}<hr>
    
    {/homephoto}
  • #5 / May 10, 2010 2:58am

    mhulse

    329 posts

    bcw,

    Try this:

    Admin >> System Administration >> Config File Editor

    At the bottom put “protect_javascript” in the left field and “n” in the right field.

    Press “Update”.

    That worked for me (I am also using Matrix).

    Hths!

    Cheers,
    Micky

  • #6 / May 10, 2010 3:00am

    mhulse

    329 posts

    Lol, I should read the date before replying to an entry…

    Using EE2.0, my solution should work. Hopefully it will help others searching for a fix. 😊

    FWIK, “protect_javascript” is not a default config option in EE2.

    Sorry to resurrect an old thread here. :(

  • #7 / May 10, 2010 3:17am

    John Henry Donovan

    12339 posts

    mhulse, no problems. I’m sure it will help somebody. Closing this old thread out. Feel free to start a new thread if you have any other questions.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases