Remove an element from an array

Author Message

Eirik Alfstad Johansen

Friday 13 August 2004 3:47:10 am

Hi guys,

What's the easier way to remove an element from an array (using the template language) when the item value (not the key) is know.

I've tried various loops, but can't seem to get it to work.

Thanks in advance !

Sincerely,

Eirik Johansen
http://www.netmaking.no/

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Paul Forsyth

Friday 13 August 2004 4:30:35 am

Would this work (quickly written):

$knownValue=""
$newArray=array();

{section var=Item loop=$oldArray}

  {section show=ne($Item, $knowValue)}
    $newArray|append($Item)}
  {/section}

{/section}

{set oldArray=$newArray}

It uses an extra array for this...

Eirik Alfstad Johansen

Tuesday 31 August 2004 11:49:01 am

Thanks a lot, Paul. BTW, here's the code I ended up with:

{let newArray=array()}
{section loop=$node.object.parent_nodes}
  {switch match=$:item}
  	{case match=128}
	{/case}
	{case}
		{let newArray=$newArray|append($:item)}
	{/case}
  {/switch}
{/section}
{/let}

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

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 15 2025 00:35:37
Script start
Timing: Jan 15 2025 00:35:37
Module start 'layout'
Timing: Jan 15 2025 00:35:37
Module start 'content'
Timing: Jan 15 2025 00:35:39
Module end 'content'
Timing: Jan 15 2025 00:35:39
Script end

Main resources:

Total runtime1.8725 sec
Peak memory usage6,144.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0069 684.5391183.6875
Module start 'layout' 0.00690.0089 868.226652.5625
Module start 'content' 0.01581.8549 920.78911,792.4453
Module end 'content' 1.87070.0017 2,713.234468.5469
Script end 1.8724  2,781.7813 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00560.2977160.0003
Check MTime0.00150.0811160.0001
Mysql Total
Database connection0.00170.093410.0017
Mysqli_queries1.804196.3468570.0317
Looping result0.00080.0427550.0000
Template Total1.814596.920.9072
Template load0.00410.216920.0020
Template processing1.810496.683720.9052
Template load and register function0.00160.084210.0016
states
state_id_array0.00230.121710.0023
state_identifier_array0.00360.193220.0018
Override
Cache load0.00370.1977190.0002
Sytem overhead
Fetch class attribute can translate value0.00080.041020.0004
Fetch class attribute name0.00280.148640.0007
XML
Image XML parsing0.00060.034120.0003
class_abstraction
Instantiating content class attribute0.00000.000650.0000
General
dbfile0.00170.0929160.0001
String conversion0.00000.000940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 15
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs