Forums / Setup & design / Embeded file makes ezmatrix disappear

Embeded file makes ezmatrix disappear

Author Message

Linh Vu

Monday 21 May 2007 11:13:10 pm

I'm using: ezp 3.8.8, php 4.4.7, mysql 4.1.15, apache 2.0.54

I have a Person object inserted in a Folder description (XML Block) with Embed view. The Person object has a Comment attribute (XML Block) and a Contact Information attribute (ezmatrix).

When the Comment attribute is blank or only contains normal text, everything is fine.

When the Comment attribute has a file inserted with Embed view, the Contact Information attribute is not output at all.

The full view of that Person works fine in either case.

This is the Person embed view template:

<div class="content-view-embed">
    <div class="class-person clearfix">

        <h2>{$object.name|wash} - {attribute_view_gui attribute=$object.data_map.job_title}</h2>
        {if $object.data_map.picture.has_content}
            <div class="attribute-image">
                {attribute_view_gui attribute=$object.data_map.picture.content.data_map.image alignment=left image_class=original}
            </div>
        {/if}

        <div class="attribute-long">
            {attribute_view_gui attribute=$object.data_map.comment}
        </div>

        <div class="attribute-matrix">
            <h3>{"Contact information"|i18n("design/base")}</h3>
            {attribute_view_gui attribute=$object.data_map.contact_information}
        </div>
    </div>

</div>

This is the File embed view template:

<div class="content-view-embed">
    <div class="class-folder">
    <h3 class="hide">{$object.name|wash}</h3>

    <div class="content-body">
{let attribute=$object.data_map.file}
{section show=$attribute.content}
<a href={concat("content/download/",$attribute.contentobject_id,"/",$attribute.id,"/file/",$attribute.content.original_filename)|ezroot}>{$attribute.content.original_filename|wash(xhtml)}</a> {$attribute.content.filesize|si(byte)}
{/section}
{/let}
     </div>
   </div>
</div>

And this is the ezmatrix view template (stock one that came with ezp):

{let matrix=$attribute.content}
<table>
<tr>
{section name=Rows loop=$matrix.rows.sequential}
    <td>
        {section name=Columns loop=$Rows:item.columns}
            {section show=0|eq($Rows:Columns:index)}
               {switch match=$attribute.contentclass_attribute_identifier}
               {case match='contact_information'}
                     <em>{$Rows:Columns:item}:</em>
               {/case}
               {case match='company_address'}
                     <em>{$Rows:Columns:item}:</em>
               {/case}
               {case}
               {/case}
               {/switch}
            {section-else}
               {$Rows:Columns:item|wash(xhtml)|autolink|nl2br}
            {/section}

        {delimiter}
        </td>
        <td>
        {/delimiter}
        {/section}
    </td>
    {delimiter}
    </tr>
    <tr>
    {/delimiter}
{/section}
</tr>
</table>
{/let}

It seems that when the embed file is there, the line {let matrix=$attribute.content} doesn't work at all, i.e $attribute doesn't exist for that template (I tried {$attribute|attribute(show,1)} and nothing came out).

I've done the usual object inspection, debug view, list of used templates and cache clearing, but I still haven't figured out what's going on. Help! :-)

If I had more time, I would write less code.

Linh Vu

Monday 04 June 2007 12:04:36 am

I got it figured out. The problem is that the $object variable appearing in both Person and File embed view templates are in the same scope so after printing out the comment in the Person template, the $object variable now contains the File (due to the File embed view template) instead of the original Person object.

To solve it, I simply add this at the top of the Person template:

{def $person=$object.data_map}

And use $person in place of $object.data_map from then on.

If I had more time, I would write less code.

eZ debug

Timing: Jan 18 2025 16:17:06
Script start
Timing: Jan 18 2025 16:17:06
Module start 'content'
Timing: Jan 18 2025 16:17:07
Module end 'content'
Timing: Jan 18 2025 16:17:07
Script end

Main resources:

Total runtime0.8984 sec
Peak memory usage4,096.0000 KB
Database Queries189

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0073 588.9453180.8281
Module start 'content' 0.00730.6986 769.7734508.9688
Module end 'content' 0.70590.1924 1,278.7422337.0703
Script end 0.8983  1,615.8125 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00410.4608210.0002
Check MTime0.00160.1745210.0001
Mysql Total
Database connection0.00090.102510.0009
Mysqli_queries0.811990.37171890.0043
Looping result0.00230.26081870.0000
Template Total0.865696.420.4328
Template load0.00200.217720.0010
Template processing0.863696.132620.4318
Template load and register function0.00010.011610.0001
states
state_id_array0.00110.118110.0011
state_identifier_array0.00120.129720.0006
Override
Cache load0.00160.1785230.0001
Sytem overhead
Fetch class attribute can translate value0.00150.167220.0008
Fetch class attribute name0.00100.107530.0003
XML
Image XML parsing0.00080.087720.0004
class_abstraction
Instantiating content class attribute0.00000.001140.0000
General
dbfile0.00961.0667270.0004
String conversion0.00000.000730.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
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 16
 Number of unique templates used: 6

Time used to render debug report: 0.0010 secs