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.

Having problems with embedding and quotes in my entries post.

September 13, 2008 1:03pm

Subscribe [2]
  • #1 / Sep 13, 2008 1:03pm

    camwest

    14 posts

    Hi there.  I am listing entries in one list from two blog posts.  I am then embedding the appropriate renderer for the blog entry based on what type of post it is.  I am having problems with the body property.  If there are double quotes in my body custom field of the entry, it breaks this (probably because i am going body=”{body}” however I need to be able to use double quotes and single quotes in my body, and I use the blog_post template in lots of different places so I really would prefer to embed it so I don’t have duplicate code.  Is there some way I can convert my quotes to entities when they are inserted into the database so that when they are retrieved it doesn’t cause this problem?

    {exp:weblog:entries weblog='blog_post'}              
              {embed="includes/blog_post"
                title="{title}"
                date="{entry_date format='%D %d %M'}"
                year="{entry_date format='%Y'}"
                time="{entry_date format='%g:%i %A'}"
                url="/blog/post/{url_title}"
                user_url="/blog/user/{username}"
                user_name="{author}"
                summary="{summary}"  
                body="{body}"
                categories='{categories backspace="1"}<a href="/blog/category/{category_url_title}">{category_name}</a>,{/categories}'
              }
          {/exp:weblog:entries}
  • #2 / Sep 14, 2008 11:08am

    Robin Sowell

    13255 posts

    If you’re embedding that much, I’m wondering if it would be better to just have the weblog tag on the embedded template instead.  That’s what I’d do unless I had a really good reason not to.

    That said- if it’s an absolute requirement that it work this way, might try using something like xml encode to ditch quotes.  I’m not certain the parse order would flake out, but I think it would.

    That said- I’d probably go a different approach overall.

  • #3 / Sep 14, 2008 12:14pm

    camwest

    14 posts

    Robin,

    It’s actually a lot more complex, I’m doing conditionals in the weblog entries loop to load a different renderer based on what type of blog post it encounters, I just simplified the example to make it more clear. I will look into XML Encode. Thanks!

  • #4 / Sep 15, 2008 4:36pm

    Ingmar

    29245 posts

    camwest, are you good? Do you need any further assistance?

  • #5 / Sep 15, 2008 4:36pm

    camwest

    14 posts

    Ingmar, thanks for following up.  I wasn’t able to solve the problem using XML Encode, I just worked around it by not embedding another template. I am just putting markup straight in.

    Thanks!

  • #6 / Sep 15, 2008 4:41pm

    Ingmar

    29245 posts

    Thanks for letting us know. As Robin suggested, embedding as much data as you did in your example is probably not a good idea. Looks like you’re squared away for the time being, though, so I’ll close this thread. If anything else comes up, please do not hesitate to start a new one.

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

ExpressionEngine News!

#eecms, #events, #releases