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

eZ debug

Timing: Jan 18 2025 11:25:00
Script start
Timing: Jan 18 2025 11:25:00
Module start 'content'
Timing: Jan 18 2025 11:25:02
Module end 'content'
Timing: Jan 18 2025 11:25:02
Script end

Main resources:

Total runtime2.3101 sec
Peak memory usage4,096.0000 KB
Database Queries205

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0067 589.1406180.8359
Module start 'content' 0.00672.1233 769.9766642.5078
Module end 'content' 2.13000.1801 1,412.4844341.6875
Script end 2.3101  1,754.1719 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.1730210.0002
Check MTime0.00150.0642210.0001
Mysql Total
Database connection0.00090.039310.0009
Mysqli_queries2.209295.63042050.0108
Looping result0.00220.09592030.0000
Template Total2.278898.621.1394
Template load0.00220.096520.0011
Template processing2.276698.546521.1383
Template load and register function0.00020.007910.0002
states
state_id_array0.00140.060010.0014
state_identifier_array0.00160.071420.0008
Override
Cache load0.00200.0879860.0000
Sytem overhead
Fetch class attribute can translate value0.00320.140440.0008
Fetch class attribute name0.00270.115180.0003
XML
Image XML parsing0.00190.081640.0005
class_abstraction
Instantiating content class attribute0.00000.001090.0000
General
dbfile0.00260.1121340.0001
String conversion0.00000.000230.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 33
 Number of unique templates used: 6

Time used to render debug report: 0.0003 secs