Jump to content

celfred

Members
  • Content Count

    168
  • Joined

  • Last visited

Community Reputation

60 Excellent

About celfred

  • Rank
    Sr. Member

Contact Methods

  • Website URL
    https://planetalert.tuxfamily.org

Profile Information

  • Gender
    Male
  • Location
    France

Recent Profile Visitors

4,789 profile views
  1. That's what I keep telling myself but I often end up having a greater and more difficult challenge πŸ™‚ On my side, front-end editing seemed a good solution because I may have up to 50 textareas to edit and if I have to click on each in back-end, save and go to another, having a rather slow connection, can be troublesome... Here, I can load all the 'alerted' textareas on 1 page and edit them 'right away'. It was then just (!) a matter of automatically detecting who was the last user to modify the text. But nevermind for now, as you said, I still have learned a lot trying to do that ! Thanks a lot for your encouraging message and your help !
  2. Thanks @bernhard for your reply. This helps me feeling more confident about my tests since I often don't know if I'm going in the right direction. I must admit I am not mastering anything there (you can tell !). I was glad to learn about the 'Event interceptor' but it seems like it lead me on a false interpretation πŸ˜‰ So hooks don't fire when front-end editing ? I don't really understand why since the field is actually saved, isn't it ? So I guess I won't be able to avoid my 'Manually check this box to alert your teacher' way of doing πŸ™‚
  3. Still desperately trying things... I have this in my ready.php : $this->addHookBefore('Fieldtype::savePageField', function (HookEvent $event) { bd('ok'); // Also tried fl(), d()... }); I have nothing anywhere (after front-editing my textarea and clicking 'save' in my CKEditor) aven after reloading the page, whereas if I use the event interceptor, I get the whole list of fields being saved (after reloading the page) and I can see that one of them is the field I have just edited. So I'm stuck 😞
  4. Thanks a lot @Zeka for your reply. I do use TracyDebugger in my usual debugging 'flow', but my problem here is that it never triggers anything, and that is exactly what I don't understand. After trying some more things, I can understand thath Tracy works in hooks by testing this : $this->addHookBefore('Page::render', function(HookEvent $event) { bd('ok'); }); which does give me a result on page load. Eventually, my concern is there : in my initial question, I want to debug in a hook that doesn't completely reload my page. I guess that's why I can't see anything. When I double-click my textarea to front-end edit it and then hit 'Save', the page doesn't reload so my dump bar stays silent. Is there a way to dynamically see what's going on ?
  5. Still digging... I have tried this taken from the docs : $wire->addHookAfter('Pages::saved', function(HookEvent $event) { $page = $event->arguments(0); $event->message("You saved page $page->path"); }); But I see nothing... My logs > messages do not show anything, my Tracy bar doesn't show anything... Does a front-end edition and a hit on the 'Save' button does not trigger the hook ? I have a feeling I was confusing things in my previous post, so all in all, let's sum up my question : how do you debug hooks ? Is a simple bd('ok') suppose to work if the hook is working ?
  6. Hello, Here's what I'm trying to achieve : I have a textarea field that is frontend editable on any page I want to. If a user with a specific role updates it, I want to tick a checkbox field on the parent page where the textarea resides. So I tried to hook as follows in my ready.php file : $this->addHookBefore('Fieldtype::savePageField', function(HookEvent $event) { $page = $event->argument[0]; $field = $event->argument[1]; if($this->user->hasRole('teacher')) { $page->alertBox = 1; } // DEBUG HERE (bd($page), l($field)... ???? }); Of course (!) it doesn't work (yet !) but the thing is I have no idea how to debug this since my bd() never triggers. I've tried the 'Event interceptor' of Tracy debugger which helped me setting up my hook. I guess my $page and $field are correct... but how could I go any further ? The road is long to become a dev (when you're not one πŸ™‚ )... For further information in case someone wonders : I'd like to set up a textarea that is modified by a user (having a 'player' role, ie 'student'). When front-end modified, I wish it would automatically alert me (the teacher) by ticking a box. So when I log in with my teacher role, I get a list of all textareas I have to read over. When I read/correct/update them (front-end), I would like my hook to automatically untick the box to remove it from my list. In other words, the 'textarea' status should go back and forth according to who modified it last. For the time being, I have managed to make it work with a checkbox that the user has to manually tick/untick, but I've noticed many kids forget to tick the box so they edit their text and I don't get a notice 😞 Thanks if anyone takes time to try and help me on that one !
  7. Well, I'm getting there... almost ! I used JS to update timestamp. Everything works as expected, except... (sorry...) : only admin can list users ? The aforementioned code by @bernhard : $pages->find("template=user, meetinghalltimestamp>$nowMinusTenMinutes") only returns result when I'm logged in as admin. Should I set my timestamp field on another template or is there a way to 'open' this and is it a recommended practice ? EDIT : I saw that adding 'include=all' to my request made it. Thanks for all your help !
  8. Thanks @LostKobrakai. I understand the problem and my concern was really a very basic thing, even if some use cases 'pass through'. It is nothing professional πŸ˜‰ and @bernhard's solution seems to the point for me : if another user loads any page, he or she will get an indicator of how many connected users are online and for those being active on the Meeting Hall, let's say within the last 10 minutes, a 'bell' will be added to show this recent activity. My only left concern now is when people are on the Meeting Hall page for more than 10 minutes, using the collaborative pad (which is embedded from another server), hence having no 'activity' on the page. I should need to update the timestamp. I'll have to see if it's possible to have a 'cron' function while connected on a particular page or simply add a button on which a user can click to update his or her timestamp to say "I'm here !"... Again, much work (for me) for not so much effect... πŸ™‚ But thanks a lot for your help !
  9. Wouah. Thanks a lot for your explanations ! I had thought of the tabs issue, but couldn't think of another possibility πŸ™‚ And your timestamp idea sounds great ! I'll go ahead and try and do that instead, but it'll take ME some time so that's for tomorrow I guess ! But the more I think about it, the more I see how this can be made YOUR way. Thanks !
  10. Hi @bernhard, Thanks for your interest. Actually, it is not a big thing. I have a collaborative pad that I share with my middle-school students that resides on the Meeting Hall page. I have used the database session manager module to get a liist of logged-in users so that when someone is on the homepage, he or she can see if others are connected at the same time. And now, I would like to simply add a 'bell' next to the connected names when they actually are ON the Meeting Hall page so others can know they are there. So my idea was to add a Page field on my meeting-hall template with connected users updating... as they come and go... Maybe that's a lot of 'fuss' for not so much, though...
  11. Hello, I'm struggling with hooks to try and do this : adding user page to a page field when visiting a particular page on my website. In fact, I want to have a list of connected users on a particular page (called meeting-hall). I've tried all kinds of things (which I don't really understand, sorry) but the latest is this : $wire->addHookBefore('Page::render', function($e) { $page = $e->arguments(0); if ($page->is("name=meeting-hall")) { $page->connected->add($user); // connected is a Page field $page->save(); } else { $meeting = wire("pages")->get("name=meeting-hall"); $meeting->connected->remove($user); $meeting->save(); } }); I put this in my _init.php file but nothing works... The best I managed was updating my 'connected' field when the user loads the 'meeting hall' page by having this on the page template : if ($user->isLoggedin()) { $page->connected->add($user); $page->of(false); $page->save(); $page->of(true); } But I wanted to remove the user when he or she leaves the page... hence my thought about using hooks... If you can give me a hint, I'd greatly appreciate !
  12. @MadeMyDay Thanks for your reply. From your comment, I have tried testing my $allEments function (it takes 0.415s on localhost). You can see the code there : https://framagit.org/celfred/planetAlert/blob/master/site/templates/my-functions.inc (function teamFreeWorld() line 1468) BUT I have also tried this : $out .= $map->render($allElements->eq(0), 'map', $options); And the page now loads a lot faster (I can tell the difference even on localhost) ! So maybe it's because I have 56 (or even 96) markers, with a photo... ? What could I do, then ? I hope you (or anybody else) will have other pieces of advice for me πŸ™‚ My site has improved so much over the years thansk to the help of this community (and I have learned so much - you can tell I'm not a pro dev πŸ˜‰ - I'm a teacher and the website is for motivating my middle-school pupils) EDIT : Well, for the moment, I've just removed the images in my map markers tooltips and it loads faster...
  13. Hello, After spending hours trying to find a solution, I ask the community for help... I have a map showing up on page load. It works fine but it takes quite a while. You can see it in action there : https://planetalert.tuxfamily.org/world/6ef (be patient, loading is terrible) I have already tried caching parts of my page (the different lists) and it's ok, but I can't manage to cache the map. So I would like to load the 2nd tab (when clicking on the faces icon at the top-left corner) by default to get a fast loading page and have my map loading on an ajax call. But all my tests are complete failures 😞 Here's my ajax part of code : [...] // Setting $allElements (for markers) and $options there $map = $modules->get('MarkupLeafletMap'); $out .= $map->getLeafletMapHeaderLines(); $out .= $map->render($allElements, 'map', $options); Eventually, I get my map box, but it stays empty 😞 Any advice, please ?
  14. Hi there, I have quite a weird issue here. On my local site, the Trash page has completely disappeared ! I've looked everywhere and I can't find it. I have no idea what has happened and how long it has been this way... On my remote, Trash is there. I also have 2 'Admin' in the tree... If I do a 'Find' search, I get a Trash page but I can't act on it. Any clue on what I could do ? Screenshot attached.
  15. Back again on my preceding matters (sorry to insist...) I've just noticed this recurring line in my modules log : Do you think this could explain my previous case ? Any advice on what I should do ? Should I try and reinstall Oages2Pdf completely ? (I'm scared of breaking things). Thanks !
Γ—
Γ—
  • Create New...