multiple section show (nesting)

Author Message

Trond Åge Kvalø

Wednesday 18 August 2004 3:24:22 am

Hi folks!

I have made an article class that contains two images. None of them are required.

If there are no pictures I want to use the whole table width to display the text.
If only picture1 has content this image will be placed in the left column.
If only picture2 has content this image will be placed in the right column.
If both picture1 and picture2 have content, I will use a three column layout with text in the middle.

This is how I had thought this would be done:

<table>
{section show=and($node.data_map.bilde1.has_content, $node.data_map.bilde2.has_content) }
  <tr>
    <td>picture1</td>
    <td>text</td>
    <td>picture2</td>
  <tr>
{section-else show=and($node.data_map.bilde1.has_content, $node.data_map.bilde2.has_content|not) }
  <tr>
    <td>picture1</td>
    <td colspan="2">text</td>
  <tr>
{section-else show=and($node.data_map.bilde1.has_content|not, $node.data_map.bilde2.has_content) }
  <tr>
    <td colspan="2">text</td>
    <td>picture2</td>
  <tr>
{section-else}
  <tr>
    <td colspan="3">text</td>
  <tr>
{/section}
</table>

Given that using xml-textfields as containers where I can put images is not an option, are there any easier methods to do the same thing?

I don't even know if this will work. I'm a bit unsure whether I can use "show=" after section-else....

Any thoughts anyone?

best regards
trondåge

trondåge

Bård Farstad

Wednesday 18 August 2004 4:10:31 am

This will not work. You cannot have multiple section-else statements and they don't support the show parameter.

But can't you just have four different sections for this? I.e. remove the section-else and replace it by section. Then you just need to add the correct show syntax for the default block, which should be something like:

show=and($node.data_map.bilde1.has_content|not, $node.data_map.bilde2.has_content|not) 

--bård

Documentation: http://ez.no/doc

Trond Åge Kvalø

Wednesday 18 August 2004 5:52:26 am

Thanks for replying, Bård.

You're probably right about your solution. But this is how I solved it:

<table>
{section show=and($node.data_map.bilde1.has_content, $node.data_map.bilde2.has_content) }
  <tr>
    <td>picture1</td>
    <td>text</td>
    <td>picture2</td>
  <tr>
{section-else}
  {section show=and($node.data_map.bilde1.has_content, $node.data_map.bilde2.has_content|not) }
    <tr>
      <td>picture1</td>
      <td colspan="2">text</td>
    <tr>
  {section-else}
    {section show=and($node.data_map.bilde1.has_content|not, $node.data_map.bilde2.has_content) }
      <tr>
        <td colspan="2">text</td>
        <td>picture2</td>
      <tr>
    {section-else}
      <tr>
        <td colspan="3">text</td>
      <tr>
    {/section}
  {/section}
{/section}
</table>

Hmm... It seems that this is actually a mix of my first post and your reply.

Anyway it works as expected now, and if it works..... don't fix it. Right? :-)

trondåge

Bård Farstad

Wednesday 18 August 2004 5:55:27 am

Yes, if it's not broken then don't fix it ;)

Cheers,

--bård

Documentation: http://ez.no/doc

Edward Eliot

Tuesday 31 August 2004 7:37:32 am

Unless it is inefficient of course!

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

Main resources:

Total runtime0.0218 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.0070 589.0313152.6250
Module start 'layout' 0.00700.0035 741.656339.4453
Module start 'content' 0.01050.0091 781.101693.4453
Module end 'content' 0.01960.0022 874.546938.3047
Script end 0.0218  912.8516 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002511.6519140.0002
Check MTime0.00114.9357140.0001
Mysql Total
Database connection0.00125.688110.0012
Mysqli_queries0.002913.487030.0010
Looping result0.00000.096210.0000
Template Total0.00177.710.0017
Template load0.00094.306810.0009
Template processing0.00073.399110.0007
Override
Cache load0.00052.454210.0005
General
dbfile0.00031.311380.0000
String conversion0.00000.047040.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