$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.

eZ debug

Timing: Jan 20 2025 06:52:13
Script start
Timing: Jan 20 2025 06:52:13
Module start 'layout'
Timing: Jan 20 2025 06:52:13
Module start 'content'
Timing: Jan 20 2025 06:52:13
Module end 'content'
Timing: Jan 20 2025 06:52:13
Script end

Main resources:

Total runtime0.0166 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.0059 589.0547152.6094
Module start 'layout' 0.00590.0026 741.664139.4141
Module start 'content' 0.00850.0059 781.078193.3047
Module end 'content' 0.01440.0022 874.382834.3047
Script end 0.0166  908.6875 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002514.8222140.0002
Check MTime0.00116.8620140.0001
Mysql Total
Database connection0.00127.147710.0012
Mysqli_queries0.002011.826230.0007
Looping result0.00000.084710.0000
Template Total0.001810.810.0018
Template load0.00095.713510.0009
Template processing0.00085.057510.0008
Override
Cache load0.00063.581710.0006
General
dbfile0.00031.892180.0000
String conversion0.00000.034540.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