Forums / Setup & design / new node without a draft?

new node without a draft?

Author Message

Ben Pirt

Monday 16 January 2006 7:06:26 am

Hi,
I was wondering if it is possible to create a new node without first creating a draft?
i.e. Instead of having to create a new draft and then filling it in and publishing it. Would it be possible to have a form which has the correct attributes for a class and which, when submitting it will create a new object.

I am hoping to use this to collect information on a site, but can't use information collectors because the user needs to uplaod a file and this datatype is not an information collector.

Cheers,

BJPirt

Paul Borgermans

Monday 16 January 2006 9:19:08 am

Hi,

It is not possible out of the box, but there is at least one contribution which goes in that direction:

http://ez.no/community/contribs/hacks/object_creator

However, Kristof should enter this thread and talk about his work in progress on the "wrapper module" --- very cool stuff ;-))

--paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Ben Pirt

Tuesday 17 January 2006 3:09:48 am

Thanks for the suggestion Paul, I'll take a look at it.
I couldn't find any info on a "wrapper module" on the site, could you point me in the right direction?
Cheers,
Ben

Xavier Dutoit

Tuesday 17 January 2006 3:33:22 am

Hi,

Kristof is working on something that allows to create a new object too.

The big advantage of his stuff is that it's going to be able to deal automatically with all the datatypes (that isn't the case with object_creator) from what I understood.

Ok, let Kristof jumps on the thread and tell us that he has uploaded his wrapper on the pubsvn... Otherwise, we are going to have to wait a few more days.

Kristof, over to you! ;)

X+

http://www.sydesy.com

Kristof Coomans

Tuesday 17 January 2006 4:41:13 am

OK guys, here I am:
http://pubsvn.ez.no/community/trunk/extension/powercontent

As always, any feedback is highly appreciated :-)

I will wait to put it on ez.no as a contribution until some of you had the time to test it.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Paul Forsyth

Tuesday 17 January 2006 5:09:25 am

This is quite interesting. I have something similar but i've based it on an action instead.

I needed to be able to create pre-filled objects. I created those first, allowed the user to select which one they wanted and then used the action to copy the object to the current location and moved into edit mode.

Is this worth combining?

Paul

Paul Borgermans

Tuesday 17 January 2006 5:32:36 am

Hi Paul,

This is also possible with Kristof's extension (pre-filling I mean). The readme maybe misleading: you can do both pre-filling and/or direct publish without creating a draft.

A nice feature would/will be one or more easy to use template functions, eg

{pc_newobject_gui $class=<class-dentifier> $node=<parent_node_id> $prefill=hash('<classidentifier>/attribute1','some subject text', '<classidentifier>/attribute2','some more text', '<classidentifier>/attribute3','a value to be the default for a selection list',....) }

;-))

This and the solution for the "internal drafts" (see pubsvn) really make me smile.

Why would we need an ez publish version 4.x? (just kidding)

--paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Paul Forsyth

Tuesday 17 January 2006 5:45:56 am

I see it now. The doc needs more examples :)

The main difference would be the dynamic choice of a range of objects to choose from to prefill a new object with (and one less version). You can choose an object and use its content to populate the function but for dynamic choices you would need a page reload (AJAX?).

Could we place a dependancy on xajax for this?

Paul

Paul Borgermans

Tuesday 17 January 2006 5:52:19 am

Hi Paul,

That can easily be done, just use Kristof's xajax extension ;-))

But the usefullness escapes me a bit ... ok ... it doesn't escape: a better / easier object copy function?

--paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Paul Forsyth

Tuesday 17 January 2006 6:03:38 am

Xajax extension, thats what i inferred :)

Heres a example of what i use this for:

I have several articles which are used as the basis for new articles, stored in a 'Template' folder. With my current action i can just choose from a list (simple child fetch from a node id), click my 'Create from' button and continue to populate my prefilled object.

With this new extension i believe the values for the object have to setup in advance. This means that if i add more articles to the 'Template' area i have to add to the code too. So a more dynamic method would be welcome.

Actually a non-cached template file with a loop should do it.... Thinking about it. Doh!

