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.

Parameter with quotes in {embed} tag

December 19, 2011 6:35pm

Subscribe [3]
  • #1 / Dec 19, 2011 6:35pm

    eedfwChris

    54 posts

    How can I embed a variable into {embed} which has quotes without it barfing up (stopping at the quote) when it contains quotes?

    For instance if my {foo} = “My awesome quot’d variable with paren"thesis”.

    I can’t pass it into an embed using any method.

    {embed='embeds/_foo' string='{foo}'}

    I should also note that the reason I’m using {embed} because I am trying to “inwardly” parse something for use in another tag so any sort of addslashes using say, phpfunstring, seems futile.

    Seems there needs to be a sort of

    {embed='embeds/_foo' string='$foo'}

    and EE knows it’s a variable or something wonky.

  • #2 / Dec 20, 2011 6:37pm

    Sean C. Smith

    3818 posts

    Hi webPragmatist,

    I’ve successfully embedded variables with quotes by using double quotes around the part to be embeded and single quotes on the interior content.

    Here is an embed i copied from a site that i built a while ago:

    {embed="includes/meta" 
       my_title="{if segment_2 !=''}{exp:channel:entries channel='gallery' disable='categories|pagination|member_data' limit='1'}{title}{/exp:channel:entries} |{/if}{bbr-mls-photogallery}"
    }

    You can see that it is quite long but all the interior quotes are single quotes with the variable my_title=”” wrapping with double quotes.

    Does that help?
    If it doesn’t, please explain further where you are having trouble.

    Sean

  • #3 / Dec 20, 2011 6:53pm

    eedfwChris

    54 posts

    Hi webPragmatist,

    I’ve successfully embedded variables with quotes by using double quotes around the part to be embeded and single quotes on the interior content.

    Here is an embed i copied from a site that i built a while ago:

    {embed="includes/meta" 
       my_title="{if segment_2 !=''}{exp:channel:entries channel='gallery' disable='categories|pagination|member_data' limit='1'}{title}{/exp:channel:entries} |{/if}{bbr-mls-photogallery}"
    }

    You can see that it is quite long but all the interior quotes are single quotes with the variable my_title=”” wrapping with double quotes.

    Does that help?
    If it doesn’t, please explain further where you are having trouble.

    Sean

    Uh? In your example if you had a ” in your {title} tag you’d be up a creek. Can you elaborate?

  • #4 / Dec 20, 2011 7:19pm

    Sean C. Smith

    3818 posts

    webPragmatist,

    Sorry for misunderstanding your post. I’ve since gone into my sandbox install and created an entry with a title that had quotes “” in it.

    I then created the following template

    {exp:channel:entries channel="blog" limit="1"}
     This is a raw title: {title}
     This is an embedded title: {embed="site/boo" foo="{title}"}
    {/exp:channel:entries}

    And then in the embed template:

    foo == {embed:foo}

    Is the variable you are trying to pass through in a global variable? if so then you may be running into trouble due to parsing order. See this excellent pdf for the low down on parsing order by @Low.

    Sean

    On the front end I was my double quotes were successfully output and I could see the following:

    This is a raw title: This title has “quotes” in it.

    This is an embedded title: foo == This title has “quotes” in it.

  • #5 / Dec 20, 2011 9:51pm

    eedfwChris

    54 posts

    Hey Sean,

    Thanks for working with me on this. Let me post some of my code to give you a better idea of what I’m having an issue with. I’m having to use the embed specifically due to parse order.

    {exp:ajw_feedparser url="{embed:url}" limit="5"}
     {
     "cell_type":"text",
     "cell_text":{embed='embed/_json_encode' string='{title}'},
     "cell_link_type":"Link",
     "cell_link_url":"{link}"
     }
     {if {count} < {total_results}}, {/if}
    {/exp:ajw_feedparser}
    {exp:phpstringfun function="json_encode"}
     {embed:string}
    {/exp:phpstringfun}

     

  • #6 / Dec 22, 2011 1:42am

    John Henry Donovan

    12339 posts

    Hi webPragmatist,

    Did you know you there is a parameter for plugins called parse=“inward”. Can you give this a go please

    {exp:ajw_feedparser url="{embed:url}" limit="5" parse="inward"}
     {
     "cell_type":"text",
     "cell_text":{exp:phpstringfun function="json_encode"}{title}{/exp:phpstringfun},
     "cell_link_type":"Link",
     "cell_link_url":"{link}"
     }
     {if {count} < {total_results}}, {/if}
    {/exp:ajw_feedparser}
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases