Share » Forums » Setup & design » How do I use the section id in...

How do I use the section id in pagelayout.tpl?

How do I use the section id in pagelayout.tpl?

Thursday 23 June 2005 7:49:28 pm - 3 replies

Author Message

Daniel Beyer

Friday 24 June 2005 11:32:03 am

Hi,

if you want to keep your existing code try this:

{let subNav='yes'}

  {switch match=$module_result.section_id}
    {case match=1}
      {set subNav='no'}
    {/case}

    {case match=2}
      {set subNav='yes'}
    {/case}

    {case}
      {* This is the case if nothing is in $module_result.section_id - or the sectionID was not mentioned above...  *}
    {/case}
  {/switch}

	{section show=$subNav|eq('yes') }

	*some html etc.*

	{section-else}
	
	*some html etc.*

	{/section}
{/let}

Personaly I prefer boolean instead of 'yes' and 'no'. But this will work too...

To do that with boolean values, try that:

{let subNav=true()}

  {switch match=$module_result.section_id}
    {case match=1}
      {set subNav=false()}
    {/case}

    {case match=2}
      {set subNav=true()}
    {/case}

    {case}
      {* This is the case if nothing is in $module_result.section_id - or the sectionID was not mentioned above...  *}
    {/case}
  {/switch}

	{section show=$subNav }

	*some html etc.*

	{section-else}
	
	*some html etc.*

	{/section}
{/let}

Refer to this docs:
-http://ez.no/ez_publish/documentation/development/libraries/ez_template/functions/switch
-http://ez.no/ez_publish/documentation/customization/custom_design/template_variables_set_by_ezpublish

Hope this helps...
...and have a nice weekend with trying it ;)

Daniel Beyer
_________________________________
YMC AG
Kreuzlingen, Switzerland
web: www.ymc.ch
____________________________________

Nathan Kelly

Sunday 26 June 2005 5:32:12 pm

Hi Daniel,

thankyou very much for your suggestions, I have used the second one that uses Boolean values an it has worked fine.

I have one more quick question, how can I use this with multiple sections? For example if all of my web pages belong to section 1 exept for the home page and one other page do simply add an extra case, or is it more complex than that?

or can I do something like the following?

    {case match=1,4}
      {set subNav='no'}
    {/case}

Like build an array with those section id's in it?

Thanks again for your help!

Pardon me while I burst into flames...

Daniel Beyer

Tuesday 28 June 2005 9:00:11 am

Hi,

in this case forget about the {switch} thing. It would be nicer to do it with a simple {section show} (or a {if} if you're using eZ 3.6.0 or up):

{let subNav=false()
     showSubNavSections=array(1,3,7,4}

  {section show=$showSubNavSections|contains($module_result.section_id)}
      {set subNav=true()}
  {/section}

	{section show=$subNav }

	*some html etc.*

	{section-else}
	
	*some html etc.*

	{/section}
{/let}

Or even better do only one {section show} for this:

{let showSubNavSections=array(1,3,7,4}

	{section show=$showSubNavSections|contains($module_result.section_id)}

	*some html etc.*

	{section-else}
	
	*some html etc.*

	{/section}
{/let}

Refer to this docs:
http://ez.no/ez_publish/documentation/incoming/appendices/appendix_e_ez_publish_template_operators
http://ez.no/ez_publish/documentation/incoming/appendices/appendix_f_ez_publish_template_functions

Daniel Beyer
_________________________________
YMC AG
Kreuzlingen, Switzerland
web: www.ymc.ch
____________________________________

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu