1

I have a template called post.html in group.group. The template includes a safecracker form. I have the safecracker form inside and if/else statement so that if the url is /group/post/title then the safecracker form loads an existing entry for editing. If there is no title segment (url is only /group/post) then it loads a blank safecracker form to create a new post. Here’s my code:

{if segment_3 != ""}
      {exp:safecracker channel="trophy_gallery"
       require_entry="yes" url_title="{segment_3}" author_only="yes"}

            // edit entry form code

        {/exp:safecracker}
{if:else}
        {exp:safecracker channel="trophy_gallery"}

           // create entry form code

        {/exp:safecracker}
{/if} 

For some reason the safecracker settings like require_entry, url_title and author_only are effecting the safecracker setup in the “else” block of the code. So when I load a url without a third segment it’s telling me no entry was provided.

Is there something wrong with the way I’m formatting this (a better way to do so), or is this potentially a bug in how the safecracker tags are being parsed?

Josh Farneman
  • 1,729
  • 1
  • 14
  • 19

1 Answers1

2

Here's the answer from the Expression Engine forums:

The Safecracker tag already has built in parsing to handle the edit/new situation based on the value of url_title or entry_id. So I could rewrite my code as:

{exp:safecracker channel="trophy_gallery"
 url_title="{segment_3}" author_only="yes"}

    // edit entry form code

{/exp:safecracker}
Josh Farneman
  • 1,729
  • 1
  • 14
  • 19