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.

Conditional based on weblog entry_form tag

July 14, 2010 12:59pm

Subscribe [2]
  • #1 / Jul 14, 2010 12:59pm

    journalistone

    78 posts

    Hello,

    I have a need to submit one SAEF form to two separate weblogs. So I am trying to establishing a conditional on my form tag.

    BACKGROUND INFO: The reason I need the form to feed into separate weblogs is that I have a classifieds website where there is an option to place a free advert and then other adverts are paid for. I need to divert the ‘Free’ process in a different direction to my e-commerce processes.

    Also, the free advert expires after 6 weeks where the others are non-expiring, so I have used the Auto Expire Extension to maintain this functionality as it is weblog driven.

    All in all the form has the same fields, but I just need to feed the form in two different directions for other site functionality purposes.


    SO, what I have tried to do is this:

    {if entry-id=='1672'} {!-- This is the Free Product weblog entry --}
    {exp:weblog:entry_form 
        weblog="free"
        return="sell/checkout" 
        preview="sell/preview" 
        status="open" 
        enctype="multi"}
    {if:else}
    {exp:weblog:entry_form 
        weblog="sell" {!-- This is for all other Product weblog entries --}
        return="sell/checkout" 
        preview="sell/preview" 
        status="open" 
        enctype="multi"}
    {/if}

    BUT this is outputting a curious Tag wrapped around my form:

    {{NOCACHE_FORM}} form fields etc {{/NOCACHE_FORM}}

    Does anyone have a better method I could use for such a scenario?

    Thank you in advance ...

  • #2 / Jul 14, 2010 3:41pm

    Rob Sanchez

    335 posts

    You’d have to have the entire entry_form, along with its closing tag within the conditional. You can’t just have the opening tag in a conditional like you have here, it’s just not how the EE template parser works.

    So you can either have two separate forms, or you could try something like this with an embed:

    {if entry_id=='1672'}
        {embed="embed/entry_form" weblog="free"}
    {if:else}
        {embed="embed/entry_form" weblog="sell"}
    {/if}

    embed/entry_form

    {exp:weblog:entry_form 
        weblog="{embed:weblog}"
        return="sell/checkout" 
        preview="sell/preview" 
        status="open" 
        enctype="multi"}
    ....
    {/exp:weblog:entry_form}
  • #3 / Jul 14, 2010 5:45pm

    journalistone

    78 posts

    Hey Rob,

    THANK YOU for the tip here. I was having an incredible mental block, and with a little bit of testing I have it working. The parsing of embedded items always throws me, and then making sure entry_ids go with the embed ...

    In the end I had to do this:

    {if "{entry_id}"=="1672"}...

    THANK YOU.
    Alison

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

ExpressionEngine News!

#eecms, #events, #releases