We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Custom fieldtype does not evaluate conditional correctly in a LivePreview

Development and Programming

Brian Litzinger's avatar
Brian Litzinger
693 posts
6 years ago
Brian Litzinger's avatar Brian Litzinger

I noticed something odd in Bloqs. When viewing a Live Preview, if I do a conditional to see if the template should display Bloqs data or a summary, it does not work in LP, but works otherwise just fine on the front-end (has been for ages). For example:

{if blog_blocks}
                                    <div class="blog-post__content" itemprop="articleBody">
                                        {blog_blocks}
                                            ... fields here...
                                        {/blog_blocks}
                                    </div>
                                {if:else}
                                    {blog_summary}
                                {/if}

That does not work, even when I’m step debugging the replace_tag method in ft.bloqs.php, it clearly has content, but when trying to render the template in LP, the conditional does not evaluate to true. It will work though if I check to see if it is a LP, but this seems like a jank fix. Why would that conditional work fine outside of a LP request, but not inside a LP request?

{if blog_blocks || is_live_preview_request}
                                    <div class="blog-post__content" itemprop="articleBody">
                                        {blog_blocks}
                                            ... fields here...
                                        {/blog_blocks}
                                    </div>
                                {if:else}
                                    {blog_summary}
                                {/if}
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.