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.

After adding a new entry, I get the "no results" conditional instead of the entry; on page refresh, entry appears

September 02, 2011 4:37pm

Subscribe [4]
  • #1 / Sep 02, 2011 4:37pm

    vosSavant

    380 posts

    I’m adding an entry to the database with a custom script of mine (I’m not using Safecracker because I need more control over the form inputs than that add-on allows me). The script is run through EE’s templating engine and uses Active Record syntax.

    The relevant piece of the form that adds the new entry is:

    <form action="{path='scripts/php_entry_add'}" method="post">

    The scripts/php_entry_add template generates a URL for the new entry and adds it to the DB. At the end of this template is a standard EE redirect, with the new entry’s URL inserted via PHP:

    echo "{redirect='entry/$entry_url/edited'}"

    In the return template (entry/index) I have the following:

    {exp:channel:entries channel="entry" require_entry="yes" url_title="{segment_2}"}
       {if segment_3 == 'edited'}Your new entry was added!{/if}
       {title}
       ... other stuff ...
    
       {if no_results}Sorry, no results{/if}
    {/exp:channel:entries}

    On form submit, I get redirected to the correct URL (e.g., http://mysite.com/entry/my-new-entry/edited), but the page is blank, with only the “Sorry, no results” text showing. In other words, the entry can’t be found.

    The strangest part is that simply refreshing the page pulls the entry up.

    I can verify that the scripts/php_entry_add template works perfectly, and that there is no issue adding the entry to the database. The problem occurs when redirecting to the newly created entry. It’s as though EE hasn’t yet registered that the entry is there. Refreshing the “entry not found” page pulls up the entry, every time.

    I suppose the shortest version of my question is: is there some kind of delay between adding entries to a DB and them being available? I can’t think of a reason why the entry would come up as missing, then show up with a simple page refresh. (Well, there’s always the “user error” possibility… 😉) Any ideas?

  • #2 / Sep 03, 2011 9:43pm

    Dan Decker

    7338 posts

    vosSavant,

    Sounds like you have quite the custom solution going on here! The *only* thing I can think of would be cache settings. Either for the “redirect” template, or DB Query caching. Or even browser caching.

    Cheers,

  • #3 / Sep 13, 2011 7:24pm

    vosSavant

    380 posts

    Thanks Dan, I’ll look into caching—you recommend turning DB Query caching off, right?

  • #4 / Sep 13, 2011 7:39pm

    LMO

    203 posts

    check server time vs. local time. We had an issue once where the two times where a little off and not showing the entry because the system was respecting the future entries rule. Probably not the answer, but just thought I’d throw it out there.

  • #5 / Sep 14, 2011 2:02pm

    Mark Bowen

    12637 posts

    Hi Ryan,

    I’m going to move this down to the Community Help forums as this is a custom script of your own that you are using here and so not really something we could support directly.

    Hopefully someone else may have some more ideas on this though once it goes to the Community Forums.

    Thanks,

    Mark

  • #6 / Sep 27, 2011 6:28pm

    vosSavant

    380 posts

    VIM,

    Your suggestion ended up being the ticket. The server is located in Chicago and the site is set to Denver time. Adding show_future_entries=“yes” fixed the problem.

  • #7 / Sep 27, 2011 6:39pm

    LMO

    203 posts

    Ryan glad it helped!

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

ExpressionEngine News!

#eecms, #events, #releases