Paul Forsyth

Tuesday 17 January 2006 7:04:19 am

Erm, got a small cosmetic request... the name 'powercontent'. Could this be improved a little? ;)

Paul Borgermans

Tuesday 17 January 2006 7:14:56 am

Suggestions then?

Maybe we should start to bundle extensions too

--paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Paul Forsyth

Tuesday 17 January 2006 7:25:36 am

I liked the original object_creator name. Edit: just noticed that extension wasnt Kristof's.

> Maybe we should start to bundle extensions too

Now, that would be 'power content' :)

Seriously, bundling would be nice. Once eZc starts going should we also have a pear channel for deploying?

Fraser Hore

Sunday 05 February 2006 7:50:59 am

Powercontent is a great extension. One of the biggest problems of ez publish is that it's quite slow to add new items. Not good for adding a quick appointment or task. Or adding multiple items quickly. The ability to put a form directly on the user page for adding a new item is great!

One problem: i haven't got it working yet :-) My class has a textline attribute with identifier "activity". It also has a date identifier but for the moment i'm trying to get it to just publish an activity name for the new item. I'm using the following code:

<form method="post" action={"powercontent/action"|ezurl} enctype="multipart/form-data">
    <div>
    <input type="hidden" name="NodeID" value="{$node.main_node_id}" />
    <input type="hidden" name="UseNodeAssigments" value="0" />
    <input type="hidden" name="ClassID" value="69" />
    <input type="hidden" name="RedirectURIAfterPublish" value={$node.url_alias|ezurl} />
    </div>
    <div>
    <input type="text" name="powercontent_activity_ContentObjectAttribute_ezstring_data_text_pcattributeid" value="Enter new sub-activity" />
    <input class="button" type="submit" name="CreateButton" value="Submit" />
    </div>
</form>

When i click on the submit button, it brings up the edit form with a note at the top saying the content was stored successfully. When i click on the publish button of the edit form I get the following error:

Module not found

The requested module ezpublish could not be found.

Possible reasons for this are:

    * The module name was misspelled, try changing the URL.
    * The module does not exist on this site.
    * This site uses siteaccess matching in the URL and you didn't supply one, try inserting a siteaccess name before the module in the URL .

Any ideas for how to get this to work would be much appreciated!

Cheers,

Fraser

Kristof Coomans

Sunday 05 February 2006 11:09:23 am

Hi fraser

Thanks for testing the powercontent extension. On which URL do you end up when clicking the publish button?

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Fraser Hore

Sunday 05 February 2006 3:12:34 pm

Hi Kristof,

I end up at a page with the error message i posted and the url is the same as the page i started from.

I changed the post to a get to see what's there, here it is:

http://www.mysite.com/ezpublish/index.php/intranet/powercontent/action?NodeID=380&DoPublish=on&UseNodeAssigments=0&ClassID=70&RedirectURIAfterPublish=%2Fezpublish%2Findex.php%2Fintranet%2Fpersonal%2Fweekly_planning&powercontent_activity_ContentObjectAttribute_ezstring_data_text_pcattributeid=1.+Activity+One&powercontent_week_number_ContentObjectAttribute_data_integer_pcattributeid=05&powercontent_monday_hours_ContentObjectAttribute_ezstring_data_text_pcattributeid=1&powercontent_tuesday_hours_ContentObjectAttribute_ezstring_data_text_pcattributeid=2&powercontent_wednesday_hours_ContentObjectAttribute_ezstring_data_text_pcattributeid=4&CreateButton=Go

Thanks,

Fraser

Kristof Coomans

Sunday 05 February 2006 11:19:44 pm

The example code I provided in the readme is wrong.

<input type="hidden" name="RedirectURIAfterPublish" value={$node.url_alias|ezurl} />

has to be:

<input type="hidden" name="RedirectURIAfterPublish" value="/{$node.url_alias}" />

Let me know if it works now.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Fraser Hore

Monday 06 February 2006 5:31:05 am

Hi Kristof,

Thanks, it works well now with your change. There are a couple of other issues i would be grateful for your thoughts on:

