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.

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 19:29:57
Script start
Timing: Jan 18 2025 19:29:57
Module start 'layout'
Timing: Jan 18 2025 19:29:57
Module start 'content'
Timing: Jan 18 2025 19:29:58
Module end 'content'
Timing: Jan 18 2025 19:29:58
Script end

Main resources:

Total runtime0.7838 sec
Peak memory usage4,096.0000 KB
Database Queries52

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0060 589.1484152.6406
Module start 'layout' 0.00600.0034 741.789139.4766
Module start 'content' 0.00940.7723 781.2656503.8750
Module end 'content' 0.78170.0021 1,285.140612.1406
Script end 0.7838  1,297.2813 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.4251160.0002
Check MTime0.00130.1646160.0001
Mysql Total
Database connection0.00070.094010.0007
Mysqli_queries0.734093.6432520.0141
Looping result0.00060.0773500.0000
Template Total0.748995.520.3744
Template load0.00240.302920.0012
Template processing0.746595.238220.3732
Template load and register function0.00010.014910.0001
states
state_id_array0.00090.112510.0009
state_identifier_array0.00300.378920.0015
Override
Cache load0.00190.2386230.0001
Sytem overhead
Fetch class attribute can translate value0.00070.085410.0007
Fetch class attribute name0.00250.313030.0008
XML
Image XML parsing0.00060.070310.0006
class_abstraction
Instantiating content class attribute0.00000.001040.0000
General
dbfile0.00090.1188160.0001
String conversion0.00000.001040.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
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
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 16
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs