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 19 2025 13:51:17
Script start
Timing: Jan 19 2025 13:51:17
Module start 'layout'
Timing: Jan 19 2025 13:51:17
Module start 'content'
Timing: Jan 19 2025 13:51:17
Module end 'content'
Timing: Jan 19 2025 13:51:17
Script end

Main resources:

Total runtime0.8624 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 589.1563152.6250
Module start 'layout' 0.00540.0027 741.781339.4453
Module start 'content' 0.00810.8529 781.2266532.1094
Module end 'content' 0.86090.0014 1,313.335912.1641
Script end 0.8624  1,325.5000 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.3756160.0002
Check MTime0.00120.1436160.0001
Mysql Total
Database connection0.00080.096210.0008
Mysqli_queries0.811794.1209570.0142
Looping result0.00060.0648550.0000
Template Total0.833896.720.4169
Template load0.00210.240620.0010
Template processing0.831796.439220.4159
Template load and register function0.00020.018110.0002
states
state_id_array0.00130.150410.0013
state_identifier_array0.00110.132520.0006
Override
Cache load0.00170.1987190.0001
Sytem overhead
Fetch class attribute can translate value0.00090.100820.0004
Fetch class attribute name0.00170.197540.0004
XML
Image XML parsing0.00110.128720.0006
class_abstraction
Instantiating content class attribute0.00000.001550.0000
General
dbfile0.00100.1174160.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.0002 secs