Forums / Developer / [Solved] Problem with embed tag in XMLBlock

[Solved] Problem with embed tag in XMLBlock

Author Message

Damien MARTIN

Monday 08 March 2010 7:59:11 am

Hi,

I have a problem with an XMLBlock filled from PHP :

$params = array();
$params['parent_node_id'] = 2;
$params['class_identifier'] = 'article';
$params['creator_id'] = 14;
$params['section_id'] = 1;
             
$attributesData = array();
            
$attributesData['title'] = 'My article';
$attributesData['body'] = $content;

$params['attributes'] = $attributesData;
$contentObject = eZContentFunctions::createAndPublishObject( $params );

The content of $content is a valide ez xml code :

<?xml version="1.0" encoding="utf-8" ?>
<section xmlns:image="http://ez.no/namespaces/ezpublish3/image/" 
xmlns:xhtml="http://ez.no/namespaces/ezpublish3/xhtml/">

<header level="1">My Title</header>
 
<link href="http://my.url.tld/pages/infos.php">
    <embed align="left" view="embed" size="medium" href="ezobject://372"/>
</link>

Hello World

</section>

Note : The ezobject with ContentObjectID = 372 has been created just before from the same extension. (It's an image)

The problem is :

  • When I watch the preview of the article from the admin, there is no image.
  • When I edit the article with the online editor, it stops at the link (No "Hello World" string)
  • When I edit directly the source, the href attribute is empty :
<embed align="left" view="embed" size="medium" href=""/>

But if I modify the embed tag and put ezobject://372, the image appears correctly.

So, the question is : Why does eZ don't take my embeded object correctly at the article creation while editing it to put the same value works ?

I can't do it manually on each page, because their will be a lot of page imported by the extension (500+).

Thanks in advance,

Damien

Damien MARTIN

Monday 15 March 2010 7:30:49 am

Hi there,

It looks like my problem isn't so funny :p

I'm looking at the source code of ezodf and I saw the wonderfull eZContentObject::addContentObjectRelation() method.

I think it could save my life but I still don't understand how to use it.

I created my pictures, stored their content object id and tryed a pretty looking :

$o->addContentObjectRelation($object);

Where $o is the newly created "Article" where my XMLBlock is written.

But it don't still works...

The pictures appears in the related objects but the href attribute of the embed tag is still empty.

NB : I also tryed

$o->addContentObjectRelation($object, false, 0, eZContentObject::RELATION_EMBED);

Could someone help me ?

Thanks in advance,

Damien

Nicolas Pastorino

Monday 15 March 2010 8:26:13 am

"
$o->addContentObjectRelation($object, false, 0, eZContentObject::RELATION_EMBED);
"

Hello Damien,

The above looks ok to me, but for the first parameter: you need to pass the object ID, and not the eZContentObject object. What exactly does the $object variable contain in your example ?

Cheers,

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

Damien MARTIN

Monday 15 March 2010 8:57:59 am

Hi Nicolas,

$object is the result of :

$my_object = eZContentFunctions::createAndPublishObject($params);

if($my_object != null)
    return $my_object->ID;

But this part works (I can see the related image in the last panel of the editor "Related objects" ).

My problem is that the href attribute of my ezxml is still empty...

When I update it by hand (disabling "online editor" ), the image is well integrated in my XML Block...

I thought addContentObjectObjectRelation was the solution to my problem, but it looks like eZ do something more and I don't know what.

Thanks,

Damien

Damien MARTIN

Wednesday 17 March 2010 2:26:46 am

Hi there,

I finaly found what was wrong :

When you add the tag for embeding images, you should not use the href attribute, but an object_id attribute.

so :

<embed align="left" view="embed" size="medium" href="ezobject://372"/>

become :

<embed align="left" view="embed" size="medium" object_id="372"/>

And eZ will do everything !!!

Nicolas Pastorino

Wednesday 17 March 2010 3:07:35 am

Wow, that actually rocks.

Thanks for the investigation, i'm sure it will help others :)

Cheers !

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

eZ debug

Timing: Jan 17 2025 23:35:46
Script start
Timing: Jan 17 2025 23:35:46
Module start 'content'
Timing: Jan 17 2025 23:35:46
Module end 'content'
Timing: Jan 17 2025 23:35:46
Script end

Main resources:

Total runtime0.7132 sec
Peak memory usage4,096.0000 KB
Database Queries203

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0099 587.8438180.8125
Module start 'content' 0.01000.5904 768.6563606.2344
Module end 'content' 0.60040.1127 1,374.8906341.3672
Script end 0.7131  1,716.2578 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.5648210.0002
Check MTime0.00150.2074210.0001
Mysql Total
Database connection0.00170.236810.0017
Mysqli_queries0.613886.06512030.0030
Looping result0.00220.30702010.0000
Template Total0.687596.420.3438
Template load0.00240.337020.0012
Template processing0.685196.063220.3425
Template load and register function0.00010.017710.0001
states
state_id_array0.00090.123410.0009
state_identifier_array0.00080.111320.0004
Override
Cache load0.00220.3155770.0000
Sytem overhead
Fetch class attribute can translate value0.00180.258930.0006
Fetch class attribute name0.00140.196680.0002
XML
Image XML parsing0.00230.322230.0008
class_abstraction
Instantiating content class attribute0.00000.0040120.0000
General
dbfile0.00490.6908330.0001
String conversion0.00000.000830.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/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
19content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
9content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
5content/datatype/view/ezxmltags/strong.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/strong.tplEdit templateOverride template
1content/datatype/view/ezxmltags/li.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/li.tplEdit templateOverride template
1content/datatype/view/ezxmltags/ul.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/ul.tplEdit templateOverride template
1content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
1content/datatype/view/ezxmltags/emphasize.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/emphasize.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 51
 Number of unique templates used: 11

Time used to render debug report: 0.0002 secs