Forums / Setup & design / relations in xml text

relations in xml text

Author Message

Ben Pirt

Friday 20 January 2006 2:39:12 am

Hi there,
Thanks for all of the replies on my last question about creating a new node without a draft. Here's another tricky one I think...

Is it possible to be able to tell which related nodes are used in xml text fields for a node and which ones are ust related.

Why?

I am building a site where the owner is able to link up all kinds of related content to a particular page, which then gets automatically linked up in a list in the right hand column. However, sometimes he uses some of these relations in an xml text field (e.g. embedding images) and so they now show up twice on the page. If I could tell which ones were linked to the xml text area then I could choose not to show them in the RH column.

Any ideas? Short of writing an extension to return an array of related nodes to an xml field.

Cheers,

Ben

Xavier Dutoit

Friday 20 January 2006 1:14:52 pm

I made this extension extactly for the need you discribe.

http://ez.no/community/contribs/template_plugins/getobjects_extension

The name of the tag (object) has changed on 3.6, you'd have to update the code. That's simple, but I don't have the time to do it and test it... but I'd be more than happy to add the modification you're going to do on it ;)

You can find it on pubsvn too.

X+

http://www.sydesy.com

Ben Pirt

Tuesday 24 January 2006 11:18:22 am

Thanks Xavier,
Great extension and absolutely perfect for my needs. Hopefully it will be included in eZ before too long. As suggested I made some changes, which were basically to check for dom elements called "embed" and to also check if they have an attribute of "object_id". So the function "modify" is now as follows:

function modify( &$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters )
    {
        if (!isset($namedParameters['xmlattribute']->DataText))
            return "should be an attribute";
         
        $xmldata =& $namedParameters['xmlattribute']->DataText;
        $xml = new eZXML();
        $dom =& $xml->domTree( $xmldata );
        if ( is_object ($dom) )
        {
            $objects =& $dom->elementsByName( "embed" );
            foreach ($objects as $object)
            {
                $attributes=& $object->attributes();
                foreach ($attributes as $attribute)
                {
                    if ($attribute->Name == "object_id")
                        $operatorValue[] = $attribute->content;
                } 
            }
        }
    }

I haven't done a check for the eZ version, but this is working perfectly on my 3.6 installation.

Thanks again,

Ben Pirt

Xavier Dutoit

Wednesday 25 January 2006 12:05:59 am

Thanks for your contrib,

I've modified it so it's compatible both with 3.5 and 3.6.
That's on pubsvn and on the contrib area too;

Could you test with your config and tell me if it's ok ?

X+

http://www.sydesy.com

eZ debug

Timing: Jan 18 2025 14:52:38
Script start
Timing: Jan 18 2025 14:52:38
Module start 'content'
Timing: Jan 18 2025 14:52:39
Module end 'content'
Timing: Jan 18 2025 14:52:39
Script end

Main resources:

Total runtime1.5532 sec
Peak memory usage4,096.0000 KB
Database Queries197

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0055 587.7031180.8438
Module start 'content' 0.00551.4193 768.5469554.2188
Module end 'content' 1.42490.1282 1,322.7656336.7578
Script end 1.5531  1,659.5234 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.2564210.0002
Check MTime0.00150.0964210.0001
Mysql Total
Database connection0.00090.055910.0009
Mysqli_queries1.485295.62301970.0075
Looping result0.00190.12201950.0000
Template Total1.524898.220.7624
Template load0.00200.131520.0010
Template processing1.522798.041020.7614
Template load and register function0.00020.013910.0002
states
state_id_array0.00090.058110.0009
state_identifier_array0.00150.096520.0007
Override
Cache load0.00180.1128320.0001
Sytem overhead
Fetch class attribute can translate value0.00090.060130.0003
Fetch class attribute name0.00180.117750.0004
XML
Image XML parsing0.00090.058730.0003
class_abstraction
Instantiating content class attribute0.00000.001060.0000
General
dbfile0.00310.1965270.0001
String conversion0.00000.000330.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
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 18
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs