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.

how to avoid conflict with js that uses { brackets

September 01, 2010 4:43pm

Subscribe [4]
  • #1 / Sep 01, 2010 4:43pm

    Ryan 2010

    265 posts

    I have this code:

    [removed]
            stLight.options({
                    st_url:'http://www.site.com/index.php/news/article/{url_title}'
            });


    {url_title} is not being rendered and I figure it is because it is inside js { brackets.

    What would be the PHP solution to fix this?

    Thanks
    Ryan

  • #2 / Sep 01, 2010 8:03pm

    ROCKET MEDIA

    153 posts

    Maybe escape the brackets like this:

    stLight.options({
             st_url:'http://www.site.com/index.php/news/article/\{url_title\}'
    });

    But that probably will not work since EE renders before Javascript…
    Maybe just output it through PHP?

    <?php
    echo "stLight.options({ st_url:'http://www.site.com/index.php/news/article/" . "{url_title}" . "'});"
    ?>
  • #3 / Sep 02, 2010 8:03am

    Sue Crocker

    26054 posts

    Thanks for the assist, RocketMedia.

    Ryan, does that help?

  • #4 / Sep 02, 2010 5:55pm

    Ryan 2010

    265 posts

    I responded earlier but it didn’t get posted.

    Yes the php solution did the trick. thanks.

  • #5 / Sep 02, 2010 9:06pm

    Brandon Jones

    5500 posts

    Ryan, also make sure you keep your Debug Preference is set to 1: PHP/SQL error messages shown only to Super Admins. Note the blue tip in the docs:

    Furthermore, for those utilizing Javascript that may resemble EE code, including curly brackets, this setting must be 1 in order for the Javascript to function, or ExpressionEngine will hide Javascript output believing it to be an error.

    Glad you have a solution!

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

ExpressionEngine News!

#eecms, #events, #releases