Forums / Setup & design / multiple section show (nesting)

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!