1. It doesn't seem to be able to validate a float datatype, i get a message to this effect at the top of the edit form. When i submit the edit form it publishes.

2. I'm having trouble submitting more than one attribute at a time. In the code below only the activity attribute is stored in the new content object. Am i missing something in the code?

<form method="post" action={"powercontent/action"|ezurl} enctype="multipart/form-data">
    <div>
    <input type="hidden" name="NodeID" value="{$item.main_node_id}" />
    <input style="display: none;" type="checkbox" name="DoPublish" checked="unchecked" />
    <input type="hidden" name="UseNodeAssigments" value="0" />
    <input type="hidden" name="ClassID" value="70" />
    <input type="hidden" name="RedirectURIAfterPublish" value="/{$node.url_alias}" />
    </div>
    <div>
    <input style="display: none;" type="text" name="powercontent_activity_ContentObjectAttribute_ezstring_data_text_pcattributeid" size="12" value="{$item.name}" />
    <input style="display: none;" class="box" type="text" name="powercontent_week_number_ContentObjectAttribute_data_integer_pcattributeid" size="5" value="{$currentweeknumber}" />
    <input type="text" name="powercontent_monday_hours_ContentObjectAttribute_ezstring_data_text_pcattributeid" size="1" value="" />
    <input type="text" name="powercontent_tuesday_hours_ContentObjectAttribute_ezstring_data_text_pcattributeid" size="1" value="" />
    <input type="text" name="powercontent_wednesday_hours_ContentObjectAttribute_ezstring_data_text_pcattributeid" size="1" value="" />
    <input class="button" type="submit" name="CreateButton" value="Go" />
    </div>
</form>

3. Not having to open a form and then submit it definitely saves clicks and time, but even with the powercontent it's still a bit slow. Is there any way with Ajax we could get to the almost instant update that you get with tada list, for example? (www.tadalist.com)

4. I'm using javascript to expand and collabse nodes of my list (using the expandablelist extension i contributed). When i add an item to level one of the list it appears immediately after update. When i add a sub item below level one i need to clear the cache for the sub item to appear. Any ideas what i could do to fix this?

5. What about in-place editing? Is it possible to send updates to a content object rather than just create new objects?

Any thoughts or advice you have on these questions would be great!

Fraser

Kristof Coomans

Monday 06 February 2006 10:11:21 am

1. Maybe this is related to point 2, but I'm not sure.

2. This was a bug in my code. It didn't recognise attribute identifiers with an underscore _ . It should have been fixed now. Try the latest revision in SVN, and let me know if it solves your problem.

3. The sky is the limit. It's possible for sure, but it needs to be coded ;)
I'm experimenting with several ajax-based functionalities (ajax-based object browser etc.) and maybe I will write some plugin for my xajax-extension that allows content creation.

4. When you publish an object, only the content view cache of the direct parent nodes gets cleared. Not the cache of the grandparents. I guess this is the problem.

5. Same answer as point 3 :-)

Good luck!

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Fraser Hore

Tuesday 07 February 2006 4:21:57 am

Hi Kristof,

Your update fixed # 2, attributes with an underscore. Thanks!

It still doesn't validate a float datatype.

As for the cache issue. New items will be updated on the page after entry only if they are directly under the node being viewed. Do you have any suggestions for clearing the cache so that items published to nodes one or more levels down are also displayed immediately?

I really appreciate you creating the powercontent extension. It works great and opens up a ton of possibilities! I'm using it for an activity management and weekly planning tool. In a left column is a hierarchical list of activities and in a right column is a plan for the week showing on which days i plan to work on which activities. I use your powercontent module to enable rapid generation of the hierarchical list. Beside each activity there is a link to add a sub-activity which uses javascript to show a little form and your powercontent extension to publish it. The user can then drag and drop an activity or sub-activity to a day on the week calendar in the right column. Actually they drag and drop it into a form field, enter the hours they plan to work on the activity that day, and then publish it using powercontent. Powercontent dramatically speeds up the whole process and it's pretty quick to build up an overall plan and allocate activities to the days of the week. With some Ajax we'd really be in business :-)

Cheers,

Fraesr