Thursday 12 October 2006 3:12:43 pm
Hi Pierre
So you want to create it with PHP. To do this you have to write your won data import functionality. A good start is to check the contributions for importing, you might be able to use one of them directly or adapt it to your needs.
This post explains the single steps for object creation quite well.
http://ez.no/community/forum/deve..._we_create_content_objects_from_code
Greetings from Luxembourg
Claudia
Monday 16 October 2006 10:04:30 am
Thanks,
I watch a other post of this forum :
http://ez.no/user/activate/1e6900e6bfd8e7686dc1c2d168078787
I activate the extensions, but ...
I do a copy-paste and no match.
your solution is excelent , I program an extension for my web site.
It's fun because i don't know ezpublish :p
Pierre-Jean
Monday 16 October 2006 11:36:35 am
HI,
Wrong url that you pasted on the post. Not sure what you're mentionning.
For your need, have a look at another extension: powercontent You can set a parameter to directly save the content. It would let you avoid writing php. Not sure what you want to do, might be a good option.
X+
Tuesday 17 October 2006 10:05:53 am
sorry for my broken link,
http://ez.no/de/community/forum/setup_design/new_node_without_a_draft
I test the extension powecontent, but it pre-perform but not save content directly.
My class have two Enhanced Object relation, one datetime and one combo-list with values 10 and 20.
I test powercontent with a simple class (one ezstring), it's pre-form , not save content.
Pierre-Jean
Tuesday 17 October 2006 10:25:54 am
Have you read the readme?
http://pubsvn.ez.no/community/tru...xtension/powercontent/doc/readme.txt
Is says that you can publish immediately (ie not only prefill). Put the DoPublish field and that's going to make it.
X+
Friday 20 October 2006 11:03:33 am
It's so hard....
I pre-filled my form with the powercontent.
I use ezHTTP to prefilled my invisible form and the visitor validate this with a JS button.
When I not use the extension (normal mode), the function ezhttp not get my vars
I have a problem too with the draft, I find in the site.ini.append.php.in the section [ContentSettings] , I add EditDirtyObjectAction for not use the draft version
[ContentSettings]
EditDirtyObjectAction=usecurrent
Thanks for all
Pierre-Jean
Friday 20 October 2006 2:49:25 pm
<b>my object :</b>
FilmSelect [Enhanced Object relation]
Utilisateur [Enhanced Object relation]
DateHeureAchat [Date et heure] (datetime) buy date
EtatSelect [Énumération] (enum-list)
element Sélection 10
element Achat 20
<b>in the page :</b>
{*formulaire d'appel*}
<form method="post" action={"powercontent/action/"|ezurl} name="addcart" style="display:block" >
<input type="hidden" name="NodeID" value="" />
<input type="hidden" name="ClassID" value="35" />
<input type="hidden" name="RedirectURIAfterPublish" value="/{$node.url_alias}"/>
<input type="hidden" name="filmselect" value="">
<input type="hidden" name="utilisateur" value="">
<input type="hidden" name="etatselect" value="10">
<input type="hidden" name="CreateButton" value="ajouter"/>
</form>
<b>in the submit form :</b>
{*fonction de remplissage du formulaire*}
{literal}
<script>
function remplitForm()
{
{/literal}
// recupereration des différents éléments du formulaire
var x=document.panier.elements ;
//construction des élements enhaced relation object
var film = "ContentObjectAttribute_data_object_relation_id_list_"+{$content_attributes[0].id}+"[empty]" ;
var util = "ContentObjectAttribute_data_object_relation_id_list_"+{$content_attributes[1].id}+"[empty]" ;
{literal}
// parcoure des element et selection des valeurs
for (i=0;i<x.length;i++){
if(x[i].type == 'select-one'){
if(x[i].name == film){
for(j = 0 ; j < x[i].length;j++){
if(x[i][j].value=={/literal}{ezhttp('filmselect')}{literal}){
x[i][j].selected = 'selected' ;
}
}
}
if(x[i].name == util){
for(j = 0 ; j < x[i].length;j++){
if(x[i][j].value=={/literal}{ezhttp('utilisateur')}{literal}){
x[i][j].selected = 'selected' ;
}
}
}
}
}
{/literal}
var mode={if eq(ezhttp('CreateButton'),'ajouter')}'Sélection'{else}'Achat'{/if};
//remplissage des champs dates
document.panier.ContentObjectAttribute_datetime_year_{$content_attributes[2].id}.value = {currentdate()|datetime( 'custom', '%Y' )} ;
document.panier.ContentObjectAttribute_datetime_month_{$content_attributes[2].id}.value = {currentdate()|datetime( 'custom', '%m' )} ;
document.panier.ContentObjectAttribute_datetime_day_{$content_attributes[2].id}.value = {currentdate()|datetime( 'custom', '%d' )} ;
document.panier.ContentObjectAttribute_datetime_hour_{$content_attributes[2].id}.value = {currentdate()|datetime( 'custom', '%H' )} ;
document.panier.ContentObjectAttribute_datetime_minute_{$content_attributes[2].id}.value = {currentdate()|datetime( 'custom', '%i' )} ;
{literal}
for (i=0;i<x.length;i++){
if(x[i].type =='radio') {
if(x[i].value == mode){
x[i].checked = 'checked';
}else{
x[i].checked = '';
}
}
}
//document.panier.PublishButton.click();
}
</script>
{/literal}
<form name="panier" enctype="multipart/form-data" method="post" action={concat("/content/edit/",$object.id,"/",$edit_version,"/",$edit_language|not|choose(concat($edit_language,"/"),''))|ezurl}>
<table class="layout" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" style="display:none">
<input type="hidden" name="DiscardConfirm" value="0" />
{include uri="design:content/edit_attribute.tpl"}
<input class="defaultbutton" type="submit" name="PublishButton" value="acheter"/>
<input class="button" type="submit" name="DiscardButton" value="annuler" />
</td>
</tr>
</table>
</form>
<b>explication : </b>
this code pre-fill too the datetime,enhaced object relation and enum-list.
The comment is in french, sorry.
explications :
second part :
in javascript fonctions
- Get all elements of my form
- Construct my var with the id of enhaced object relation.
- browse all my element with the select-one and equal to my var.
- set the value with ezhttp.
- the is the current date of my server.
- browse all my radio button and set the value (not generic and not optimize)
- the last line simulate a click in the button publish.
It's a speed code, no optimization, no generic code
Pierre-Jean
Sunday 22 October 2006 7:35:26 pm
Salut Pierre-Jean,
Not sure I got your problem.
However,the names of the forms aren't the correct onces for powercontent to work properly I suspect. Is the form properly filed ?
As for the draft, could you detail your problem ?
X+
P.S. Not sure if the powercontent to download on the contrib area is up to date compare to the one in the pubsvn.ez.no . I think the doc is more complete on the svn.
You must be logged in to post messages in this topic!