[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

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 29 2025 23:44:59
Script start
Timing: Jan 29 2025 23:44:59
Module start 'layout'
Timing: Jan 29 2025 23:44:59
Module start 'content'
Timing: Jan 29 2025 23:44:59
Module end 'content'
Timing: Jan 29 2025 23:44:59
Script end

Main resources:

Total runtime0.0155 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0048 588.2656151.2266
Module start 'layout' 0.00480.0028 739.492236.6797
Module start 'content' 0.00760.0062 776.171999.0156
Module end 'content' 0.01390.0016 875.187541.9922
Script end 0.0154  917.1797 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002214.5131140.0002
Check MTime0.00106.2613140.0001
Mysql Total
Database connection0.00084.944010.0008
Mysqli_queries0.002214.101730.0007
Looping result0.00000.161810.0000
Template Total0.00127.510.0012
Template load0.00095.771310.0009
Template processing0.00031.693210.0003
Override
Cache load0.00063.831610.0006
General
dbfile0.002315.046180.0003
String conversion0.00000.057040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs