Forums / Developer / Publishing a user profile draft

Publishing a user profile draft

Author Message

Paul Forsyth

Wednesday 25 June 2003 1:17:51 am

Im working on getting users to edit their own profile on the user site - not via the admin interface.

My users are a new class, not class 4.

I have a tpl file overriding 'design/standard/content/edit.tpl'. When i want my user to edit their profile I force the creation of a new draft by means of clicking:

<form method="post" action="{concat('/content/edit/', $current_user.contentobject_id)}">
<input class="button" type="submit" name="NewButton" value="New draft" />
</form>

This displays my edit.tpl with my user profile and contains the submit line:

<input type="submit" name="PublishButton" value="Update my profile" />

which should publish my users changes. But it doesn't do this. When I query the versions using 'content/versions/' I see that that draft remains a draft.

If i log in to my user site as an admin and attempt the same procedure the profile does indeed get published. I've tried this with a different admin user and the same happens again. If i give my ordinary user all role privileges (* * *) it fails to publish so it appears privileges have nothing to do with this, only user group...

I've tried editing my users contentobject so that the owner is itself but this doesn't work.

The php code i've looked at doesn't seem to indicate how this can be done easily so at an end for creating some operator to help out...

Has anyone tried this yet?

All help appreciated, and beers at summer conference forthcoming ;)

paul

Tony Wood

Wednesday 25 June 2003 1:47:50 am

Paul, you do know how much beer costs in Norway! :)

Maybe a trip to duty free on the way over will be a good idea.

Tony Wood : twitter.com/tonywood
Vision with Technology
Experts in eZ Publish consulting & development

Power to the Editor!

Free eZ Training : http://www.VisionWT.com/training
eZ Future Podcast : http://www.VisionWT.com/eZ-Future

Bård Farstad

Wednesday 25 June 2003 3:00:38 am

Paul, the problem is that you create a new version for every time you post your data. You need to specify the editversion in the URL as well.

eZ publish will automatically create a new version of the object if it's already published, so you shouldn't need to think about this.

Did I just earn myself a beer? ;)

Tony: yes, beer is expensive in Norway. About 50 NOK at a restaurant.

--bård

Documentation: http://ez.no/doc

Paul Forsyth

Wednesday 25 June 2003 3:19:01 am

Hey, food wasn't part of the deal! but, we can bring some walkers thai crisps, lovely!

I still can't get it to publish. I've changed my form line to:

<form method="post" action="{concat('/content/edit/', $current_user.contentobject_id,'/',$current_user.contentobject.current_version)}">

to include the current version. When i click through this now i see that a new draft is created, like before. However, also like before pressing the publish button doesn't publish the draft.

Including the current version only seems to aid in creating the new draft but this worked before without this addition...

Are there 'input hidden' fields i need?

Does this have anything to do with the user settings in site.ini?

I should say that my content/edit.tpl doesn't include edit_placement and does include a customised edit_validation routine.

paul

Bård Farstad

Wednesday 25 June 2003 3:33:31 am

Here is a minimal edit template, the MainNodeID is a hidden variable.

<form enctype="multipart/form-data" method="post" action={concat("/content/edit/",$object.id,"/",$edit_version,"/",$edit_language|not|choose(array($edit_language,"/"),''))|ezurl}>
{section show=$validation.processed}
{section name=UnvalidatedAttributes show=$validation.attributes}
<div class="warning">
<h2>Input did not validate</h2>
<ul>
{section loop=$validation.attributes}
<li>{$UnvalidatedAttributes:item.name}: {$UnvalidatedAttributes:item.description}</li>
{/section}
</ul>
</div>

{section-else}

<div class="feedback">
<h2>Input was stored successfully</h2>
</div>

{/section}
{/section}

<input type="hidden" name="MainNodeID" value="{$main_node_id}" />

{section name=ContentObjectAttribute loop=$content_attributes sequence=array(bglight,bgdark)}
<div class="block">
<label>{$ContentObjectAttribute:item.contentclass_attribute.name}:</label><div class="labelbreak"></div>
<input type="hidden" name="ContentObjectAttribute_id[]" value="{$ContentObjectAttribute:item.id}" />
{attribute_edit_gui attribute=$ContentObjectAttribute:item}
</div>
{/section}

<input class="button" type="submit" name="PublishButton" value="Post" />
<input class="button" type="submit" name="DiscardButton" value="Discard" />
</form>

--bård

Documentation: http://ez.no/doc

Paul Forsyth

Wednesday 25 June 2003 4:00:45 am

Got it working :)

In my edit.tpl I am explicitly using elements of the array $content_attributes so that i can display names slightly differently. This means at the end I have lines like:

<input type="hidden" name="ContentObjectAttribute_id[]" value="{$content_attributes[0].id}" />
<input type="hidden" name="ContentObjectAttribute_id[]" value="{$content_attributes[1].id}" />
<input type="hidden" name="ContentObjectAttribute_id[]" value="{$content_attributes[2].id}" />
<input type="hidden" name="ContentObjectAttribute_id[]" value="{$content_attributes[3].id}" />

and so on.

My edit.tpl actually has two forms, intended to submit different parts of the data. The first form submits user account data such as login and password changes. The second submits shop data such as address changes. The user is the same, but i was being selective about what data was passed back to the form so for user data i used the appropriate $content_attribute element and omitted the rest.

Omission of the other $content_attribute causes the draft to not publish...

I guess this means i must submit all attributes to publish... Is this correct? A good error message would be nice :)

Time to refill that hip flask!

thanks

paul