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.

Problems interpreting EE tags within script tags

August 02, 2011 2:43pm

Subscribe [3]
  • #1 / Aug 02, 2011 2:43pm

    Stephan Tran

    7 posts

    This question may be related to a resolved thread.

    I’m trying to insert a simple conditional statement within a SCRIPT tag. Basically, I’m using Channel Images along with a script called supersized, and I need EE to insert a comma between all Channel Image entries, except at the end of the entries (IE compatibility issues).

    The problem:
    the if statement does not seem to be recognized as an EE tag so the code outputs commas everywhere. I’ve tried all variations of the $config[‘debug’] variable but this never gives me the proper output. Of course, outside of the script tag, the same code works perfectly well.

    slides                     :      [        //Slideshow Images2-te3
                        {exp:channel:entries channel="{mychannel}"}
                        {exp:channel_images:images entry_id="{structure:page:entry_id}"}
                        {
                            image : '{image:url:home_bg}'}
                        {if '{image:count}' < '{image:total}'}
                        ,
                        {/if}
                        {/exp:channel_images:images}
                        {/exp:channel:entries}
                                                    ]

    Notes
    I placed the opening curly bracket on a different line before the statement image : ‘{image:url:home_bg}’} so that EE would not read this as an EE tag since it’s part of the script parameter syntax.

    Any suggestions as to what I could try to resolve this?

    Output sample with $config[‘debug’] = “1”

    slides                     :      [        //Slideshow Images2-te3
                        
                        
                        {
                            image : 'http://paxrodentiaprotege1.dyndns.org:8888/mwa002b/images/channel-images/34/homepage-4__home_bg.jpg'}
                        {if '1' < '10'}
                        ,
                        {/if}
                        
                        {
                            image : 'http://paxrodentiaprotege1.dyndns.org:8888/mwa002b/images/channel-images/34/homepage-5__home_bg.jpg'}
                        {if '2' < '10'}
                        ,
                        {/if}

                 
    etc…

    Output sample with $config[‘debug’] = “0” (the if EE tags seem to be ignored, the page outputs a comma no matter what)

    slides                     :      [        //Slideshow Images2-te3
                        
                        
                        {
                            image : 'http://paxrodentiaprotege1.dyndns.org:8888/mwa002b/images/channel-images/34/homepage-4__home_bg.jpg'}
                        
                        ,
                        
                        
                        {
                            image : 'http://paxrodentiaprotege1.dyndns.org:8888/mwa002b/images/channel-images/34/homepage-5__home_bg.jpg'}
                        
                        ,

    etc…

  • #2 / Aug 02, 2011 3:06pm

    LMO

    203 posts

    I believe you need to seperate the curly brackets like this:

    slides                     :      [        //Slideshow Images2-te3
                        {exp:channel:entries channel="{mychannel}"}
                        {exp:channel_images:images entry_id="{structure:page:entry_id}"} {
                            image : '{image:url:home_bg}'
                         }
                        {if '{image:count}' < '{image:total}'}
                        ,
                        {/if}
                        {/exp:channel_images:images}
                        {/exp:channel:entries}
                                                    ]

    The opening bracket doesn’t need to be on a new line, you just can put anything after it. The closing bracket should be on a new line. Not sure if this solves the problem you are having since I have not set up a test case yet.


    EDIT: have you tried using the backspace parameter and forgoing the if statement?

  • #3 / Aug 02, 2011 3:19pm

    Stephan Tran

    7 posts

    Thanks for you suggestion VI! The mod you sent did not change the issue with the lack of parsing for the IF statement. Backspace will work perfectly in this case!

    However, I am still curious as to how/why this issue is still happening?

    I also found another post relating to the process of IF statements within a script parameter: http://ellislab.com/forums/viewthread/194445/

    This was not really solved either…

  • #4 / Aug 03, 2011 9:20am

    Dan Decker

    7338 posts

    Hello Stephan,

    Welcome to ExpressionEngine and the forums!

    Just to clarify, VIM’s suggestion of the backspace parameter is getting you the results you are looking for, correct? But that doesn’t answer the question of why your conditional wasn’t processing properly.

    What version and build of ExpressionEngine are you using? This info is available in the footer of your Control Panel. Do you have the template type set to Javascript for the template in question?

    Best,

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

ExpressionEngine News!

#eecms, #events, #releases