Announcement

Collapse
No announcement yet.

Template code to modify an array element?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Template code to modify an array element?

    I feel like I should already know this ...
    I need to modify the value of an array element in template code. Initially I wrote something in the form:
    Code:
    <mvt:assign name="l.settings:MyArray[l.settings:ElementNumber]:someMember" value="l.NewValue" />
    But that's not allowed; and according to the docs, you can't use the index or member attributes in mvt:assign like you can in regular Miva Script MvASSIGN.

    The only solution I've thought of is to:
    • Copy the array element to a temporary variable,
    • delete the element from the array,
    • modify the temporary variable, and
    • Insert the temporary element back into the array.
    But that seems kind of klugey. Is there a better way, and I've just forgotten?

    Thanks --
    Kent Multer
    Magic Metal Productions
    http://TheMagicM.com
    * Web developer/designer
    * E-commerce and Miva
    * Author, The Official Miva Web Scripting Book -- available on-line:
    http://www.amazon.com/exec/obidos/IS...icmetalproducA

    #2
    I think the forum has been requesting that feature for years.

    I still have to use the Toolbelt for array indexing in template code.

    You could probably write a small utility module for just that purpose.
    http://www.alphabetsigns.com/

    Comment

    Working...
    X