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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 16:07:23
Script start
Timing: Jan 18 2025 16:07:23
Module start 'layout'
Timing: Jan 18 2025 16:07:23
Module start 'content'
Timing: Jan 18 2025 16:07:24
Module end 'content'
Timing: Jan 18 2025 16:07:24
Script end

Main resources:

Total runtime0.9502 sec
Peak memory usage4,096.0000 KB
Database Queries68

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0072 589.3438152.6250
Module start 'layout' 0.00720.0037 741.968839.4453
Module start 'content' 0.01090.9380 781.4141637.4297
Module end 'content' 0.94880.0013 1,418.843820.7891
Script end 0.9502  1,439.6328 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.3536160.0002
Check MTime0.00120.1296160.0001
Mysql Total
Database connection0.00070.078010.0007
Mysqli_queries0.871491.7013680.0128
Looping result0.00060.0646660.0000
Template Total0.921697.020.4608
Template load0.00210.222520.0011
Template processing0.919596.761220.4597
Template load and register function0.00010.015010.0001
states
state_id_array0.00120.127510.0012
state_identifier_array0.00090.095320.0005
Override
Cache load0.00200.2148860.0000
Sytem overhead
Fetch class attribute can translate value0.00090.090730.0003
Fetch class attribute name0.00130.140180.0002
XML
Image XML parsing0.00110.112630.0004
class_abstraction
Instantiating content class attribute0.00000.001890.0000
General
dbfile0.00090.0932230.0000
String conversion0.00000.001340.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
14content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
8content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 33
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs