Jump to content

celfred

Members
  • Posts

    193
  • Joined

  • Last visited

Everything posted by celfred

  1. I'm viewing my homepage on localhost (the page can be seen there), but actually I went on many other pages to test, checked cache and so on... but no change... I was just thinking about this. But I'm afraid I won't be able to do that right now. I always get scared of such a major update in case I break things ? I prefer having more time ahead of me to do such an action. I'm not trusting my dev abilities ! So I stay tuned for ideas and I'll keep you updated when I update. But thanks a lot for your help @adrian.
  2. Ok. I have the same as you then in PageRender.module, but... hooking into PageRender::renderPage keeps me 'outside' ?
  3. Ah... This TracyDebugger is indeed extraordinary ? There might be a clue here : my Page hooks are in lesser number than yours (no 'if', no 'links'). If I use Page::path, my 'inside' gets triggered, but as soon as I use Page::render, nothing happens ? And why is Page::render not listed our tables (only renderField or renderValue) ?
  4. Well... I have this in the preceding lines which seems to work ok : $wire->addHook('LazyCron::everyDay', null, 'checkActivity'); // Check all players activity $wire->addHook('LazyCron::everyDay', null, 'randomSpecial'); // Set random special monsters $wire->addHook('LazyCron::everyDay', null, 'emptyTmp'); // Empty /tmp subtree every night $wire->addHook('LazyCron::everyDay', null, 'cleanTest'); // Init test-team players Is there a basic hook other that Page::render which I could test with ? (I must admit I'm getting lost in all those hooks, hence my post in the 'Get started' forum ? ) For info, I'm with PW 3.0.62. Thanks for the help !
  5. Hello, I am getting nuts trying to understand hooks and I hope someone in the community will be able to help. This is deiving me crazy ! I have tested tens of possibilities to eventually reduce my code to this : bd('outside'); $wire->addHookAfter('Page::render', function($event) { bd('inside'); }); And if someone could tell me why my bd('inside'); never triggers... I would be infinitely grateful ! EDIT : Forgot to say : this piece of code is in my _init.php included in my template (but I've also tried in my site/ready.php for no better results...)
  6. Thanks @OLSA for this reply. This put me back on some tests I had done previously but didn't work, but I've managed thanks to you ! ? In fact, I had tested the hook you mentionned (for the 1st time, by reading about it in the 'Custom PHP cide' section in the template page) but I had put it in a _init.php file I include in all my templates, but I guess this was the wrong place for back-end templates. From what you've indicated, I put my code in admin.php and it works as expected ? So a big thanks to you ! For information in case someone reads this, here's my code : $wire->addHookAfter('InputfieldPage::getSelectablePages', function(HookEvent $e) { $user = wire('user'); $pages = wire('pages'); if($e->object->name == 'group') { if ($user->isSuperuser()) { $selector = "template=group, sort=title"; } else { $selector = "template=group, created_users_id=$user->id, sort=title"; } $e->return = $e->pages->find($selector); } }); Of course, I had to remove my selector string in the template page because it triggered an error otherwise by indicating that the saved page didn't match.
  7. Hello, I'm facing an issue trying to restrict access to a field so front-end edition is possible in an easy manner for the user. Let me explain : I have a field 'group' which is a Page list of group names. I want the user to be able to front-end edit a 'player' page in which this group field appears. I'd like the user to have a list of groups limited to his or her own groups (so he or she doesn't see all groups created by other users). In the back-end, I use this selector string : template=group, created_users_id=[user], sort=title This works great ! BUT here's my issue : If I back-end edit a 'player' page as 'Admin', the 'group' is empty (since admin is not the created-users-id and the group field is then empty... In other words, I must choose between all groups shown to all users (which may be scary for a user having only 2 or 3 groups whena list of 60 shows up) OR having a correct list for the front-end user, but empty for the back-end 'admin'. Can anyone think of another way I could get the expected result ? I have a feeling the simplest way would be to have a "Ignore for superusers" checkbox next to the 'selector string'. Thanks !
  8. @jmartsch Thanks a lot for your help ! It works now ! But one thing worth mentionning : I was on a 'Page List Select' and it wasn't working, until I found out I had to use the 'Select' type of field ?
  9. Hello, I'm struggling with this : a 'group' field of 'Page' type. The parent of selectable pages is '/groups', the template is 'group', and a member can create some groups in the /groups tree. I would like this user to see only the groups he or she has created so in my 'Find selector' in the backend, I would like to use : template=group, created_users_id=$user->id But that doesn't seem to work... I still get the list of all available groups in the /groups tree. Any idea ? I had a feeling I had already seen that before (something like $user->id must be replaced by users_id or something, but I can't find anything in the Forums... and all my tests keep failing...
  10. Perfect ! It works ! Thanks a lot !
  11. @adrian I was indeed about to tell you I'm updating from... 3.6.9 ! I managed to get back the old version from my remote site). So far, I've tried what you said : Starting with a 'regular' update trhough the module page, clicking on update. It detects the 4?15.4 version. It downloads and then still triggers the same error. Then, I went to check the cookies. I couldn't find the TracyPanelSticky you mentionned, but trying to erase all Tracy cookies (and eventually deleting all my localhost cookies), and also deleting the TracyDebugger folder in my modules folder, and deleting the TracyDebugger folder in my assets/cache/Filecompiler/site/modules... still the same result ? In short, I have deleted all traces I could find of TracyDebugger and tried re-installing 4.15.4 but the error persists. You were perfectly right about the 'sticky panel' : I remember I had the var-dump panel sticky before updating. Thanks a lot for your help.
  12. @adrian : Well, I am upgrading through Setup > Modules > New and I type the className. Everything downloads and then I click 'Install now'. I've checked the path and no, the file doesn't exist. I've tried the Modules > Refresh and re-installed Tracydebugger : same problem. Here's the line mentionned that triggers the issue : File: .../modules/TracyDebugger/TracyDebugger.module.php:1341 Thanks for your quick reply. Edit : I've checked on Github in panels folder, and there is no TemplateEditorPanel.php file... I really don't get it...
  13. Hello to all, I've just tried updating the module and got an error. I then deleted it completely to start all over again (on my local site), and as soon as it is downloaded, even if I choose to leave it uninstalled, I still have the same fatal error (I must delete the TracyDebugger folder in my modules completely to be able to access my site). Here's the error : require_once(): Failed opening required '/home/celfred/PlanetAlert/site/modules/TracyDebugger/panels/TemplateEditorPanel.php' (include_path='.:/usr/share/php') And I'm sorry to say I have no idea what to do... So if one of you could give me a hint, that would be great. I was using TracyDebugger more and more (for minor debugging, I guess you can tell from my question) but I would like to use it more ?
  14. Well that's a great answer ! Thanks a lot @Robin S I was completely unaware of the distinction and your explanation is perfect. I had to struggle with similar issues before and that's quite a step forward for me. Thanks ! I'm gonna take some time to think about all this and read over my code.
  15. Hello, I'm facing a weird behavior (to me)... Why are these requests not returning the same values ? // Test 01 : not working > returns empty $allPlayers = $pages->find("team=$team"); // Returns the 10 players (1 of them has HP=14, others have HP>15, no players have coma=1) $dangerPlayers = $allPlayers->find("(HP<=15), (coma=1)")->sort("coma, HP"); // Returns nothing ??? // Test 02 : Working as expected $dangerPlayers = $pages->find("parent.name=players, team=$team, (HP<=15), (coma=1)")->sort("coma, HP"); // Returns the low HP player If you can explain this to me, I would appreciate because this is causing me a headache right now ? Thanks !
  16. Thanks a lot for your quick help. But I'm not that good and I am running PW 3.0.62 both on local and production. I won't update right now because I'm not able to easily manage different version on local and remote... So I'll manage little by little and do the update later ? But thanks !
  17. Hello, I am discovering PHP tests and this great module (thanks !). Just to mention in case it helps others. The first example kept failing on my website until I understood it was due to the multilanguage setup. Eventually, test 01 became : public function testHomeTitle() { $expected = 'Home'; // we expect the page title to be "Home" $actual = wire('pages')->get(1)->title->getLanguageValue("default"); // check what's the actual title Assert::equal($expected, $actual); // check whether they are equal } and passed ? This may seem perfectly obvious to most of you, but it might help a few ? By the way, I wish I could use my usual debugging tools to debug my tests (sounds quite funny to say ? ) and write something like bd($actual); Here I had to fiddle until I found out about my multiLanguage thing... Would you have any tips on that ?
  18. Thanks a lot for your explanation. I understand things better now ? I've just tested and made sure my cache was up to date, but no change... What's surprising is that with the initial config, I tested somewhere else on my site and it worked. Of course, I double-checked all permissions for the template I'm trying to have the 'Edit' button for... and I'm testing only as a superuser. So that's still a bit myserious to me. But since the problem doesn't occur somewhere else, I guess I AM the culprit who messes things up. That's not a big deal either. I'll do more testing and come back here if I find an explanation. Thanks for your help !
  19. Hello, Another question I have, related not only to FEEL module, but I'm facing it with it so here it is : I load a page via ajax. In the loaded page, I would like to have a $page->feel() to have my front-end link, but the result is nothing. I thought having namespace ProcessWire; at the top of my ajax-loaded page would do the trick, but it doesn't... Does anyone know what I should do ? Thanks !
  20. @tpr Thanks for your quick reply, but with no luck.. I had tried to set the 'user-admin' permission to the 'teacher' role (and I'm trying again right now), but still no Edit link appearing. If I set 'superuser' role back, the link comes back... Another idea ? More info : if I try to front-end edit using the built-in PW capabilities method D gives the same result : not editable even though I'm setting all permissions like superuser's permissions, but editable by double-clicking if I add the 'superuser' role to my 'teacher'. I just don't get it... EDIT : As a follow-up, I have applied a workaround : building a linked page to my user (with a specific editable template) and behavior is now as expected... I should dig a little for the 'official' user profile page front-end edit, but I am not a 'superuser' myself ?
  21. Hi, I'm struggling with something : My 'user' template has page-edit permission for my 'teacher' role My 'teacher' role has page-edit, page-edit-front and profile-edit permissions And yet if I type $user->feel() in my template page (while logged as a 'teacher' user), I get nothing ? If I add 'superuser' role to my logged-in teacher, I get the 'Edit' link. I thought $user were behaving like regular pages... So I've been looking thorugh all my permissions roles for hours but I can't get it to work... I'm lost... Maybe $user is not possible in this context ? If anyone has an idea on where I could look or can explain what's going on here, I'd appreciate.
  22. Hey, Sorry to come back on this, but I'm still struggling... Why is this working as expected ? $notTeacherActions = $pages->find("template=task, owner.singleTeacher=$user"); // Returns 2 pages having the $user in the owner repeater singleTeacher field Whereas this is not : $notTeacherActions = $pages->find("template=task, owner.singleTeacher!=$user"); // Returns nothing where it should return all tasks NOT having this particular user in the singleTeacher owner repeater ? I have a feeling this has to do with my misunderstanding in the previous posts... So I continue here ? By the way, still in this issue, I'm stuck with : $globalActions = $pages->get("name=tasks")->children(); // I have 62 tasks pages $adminActions = $globalActions->find("adminOnly=1"); // I have 10 adminActions $allActions = $globalActions->find("adminOnly=0"); // I have 45 non admin (available to the logged-in user bd($allActions->count()); // This shows me the 45 // The following are my tests to understand... Which I don't :( // First tests from $pages $teacherActions = $pages->get("name=tasks")->children("owner.singleTeacher=$user"); // This returns 2 $notTeacherActions = $pages->find("template=task, owner.singleTeacher!=$user"); // This returns nothing... $notTeacherActions = $pages->get("name=tasks")->children("adminOnly=0")->not("owner.singleTeacher=$user")->sort("category.title"); // This actually returns 45 ($allActions, including the 2 returned in $teacherActions...) bd('from $pages:'.$teacherActions->count().'/'.$notTeacherActions->count()); // I get 2 and 45 // Second test from $allActions // THIS SEEMS LINKED TO MY ORIGINAL REQUEST (AND I'M STILL LOST !) $teacherActions = $allActions->find("owner.singleTeacher=$user"); $notTeacherActions = $allActions->not("owner.singleTeacher=$user")->sort("category.title"); bd('from $allActions:'.$teacherActions->count().'/'.$notTeacherActions->count()); // Returns 0 and 45 As you can see, I still have a long way to go tu understand all this... Sorry if I'm being hard to follow, but I am indeed confused on this issue...
  23. I'm starting understanding things better ? Thanks a lot for this helpul answer ! I'll keep exploring to build a better knowledge of what I'm doing exactly.
  24. Hello, Another newbie question. My Processwire sites is growing and I'm wondering if my way of doing things sounds goog to you. I tend to avoid what I consider 'heavy and frequent' database requests in my functions. For example : // In functions.php myfunction($player) { wire('$pages')->find("myselectors"); // This means about 300 database requests do something... (like $p->newTmpField = 1;) return $player; } // In template.php $allPlayers = $pages->find("template=player"); // About 300 players foreach ($allPlayers as $p) { myfunction($p); } // Now I have access to newTmpField, for example. I tend to replace with : // In function.php myfunction($allPlayers) { foreach($allPlayers as $p) { // do something like set $p->newTmpField = 1 } return $allPlayers; } // In template.php $allPlayers = $pages->find("template=player"); myfunction($allPlayers); // Now $players have been modified. For example, I have $allPlayer->find("newTmpField=1"); So for the moment, I tend to choose the second solution which makes only 1 database request, but what do more experimented developers would recommend ? What I find useful with Page objects in functons arguments is that I have the whole 'tree' I can then 'find' in my function. But as you can see, I need to understand things better. I have a feeling my 'practical' explanation is not really convincing ? Thanks if someone can take a few minutes to give me advice !
  25. Hello ! I have somehting I don't understand here... Here's my code : $allPlayers = $pages->find("parent.name=players, team=$selectedTeam"); $allTrains = $allPlayers->find("template=event, task.name~=ut-action, refPage!='', date>=$startDate, date<=$endDate, sort=refPage, sort=date"); bd('$allTrains:'.$allTrains->count()); // DISPLAYS 0 ???? foreach($allPlayers as $p) { $allTrainings = $p->find("template=event, task.name~=ut-action, refPage!='', date>=$startDate, date<=$endDate, sort=refPage, sort=date"); $test += $allTrainings->count(); } bd('$test:'.$test); // DISPLAYS 883 pages (normal) As you can read from my comments, I have no idea why my first $allTrains stays at 0 while the second request actually finds the corresponding pages. If someone could explain I'd appreciate a lot. I have been struggling with this for hours now... For your information, my pages having template 'event' are in a subtree like so : - player 01 - history-1 - event 01 - event 02 - event ... - history-2 - event 01 - event ... - player 02 - history-1 - event 01 - event 02 - event ... - history-2 - event 01 - event ... - player ... - history-1 - event 01 - event 02 - event ... - history-2 - event 01 - event ... Thanks in advance. (sorry for my preceding 'tree' which doesn't look like much. I need to find a way to output this better ? )
×
×
  • Create New...