DooPHP IRC channel


looping arrays in object attributes

Share your tips, snippets and experiences about DooPHP, and discuss about best DooPHP practices.

looping arrays in object attributes

Postby UmbertoKo » Mon Mar 01, 2010 10:56 am

Hi!

I'm looking for a solution for deep arrays like this:
Collection(1-n)->Dress(0-n)->Image(0-n)->path

The parser of
Code: Select all
<!-- loop -->
works not correctly on so much dimensions. After the first we get Problems.

Loop Collection will create:
Code: Select all
foreach($data['Collection'] as $k1=>$v1)
.
Code: Select all
{$v1->collection_name;}
will work fine.

But Loop on Dresses
Code: Select all
<!-- loop Collection' value.@Dress -->
will create
Code: Select all
foreach($v1 as $k2=>$v2):
which is false!
Code: Select all
foreach($v1->Dress as $k2=>$v2):
is, what I expected!

What I see is the Problem in looping object attributes ("Collection' value.@Dress"). In a different way (but sub-optimal)
Code: Select all
<!-- loop Collection' value' -->
with
Code: Select all
<!-- if (Collection' value' key') == 'Dress' -->
I can access only the Dress attribute of class Collection & loop them. This can not make me happy :(

I hope, there is a way in parsing loop elements to make this better.

But "in Großem und Ganzem" (is german and means the wohole thing) DooPHP is very nice!

UmbertoKo
UmbertoKo
 
Posts: 13
Joined: Tue Feb 16, 2010 8:48 am

Re: looping arrays in object attributes

Postby RichardM » Mon Mar 01, 2010 11:17 am

Hi,

I was not a fan of the existing DooView class and most importantly its looping method so I have added in support for better looping using DooViewBasic. Just check out the very latest version from SVN and see the information found here: viewtopic.php?f=7&t=1015

I think you will find its looping options more in keeping with what you need. I am also assuming there is a 'limit' to the level of looping you are still doing as neither DooView or DooViewBasic support iteration to an unknown depth.


Richard
RichardM
 
Posts: 1054
Joined: Sun Aug 30, 2009 6:03 pm
Location: Cumbria, UK


Return to Tips & Tricks

Who is online

Users browsing this forum: No registered users and 1 guest