1

So I've setup a safecracker form, all works great to submit an article and the editing page also works if you're logged in as the author. However if you're logged out you get the following message:

The form you submitted contained the following errors
You are not the author of this entry.

This is fine for the edit page and works as it should do, however when trying to simply view the article it still displays this message, any ideas why?

{if freebie_3 == ""}

  {embed="site/_header" page_name="{segment_1}"}

  <div class="primary-col">

  {exp:channel:entries channel="profile"}

    <h1>{title}</h1>

    <div class="bio">
      {company_bio}
    </p>

    <div class="work-samples">
    {company_samples}
      <article><img src="{image:url}" alt="{image:title}" /></article>
    {/company_samples}

  {/exp:channel:entries}

  </div>

{if:else}  

  {embed="site/_header" page_name="edit"}

  <h1>Your Profile</h1>

  <div class="primary-col">

    {if logged_out}  You aren't a member or aren't logged in.<br /> <a href="{path='member/login'}">Login</a>  | <a href="{path='member/register'}">Register</a>  {/if}

    {exp:safecracker channel="profile" author_only="yes" return="companies/URL_TITLE" url_title="{segment_2}" error_handling="inline" include_jquery="no" rte_selector=".rte"}
      {edit-form}
    {/exp:safecracker}

  </div>

{/if}

{embed="site/_footer"}

I'm using Freebie to detect if segment_3 is empty, if it is then the article is displayed, but if segment_3 is edit then you'll get the edit form. I've tried swapping the ifs around so that if freebie_3 == "edit" but it does exactly the same thing.

1 Answer 1

3

Because your freebie conditional uses an {if:else} statement, it is considered an advanced conditional. Advanced conditionals are rendered after module/plugin tags are rendered (see: Rendering Stages). The safecracker tag in the else condition is getting parsed and executed before the condition is evaluated. The solution is to split it into two simple conditionals (example below) or to use the IfElse plugin.

{if freebie_3 == ""}
...
{/if}
{if freebie_3}
...
{/if}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.