$section_array variable

Author Message

Softriva .com

Monday 21 August 2006 1:56:06 am

Anyone knows about this variable

$section_array

It is mentioned in the advacnedsearch.tpl. I am not sure if this var is reserved var or it is actually set the search process.

Is it documented anywhere?

Any info about this var is appreciated.

Kristof Coomans

Monday 21 August 2006 2:21:36 am

Hi OOzy

$section_array is set by the advancedsearch view, it's the result of eZSection::fetchList();

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Softriva .com

Monday 21 August 2006 2:40:38 am

Thanks Kristof,

One more question? Is it an array or a hash. The reason I am asking is that I am trying to make my search template.

The following original search tpl code

<select name="SearchSectionID">
<option value="-1">{"Any section"|i18n("design/standard/content/search")}</option>
{section name=Section loop=$section_array }
<option {switch name=sw match=$search_section_id}
     {case match=$Section:item.id}
selected="selected"
{/case}
{case}
{/case}
{/switch} value="{$Section:item.id}">{$Section:item.name|wash}</option>
{/section}
</select>

produces

  <select name="SearchSectionID">
    <option value="-1">
      Any Section
    </option>

    <option value="1">
      Standard
    </option>

    <option value="2">
      Users
    </option>

    <option value="3">
      Media
    </option>

    <option value="4">
      Setup
    </option>

    <option value="5">
      Design
    </option>
  </select>

While my newly foreach code

    <select name="SearchSectionID">
      <option value="-1">{"Any section"|i18n("design/standard/content/search")}</option>
      {foreach $section_array as $srIndex=>$srSection}
	<option {switch name=sw match=$search_section_id}{case match=$srSection.name} selected="selected" {/case} {/switch} value="{$srIndex+1}">{$srSection.name|wash}</option>
      {/foreach}
    </select>

produces. Note that option value start with 0 i.e. each section is of by 1 due to the fact that the array index starts with 0

  <select name="SearchSectionID">
    <option value="-1">
      Any Section
    </option>

    <option value="0">
      Standard
    </option>

    <option value="1">
      Users
    </option>

    <option value="2">
      Media
    </option>

    <option value="3">
      Setup
    </option>

    <option value="4">
      Design
    </option>
  </select>

Kristof Coomans

Monday 21 August 2006 2:51:36 am

Hi OOzy

It's an array of eZSection objects. You should use their id attribute for your option values, just like the old template code did.

<select name="SearchSectionID">
	<option value="-1">{"Any section"|i18n("design/standard/content/search")}</option>
	{foreach $section_array as $srSection}
		<option {switch name=sw match=$search_section_id}{case match=$srSection.id} selected="selected" {/case} {/switch} value="{$srSection.id}">{$srSection.name|wash}</option>
	{/foreach}
</select>

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.