Search the Community
Showing results for tags 'deleting'.
-
Hello, I'm coming back to you since I've finally managed to extract the 'buggy' part of my code. Here's my problem : When a player loses a level, I want this player to lose all his equipment, so I wrote : foreach ($player->equipment as $equipment) { $equipment->delete(); } But here's what happens : The original equipment pages get deleted ! Not just the item in the AsmSelect ! And I just can't figure why this happens ! Yet I'm sure I am misunderstanding some basic principle here... So if anyone could give me a hint, I'd appreciate. To be more precise : my equipment list is in my tree in equipment/weapons/ and has many pages, such as sword, bow, gun... (It looks violent but it's not, it's a classroom experiment to motivate teenagers ) and my AsmSelect resides in a player template so whenever a player has the possibility, he can select an equipment page. Everything works fine, except when I use this 'delete' line In other words, how could I clean this asmSelect without actually deleting the pages in the original equipment tree? Thanks in advance !
-
Hello, I am struggling again with my lack of understanding of PHP developement (I guess)... I would just like to get rid of a field (part of a repeater) in my page if I find a particular value. My code is the following : $name = $pages->get($id)->title; // THIS IS THE VALUE I SEARCH FOR $found = $pages->find('guests.guest_name='.$name); // THESE ARE THE PAGES CONTAINING THE VALUE foreach ($found as $f) { // LOOP THROUGH THE PAGES foreach ($f->guests as $g) { // LOOP THROUGH THE REPEATER TO GET RID ONLY OF THE FIELD CONTAINING THE NAME I AM LOOKING FOR if ($g->guest_name == $name) { // IF I FIND THE NAME IN THE FIELD $f->remove(guests.guest_name); // GET RID OF THE FIELD. THIS IS THE LINE I REALLY DON'T UNDERSTAND : REMOVE? DELETE? HOW TO USE IT...? } } } I've tried to show my way of seeing things here, since I'm not sure I'm thinking well about my issue. Feel free to put me on the right tracks ;-) And as always, thanks in advance for your help.