Creating content from code

Author Message

Heiko Irrgang

Monday 24 January 2011 5:48:48 am

Hi, i am trying to create a page with content from php. So i read David Linnards wonderful tutorial about how to create objects in php, and it works in general, but i want to fill up the content with html or ezxml from inside the script.

Here is what i have so far:

$parentNode = eZContentObjectTreeNode::fetchByURLPath( $parentURL );
$user = eZUser::currentUser();
$p = array();
$p['class_identifier'] = 'folder';
$p['creator_id'] = $user->attribute( 'contentobject_id' );
$p['parent_node_id'] = $parentNode->attribute( 'node_id' );
$p['section_id'] = $parentNode->attribute( 'object' )->attribute( 'section_id' );
$attr = array ( ) ;
$attr['name'] = $fullName;
$attr['short_name'] = $shortName;
$attr['summary'] = '<p>AGGI</p>';
$attr['description'] = '<p>AGGI</p>';
$attr['tags'] = 'AGGI';
$p['attributes'] = $attr;
$o = eZContentFunctions::createAndPublishObject( $p );

Well, after this, the new folder is created and 'Name', 'Short Name' and 'Tags' are filled, but summary and description are both blank, what am i doing wrong?

Heiko Irrgang

Tuesday 25 January 2011 12:56:14 am

Ok, i am a little step closer: A) the correct field is 'short_description', not 'summary' and B) id does save the data in the fields, if i use

$parentNode = eZContentObjectTreeNode::fetchByURLPath( 'my_imported_stuff/test');

$m=$parentNode->dataMap();
var_dump($m['description']->content());

.... it displays the correct values, but it does not show the values in the admin interface.

Could this be some problem because i am running a multi lingual page?

Heiko Irrgang

Tuesday 25 January 2011 1:12:33 am

arrrrrr, found it: it is the visual editor, it filters out the <p>AGGI</p> :-/

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 02:57:04
Script start
Timing: Jan 18 2025 02:57:04
Module start 'layout'
Timing: Jan 18 2025 02:57:04
Module start 'content'
Timing: Jan 18 2025 02:57:04
Module end 'content'
Timing: Jan 18 2025 02:57:04
Script end

Main resources:

Total runtime0.8074 sec
Peak memory usage4,096.0000 KB
Database Queries55

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0051 587.9141152.6250
Module start 'layout' 0.00510.0029 740.539139.4531
Module start 'content' 0.00790.7976 779.9922437.5469
Module end 'content' 0.80560.0018 1,217.539112.1641
Script end 0.8074  1,229.7031 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00300.3774160.0002
Check MTime0.00120.1529160.0001
Mysql Total
Database connection0.00070.088410.0007
Mysqli_queries0.764694.6990550.0139
Looping result0.00050.0608530.0000
Template Total0.772095.620.3860
Template load0.00190.235120.0009
Template processing0.770195.377220.3851
Template load and register function0.00010.016710.0001
states
state_id_array0.00230.290410.0023
state_identifier_array0.00100.119020.0005
Override
Cache load0.00150.1920310.0000
Sytem overhead
Fetch class attribute can translate value0.00050.056110.0005
Fetch class attribute name0.00150.182030.0005
XML
Image XML parsing0.00010.011110.0001
class_abstraction
Instantiating content class attribute0.00000.001230.0000
General
dbfile0.00090.1109100.0001
String conversion0.00000.000740.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
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/strong.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/strong.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 13
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs