Problems inserting into $dataMap

Author Message

Bjarte Lunde

Monday 26 February 2007 6:19:00 am

I'm having difficulties inserting this to the "desc" attribute (XML-block)
Do you see anything i'm doing wrong?

Code:

    // Change characters
    $fraChar = array("æ", "ø", "å", """, "
", "\n", "\r");
    $tilChar = array("&aelig;", "&oslash;", "&aring;", "&quote;", " ", "<br>", "<br> ");
    $description = '<p>'.str_replace( $fraChar, $tilChar, $attributes->elementTextContentByName( 'DESCRIPTION' ) ).'</p>';
    $description = trim( $description );
    $dataMap['desc']->setAttribute( 'data_text', $description );
    $dataMap['desc']->store();

Original XML-text:

<DESCRIPTION>Bilen er topp utstyrt!&#xd;
F1 giring p&#229; rattet&#xd;
18&quot;sommer&#xd;
17&quot;vinter&#xd;
sportsunderstell&#xd;
sportsseter&#xd;
++++</DESCRIPTION>

Betsy Gamrat

Monday 26 February 2007 10:17:58 am

I have had good luck with this approach, basically taking a text string and wrapping it with XML data.

I think if you ran the conversion code, then wrapped it with the XML tags, you would be okay.

$description = XML_wrap($Data);

function XML_wrap($text)
{
return '<?xml version="1.0" encoding="UTF-8"?>' ."\n".
                '<section xmlns:image="http://ez.no/namespaces/ezpublish3/image/"'."\n".
                '    xmlns:xhtml="http://ez.no/namespaces/ezpublish3/xhtml/"'."\n".
                '    xmlns:custom="http://ez.no/namespaces/ezpublish3/custom/"><paragraph>'.
                $text."</paragraph>\n</section>\n";
}

Bjarte Lunde

Monday 26 February 2007 2:24:57 pm

I tried your suggestion, but it didn't do the trick.

I also have this code which inserts with no problem into a xml-block

    $equipment = '<ul>';
    $eqChild = $attributes->elementChildrenByName( 'EQUIPMENT' );
    foreach( $eqChild as $eqElement )
    {
        $equipment = $equipment.'<li>'.trim( $eqElement->textContent() ).'</li>';
    }
    $equipment = $equipment.'</ul>';
    $dataMap['equipment']->setAttribute( 'data_text', $equipment );
    $dataMap['equipment']->store();

Betsy Gamrat

Tuesday 27 February 2007 7:22:59 pm

It may be the <b><br></b> tags. You might want to try using a different substitution just to test the idea. For example, use <b>!</b>, just as a marker.

I don't think all versions of eZ support <b><br></b>.

Good luck.

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 15:55:28
Script start
Timing: Jan 18 2025 15:55:28
Module start 'layout'
Timing: Jan 18 2025 15:55:28
Module start 'content'
Timing: Jan 18 2025 15:55:29
Module end 'content'
Timing: Jan 18 2025 15:55:29
Script end

Main resources:

Total runtime0.7057 sec
Peak memory usage4,096.0000 KB
Database Queries60

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 589.0469152.6250
Module start 'layout' 0.00540.0030 741.671939.4453
Module start 'content' 0.00830.6959 781.1172520.7891
Module end 'content' 0.70420.0015 1,301.906312.1563
Script end 0.7057  1,314.0625 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.4639160.0002
Check MTime0.00130.1870160.0001
Mysql Total
Database connection0.00090.123910.0009
Mysqli_queries0.654492.7260600.0109
Looping result0.00060.0888580.0000
Template Total0.672395.320.3361
Template load0.00210.298720.0011
Template processing0.670294.961020.3351
Template load and register function0.00010.016710.0001
states
state_id_array0.00080.106310.0008
state_identifier_array0.00090.121820.0004
Override
Cache load0.00170.2469230.0001
Sytem overhead
Fetch class attribute can translate value0.00090.125620.0004
Fetch class attribute name0.00160.231350.0003
XML
Image XML parsing0.00090.124420.0004
class_abstraction
Instantiating content class attribute0.00000.002760.0000
General
dbfile0.00180.2500160.0001
String conversion0.00000.000940.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
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 18
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs