Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: Viewing Publisher Draft Content in Safecracker

Status Resolved
Add-on / Version Publisher
Severity Trivial
EE Version

brygeaux

Jul 30, 2013

I was wondering about being able to view pre-existing Publisher Draft data via safecracker.

After doing a few tests, it seems that Safecracker is only pulling data from the native EE table, rather than the Publisher table, which makes sense.

Are there any plans to be able to edit pre-existing Publisher Drafts via safecracker?

It seems like a bad idea for new safecracker entries to automatically copy over publisher drafts if they already exist. A nice workflow utility which keeps people out of the CP is the dream!

#1

BoldMinded (Brian)

Using these fields/parameters don’t provide what you are looking to do? http://boldminded.com/add-ons/publisher/third-party-add-ons/safecracker

#2

brygeaux

Right, I was thinking the last thing concerning the safecracker parameter was going to be it, but when I try it the pre-filled content is always the Open/Published data from the EE table.

I tried adding ?publisher_status=draft to the url as well.

What I want to do is display the draft content in the safecracker fields, and none of the open/published content.

or is that what publisher_status=”draft” suppose to do?

#3

BoldMinded (Brian)

publisher_status=”draft” should be working. What version of EE and Publisher?

#4

brygeaux

2.5.5 EE and 1.0.2 Publisher. Should the Safecracker Extension settings say anything for the default status of the particular channel?

But if you’ve verified that’s what the safecracker parameter does, I can go back and see if I’ve messed something up. I thought perhaps I was reading your description of what the parameter does wrong.

#5

brygeaux

PS. When I manually edit data in the publisher_titles or publisher_data table for both the open and draft versions of an entry, that data never shows up in the safecracker template. It’s always showing the data from the exp_channel_data table.

This just leads me to think that when safecracker prefills in the fields, it is only looking at the native EE tables.

#6

BoldMinded (Brian)

Are you using Zoo Visitor by chance?

#7

brygeaux

Yes indeed!

#8

BoldMinded (Brian)

And are you editing the member channel? If so are you using the ZV tag or the EE Safecracker tag?

#9

BoldMinded (Brian)

My test environment is using ZV, but if I use the Safecracker tag my first and last name show as blank b/c in the data array its member_firstname and member_lastname fields are blank, but it should be field_id_X and field_id_Z, both of which are empty in the array.

#10

brygeaux

Not editing a member channel.

#11

BoldMinded (Brian)

Oh line 452 or so of ext.publisher.php, change the method to this:

public function safecracker_entry_form_tagdata_start($tagdata, &$sc)
    {
        if (isset($sc->entry) && !empty($sc->entry))
        {
            $status = isset(ee()->TMPL->tagparams['publisher_status']) ? ee()->TMPL->tagparams['publisher_status'] : ee()->publisher_lib->status;

            // Grab the draft content of the entry instead.
            if ($status == PUBLISHER_STATUS_DRAFT)
            {
                $publisher_entry = ee()->publisher_entry->get($sc->entry['entry_id'], $status);
                $sc->entry = array_merge($sc->entry, (array)$publisher_entry[0]);
            }

            $sc->entry['categories'] = ee()->publisher_category->get_category_posts($sc->entry['entry_id'], $status);
        }

        return $tagdata;
    }
#12

brygeaux

PERFECT! Thanks so much!!!

#13

BoldMinded (Brian)

Copied from email:

It looks like I responded too quickly. The title is updated to the draft’s title But oddly the other content is still the published content.

The ?publisher_status=draft in the normal url shows the correct draft content in the normal template.

Perhaps it is only take the draft title from the publisher_titles table but not the publisher_data table ?

#14

BoldMinded (Brian)

So if you view the entry in the CP does it have the proper draft content? I’m just trying to understand if the issue is that it isn’t saving the draft content, or if it just isn’t displaying the draft content.

#15

brygeaux

Yes, all is well in the CP. I thought about posting that right after I sent the last email.

the drafts all save perfectly fine, from cp and safecracker front-end as drafts.

For instance, when I load the entry via safecracker it now has the ‘draft’ title but the ‘open’ content. I can then make changes and save it as draft and all of that saves properly as a draft.

But then when I bring up that same entry again in safecracker, only the new draft title shows vs the original ‘open’ entry’s content.

When I View as draft in the CP, it shows both the draft title and draft content.

#16

BoldMinded (Brian)

Are these normal EE fields? They’re not Matrix or Playa fields that are not showing the draft content properly?

#17

brygeaux

Wygwam fields.

#18

BoldMinded (Brian)

Can you temporarily make one of those fields a simple textarea, or try adding a new text or textarea field to test with? I doubt its Wygwam specific, but just want to rule it out.

#19

brygeaux

I converted one back to rich text from wygwam, but the old ‘open’ content still shows instead of the new ‘draft’ content for that field.

#20

brygeaux

I just converted it to normal text area, same results.

#21

BoldMinded (Brian)

Figured, but wanted to be sure. This is the template I’m testing with and its properly saving and displaying draft content.

{exp:safecracker channel="pages" return="zoo_visitor_example/profile/success" publisher_status="draft" entry_id="1"}
<input type="hidden" name="publisher_save_status" value="draft" />
<input type="hidden" name="publisher_view_status" value="draft" />
<input type="hidden" name="lang_id" value="{publisher:current_language_id}" />
<fieldset>
 
  <label for="title">{label:title}</label>
  <input type="text" name="title" id="title" value="{if title}{title}{/if}"/>
 

 
  <label for="field_id_2">{label:field_id_2}</label>
  <input type="text" name="field_id_2" id="field_id_2" value="{if field_id_2}{field_id_2}{/if}"/>
 


 <input type="submit" value="Submit" class="button"/>


{/exp:safecracker}
#22

brygeaux

I’ve tried slimming down the exp:safecracker tab to the just the parameters you use, as well as using {field:fieldname2} and <input type=”text” name=”fieldname2” etcetc>

But it still only shows the draft title with the rest of the data coming from the exp_channel_data table.

I’m wondering, if you manually edit the rows in the publisher_data table for both the ‘open’ and ‘draft’ version of the entry (with different values, of course), does it get reflected in what shows up pre-filled in your safecracker form?

#23

BoldMinded (Brian)

Emailed you a new build.

#24

brygeaux

Yup, seems to work great! Thanks again!

Login to reply