celfred

Members
  • Content count

    114
  • Joined

  • Last visited

Community Reputation

53 Excellent

About celfred

  • Rank
    Sr. Member

Profile Information

  • Gender
    Male
  • Location
    France

Recent Profile Visitors

3,532 profile views
  1. Yep. I could have thought of it. Good idea ! Thanks a lot
  2. Hello, I'm facing an issue with my page fieldtype. Pages appear in the order they were created although I'd like to see them sorted in alphabetical order (by title). The pages are well-sorted in my tree, but in that particular Page fieldtype (on another page), I can't find any place where I would decide on what field I can sort them. Am I missing something here ? Let me know if I'm not clear enough in my explanations. Thanks in advance for a clue
  3. As always in this community, a quick, straight to the point and perfect answer. Many thanks to you @kongondo Sorry for missing it in the docs. I promise I searched for it but I was stuck in the $page part of the API and didn't see the restore()... My bad. Just to mention, I typed 'restore' in the search box (top left), but the API linked in your post above didn't appear in the results Anyway, the answer was quite simple (just as I thought, in the PW 'philosophy') and I'm happy with that. Thanks again !
  4. Hello, I have a feeling I'm missing an easy thing here (again...). If I trash a page from API with : mypage->trash() Is there a simple way to restore it if needed ? I can do it in back-end, but I'd like to do it through API with something like mypage->restore() but this doesn't exit So if you can give me a little help on that, I'd appreciate. Thanks in advance !
  5. Thanks for your explanatory reply. I understand the JS snippet here, but I am not able to make it work yet. The function seems not to be triggered unless I get rid of the "span[data-name="informations"] before the .pw-edit-copy (but then I imagine this works because my field is unique for my test). I tried all sorts of changes with no luck and I am unable to find a way to actually SEE what's going on when my field is being saved after I front-end edit it (so I can find out the correct parent to spot the exact field that's being edited). Not sure of being clear there. Sorry if I'm not ! EDIT (before sending !) : I kept digging with my 'novice' tools and habits : I went back to my Firefox debugging console and displayed the infos of the parent while working only out of .pw-edit-copy selector and I SAW it : it was div[data-name="informations"], not <span> As easy as it might sound to many of you, I'm glad I've managed this ! Thanks again for this answer which helps me improve.
  6. Hello, I can't find my way out of this. I'm trying to use the front-end editing capabilities of PW. It works quite well so far, except if the user sets an empty value. Indeed, in such a case my field just disappears until I reload my page. Here's my code : $out .= '<edit informations>'; if ($page->informations != '') { $out .= '<p>'.$page->informations.'</p>'; } else { $out .= '<p>No infos.</p>'; } $out .= '</edit>'; The idea is to have a paragraph showing 'No infos' if field is empty so the user can double-click on it. He/She then gets the inline editor which works perfectly well as lon as he/she sets a value. But let's say he/she decides (or by mistake) to set an empty value and save, then my paragraph disappears completely and the user must reload the page if he/she wants to edit the field again. I wish I could add some kind of default value if field is empty. Maybe I'm misunderstanding something ? If you have an advice, I'd appreciate PS : I've tried all A/B/C/D front-end possibilities and read and re-read docs, but still the same issue...
  7. Another nice 'lesson' from this community. Thank you very much @Robin S.
  8. Hello, Still in my 'teaching game'. Here's my problem : I 'find' all players with a request like $allPlayers = $pages->find("template=player"); [/code Then, I limit to players belonging to the team of the logged in player with [code] $teamPlayers = $allPlayers->find("team=$loggedPlayer->team"); No problem so far. But my scoreboards rely on either : $allPlayers->getItemKey($loggedPlayer); or $teamPlayers->getItemKey($loggedPlayer); to find the logged player's position in the charts. On the 'global' newboard with scoreboards based upon $allPlayers, everything works as expected. BUT on my 'team' newsboard, even though I'm using $teamPlayers, the returned indexes are based upon $allPlayers. Am I clear ? In other words, I have a total of 125 players, and my logged player is 61 out of 125 regarding the number of places he freed. But in his particular team of 25 players, he sould be 15 whereas he's still 61 I'd like to reset my indexes (and start back from 0), but I can't find my way out of this... If someone has a hint to help, I'd appreciate. I have a second part in my worry : I had a way around it by simply making another 'raw' request : $teamPlayers = $pages->find("team=$loggedPlayer->team"); Then my team indexes were right, but I faced another issue : Reordering my wirearray according to the scoreboard I want usually worked fine (simple sort() based upon an integer field, for example, player's coins, player's karma...) and indexes were updated BUT resorting with places.count ('places' field is a pageArray) doesn't update the indexes returned by getItemKey and my logged player is always at the position he was when I first did my initial $pages->find() query So my way around found its limit and that's why I'm posting here, after struggling with this for a couple of hours... Thanks in advance for the help.
  9. It is an integer and I've checked the setting and intentionally set it to 'Yes' because my freeActs field had no value in some pages and I wanted those pages to be returned. In short, a player being level 1 with no previous activity should have access to items having level 1 set, enough Gold Coins (GC) and 0 previous 'free' actions... I guess I'm not clearly understanding this yet. I'll go ahead and try to check 'No' and see what's going on, but later during the day. Thanks for your help @Robin S
  10. Hello to all, This time, I'm stuck on an issue with a 'find' request. I have found a turnaround, but I have no idea what's going on, really, and I wish I could understand. My code is the following : $nbEl = $player->places->count(); $items = $pages->find("template=place|item|equipment, GC<=$player->GC, level<=$player->level, freeActs<=$nbEl")->sort("template, name"); If I explain briefly : the $items should contain the possible elements for a player according to his level and GC (gold coins), and freeActs, i.e. the number of already 'bought' places. If the 1st line $nbEl returns a number higher than 0, it 'works', I get some items. BUT if the player has not bought any place yet and then $nbEl = 0, $items is... empty whereas it should contain all elements being accessible with a 0 'freeAct' field (and there are many). I have tried to hard-code 'freeActs<=0', I get no items. 'freeActs<=1', I get some nice results' AND THEN, 'freeActs=0' and it works as expected So here's my 'workaround' : $nbEl = $player->places->count()+1; $items = $pages->find("template=place|item|equipment, GC<=$player->GC, level<=$player->level, freeActs<$nbEl")->sort("template, name"); Note the 'freeActs<$nbEl' instead of 'freeActs<=$nbEl' and the '+1' for $nbEl so not to start at 0... Then, it works as expected !?!? Does someone have an explanation for this ? Thanks in advance if you do. And don't hesitate asking me for more details/explanations if you need.
  11. @kongondo Sorry for being late on that... Thanks for your reply. Somehow, your answer is comforting since things should work the way I was understanding them. Now I'll try and find out what's going on in my code. Good point about my wrong variable name. I wasn't even aware of that... Shame on me...
  12. Thanks. But is that new in some way ? Or was it always like that but I didn't notice ? Just making sure I'm being understood : the equipment is added to the player's page, BUT it stays in the equipment list even though I reload the page and empty the cache. I thought it wouldn't stay since I didn't save the page.
  13. Hello, Just a simple (I think) question which is in the title of my post. Roughly speaking : here's my code (made-up because my real function is so long... I don't want to post it all here ) function updateScore($player, $task, $real = true) { [...] $player->score = $player->score+$task->score; if ($task->name == 'new-equipment') { $new-eq = $pages->get("name=sword"); $player->equipment->add($new-eq); } if ($real == true) { $player->save(); } } Everything works fine when I call updateScore($player, $task, true), but if I call updateScore($player, $task, false), scores are untouched, but the equipment gets added ! It used to work fine on PW2.7 but my update to PW 3.0.62 seems to have broken this... Is there a simple explanation ? I keep reading my code over and over and this is driving me crazy... Thanks !
  14. Here's what I think : I had an 'old' processwire directory which I downloaded through Git and which I thought was up-to-date with master (not dev branch) so I really imagined I was with 3.0.62. (I'm sure I did a git pull but I guess not...) And today I added PW version in my footer and saw 3.0.36 and imagined I forgot about the version number _ must have been 3.0.32 and they've already made some changes and now it's 3.0.36... Anyway, you see how good I am with Git and some stuff So I'm really sorry about all these issues which shouldn't have happened if I had done things correctly. I'll update for real (!) and see how it goes. Thanks again for your help and time. I appreciated a lot ! And about my Tracy 'theme' : I just use my computer 'negative' mode because I have eyesight problems and I feel better this way. So no leaking, don't worry EDIT : 3.0.62 installed : I can confirm, there is no more a bug with the 2 forms of 'find' statements.
  15. I PMed you the files so as not to 'pollute' this post with unnecessary lines. Edit : I added my Tracy console.