Jump to content

flash

Members
  • Posts

    190
  • Joined

  • Last visited

Everything posted by flash

  1. Thanks for the reply @Jan Romero But it didn´t work? hmm.. i wonder why it works on localhost and not on live server.. just to be clear the file is outside the templates folder, root of the website folder. I have tried to put the file inside the template folder in my assets/auction-page/ folder but then it won´t work. So therefor i put it in the root folder. <script> // (B) LAST UPDATED TIMESTAMP var last = 0; // (C) AJAX LONG POLL function poll () { // (C1) FORM DATA let data = new FormData(); data.append("last", last); console.log("Fetch run", last); // (C2) FETCH UPDATE ON SERVER RESPONSE fetch("<?=config()->urls->httpRoot?>auction-longpolling.php", { method:"POST", body:data }) .then(res => res.json()) .then(data => { // (C2-1) UPDATE HTML DISPLAY document.getElementById("bid").innerHTML = data.bid; // (C2-2) NEXT ROUND last = data.unix; poll(); }) // (C3) CATCH ERROR - LOOP ON TIMEOUT .catch(err => poll()); } // (D) GO! window.onload = poll; </script>
  2. I need some help to specify path to website root. templates/assets/auction-page/javascripts.php fetch("../../auction-longpolling.php", { method:"POST", body:data }) the file is located in website/auction-longpolling.php It´s working in localhost but not on live server?
  3. Maybe I have to define the auction-bid before i can define the variables with the parent? Because it's not working right now
  4. Yes, its not getting the parent page? Should i defined it before? I´m lost PHP Warning: Undefined variable $pageparentdate Also i got Undefined variable $parent
  5. $wire->addHookAfter('Pages::added', function(HookEvent $event) { $page = $event->arguments(0); $pageparentdate = $page->parent->auction_end_date; $parentdateminusstart = date( 'Y-m-d H:i:s', strtotime($pageparentdate . ' - ' . "3" . ' minutes')); $parentdateminusend = date( 'Y-m-d H:i:s', strtotime($pageparentdate)); if (!$page->matches("template=auction-bid, auction_bid_date>={$parentdateminusstart}, auction_bid_date<={$parentdateminusend}")) return; $parent = $page->parent; $parentdate = $parent->auction_end_date; $parentdateadded = date( 'Y-m-d H:i:s', strtotime($parentdate . ' + ' . "3" . ' minutes')); $parent->setAndSave('auction_end_date', $parentdateadded); }); Thank you so much @Jan Romero Current code. Error! I get Undefined variable $pageparentdate? Don´t know how to define it?
  6. But how should i test a variabel in ready.php? I´m not so familiair with the debug tool.
  7. If i use this if($page->template != "auction-bid, auction_bid_date>=$parentdateminusstart, auction_bid_date<=$parentdateminusend") return; It will not work, but if i remove the date variables then it will work. So something is wrong with it.. hmm if($page->template != "auction-bid") return; Should i place the variables elsewhere?
  8. The parent field (auction_end_date) is set. First i add auction-page, then users will add bid (auction-bid).
  9. Well the code is not working correct. I don´t now how to fix it. I want it to look for if the current time is less than 3min from the end date.
  10. I wan´t to change the parent page date when a child is added 1sek - 3 min left of the date/time. $wire->addHookAfter('Pages::added', function(HookEvent $event) { $page = $event->arguments(0); $pageparentdate = $page->parent->auction_end_date; $parentdateminusstart = date( 'Y-m-d H:i:s', strtotime($pageparentdate . ' - ' . "3" . ' minutes')); $parentdateminusend = date( 'Y-m-d H:i:s', strtotime($pageparentdate)); if($page->template != 'auction-bid, auction_bid_date>=$parentdatestart, auction_bid_date<=$parentdateend') return; $parent = $page->parent; $parentdate = $parent->auction_end_date; $parentdateadded = date( 'Y-m-d H:i:s', strtotime($parentdate . ' + ' . "3" . ' minutes')); $parent->setAndSave('auction_end_date', $parentdateadded); }); Parent template= auction-page Child template=auction-bid End date field = auction_end_date The code is working but i don´t know how to do with the date. 3 min > enddate.
  11. @gebeer That worked!! Thanks alot!!!
  12. Im trying to redirect a logged in user back to his own user page if he tries to access another member page, but i can´t get it to work. It will redirect back to the correct url but then i get browser error? "The page redirects incorrectly, Firefox has detected that the server is redirecting the request for this location in a way that prevents completion." <?php $userloggedinname = $user->name; $pagename = $page->name; { $session->redirect( "{$pages->get(1)->httpUrl}medlemmar/" . $userloggedinname ); } ?> also i tried this but same result $userloggedinname = $user->name; $pagename = $page->name; if (!$userloggedinname === $pagename) { $session->redirect("{$pages->get('/')->url}medlemmar/{$userloggedinname}"); } I have created another user template similar to this post https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users So my users is now under Home/Members/MemberX I´m on localhost. Also i if a user is logged in, the user can edit other users aswell ? so my goal is also to hide/restrict users to edit or access the processwire front end user edit page. I am building a separate edit on the front end user custom page that also is the memberX page, Home/Members/MemberX. Any suggestions? Please help..
  13. @gebeer Thanks for the detailed reply.. very appreciated. ? This is my current code. The dropdown with all its option is now visible but when i submit the form the value is not selected. (County) is the option field.. any clues? <?php $fu = $modules->get( 'FrontendUser' ); $redirectDestination = htmlentities( $_SERVER[ 'REQUEST_URI' ] ); $firstname = $modules->get( 'InputfieldText' ); $firstname->label = $this->_( $fields->firstname->$label ); $firstname->attr( 'id+name', 'firstname' ); $firstname->required = 0; $firstname->fhSanitizer = 'text'; $firstname->addHookAfter( 'processInput', function ( $event ) { $field = $event->object; $mySanitizedCustomInput = wire('fu')->form->fhValue( $field->name ); wire('fu')->userObj->firstname = $mySanitizedCustomInput; }); $location = $modules->get( 'InputfieldText' ); $location->label = $this->_( $fields->location->$label ); $location->attr( 'id+name', 'location' ); $location->required = 0; $location->fhSanitizer = 'text'; $location->addHookAfter( 'processInput', function ( $event ) { $field = $event->object; $mySanitizedCustomInput = wire('fu')->form->fhValue( $field->name ); wire('fu')->userObj->location = $mySanitizedCustomInput; }); /* Option field */ $form = $modules->get('InputfieldForm'); $county = $modules->get('InputfieldSelect'); $county->attr('id+name', 'county'); $county->label = $this->_($fields->county->label); $county->required = 1; $county->attr('required', 'required'); $optionsArray = $pages->findRaw('template=county', 'title'); $county->setOptions($optionsArray); $form->add($county); $form->render(); $county->fhSanitizer = 'text'; $county->addHookAfter( 'processInput', function ( $event ) { $field = $event->object; $mySanitizedCustomInput = wire('fu')->form->fhValue( $field->name ); wire('fu')->userObj->county = $mySanitizedCustomInput; }); $fu->addHookBefore('save', function($event) { $form = wire('fu')->form; $user = wire('fu')->userObj; $user->addRole('member'); $user->parent = "/medlemmar"; $user->template = "member-page"; }); $fu->register( array( 'username', 'email', 'password', $firstname, $county) ); $redirectDestination = $pages->get( '/logga-in' )->url; $fu->process( $redirectDestination ); echo $fu->render(); ?>
  14. $optionsArray = $pages->findRaw('template=location', 'title'); $location->setOptions($optionsArray); $location = $modules->get( 'InputfieldText' ); $location->label = $this->_( $fields->location->$label ); $location->attr( 'id+name', 'location' ); $location->required = 1; $location->fhSanitizer = 'text'; $location->addHookAfter( 'processInput', function ( $event ) { $field = $event->object; $mySanitizedCustomInput = wire('fu')->form->fhValue( $field->name ); wire('fu')->userObj->location = $mySanitizedCustomInput; }); Thanks for the reply.. I´m a beginner with php so don´t know how to insert this.. ? Getting Fatal Error: Uncaught Error: Call to a member function setOptions()
  15. How to you add a page reference dropdown to the form? I´ve got this $county = $modules->get( 'InputfieldSelect' ); $county->label = $this->_( $fields->county->$label ); $county->attr( 'id+name', 'county' ); $county->required = 1; $county->fhSanitizer = 'text'; $county->addHookAfter( 'processInput', function ( $event ) { $field = $event->object; $mySanitizedCustomInput = wire('fu')->form->fhValue( $field->name ); wire('fu')->userObj->county = $mySanitizedCustomInput; });
  16. Im building a site where members can hopefullly sign up, login, and have a front end user page that that they can edit and also post new for example entries/pages to an auction for example. I have created an alternative user page based on this post. https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users So my new template is "member" with the parent "members". This is where all my new user will end up but they will also have a parent under the regular users page. I have created a form from "frontedituser" module. So now the users can signup and login from localhost/userarea/logga-in. But the problem is that once the user is logged in they also can access other users pages with the parent home/medlemmar/.. I want only the logged in user to be able to visit the users profile page.. home/medlemmar/testuser1 for example. I have also tried to get you an overview of everything in the attached image. If you have any clues or have some other/better solutions please let me know.. /thanks.
  17. $wire->addHookAfter('Pages::added(template=booking)', function(HookEvent $event) { $page = $event->arguments(0); $selectable_pages = $page->getInputfield('booking_group')->getSelectablePages($page); $current_group = $selectable_pages->find("template=booking_price, parent.booking_current_group=1"); $first = $current_group->eq(0); $second = $current_group->eq(1); if ($page->booking_numberofpeople->id == 1 ) { $page->setAndSave('booking_group', $first); } else if ($page->booking_numberofpeople->id !== 1 ) { $page->setAndSave('booking_group', $second); } }); I have this code in ready.php It works when i change to (Pages::save) but when (Pages::added) it doesn´t work? It sets the value to $second regardless.. Any clues? booking_group = page reference field booking_numberofpeople = select option field the options in booking_numberofpeople is 1=1 2=2 3=3 4=4 5=5 Also i have set the required value to 1. The pages are created from the module (Simple Contact Form). Please help!!
  18. I can´t even install the module.. ?? Any clues? Parse Error: syntax error, unexpected 'Validator' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) (line 20 of E:\Wamp\www\Website\site\modules\FrontendForms\FrontendForms.module)
  19. @zoeck Yes but the module only let you restrict branches not give rights to edit pages. The problem is that the Edit button not showing up.. Maybe its because its a user-page and not a regular one. I don´t know how to solve this.. I have this code in my config.php $config->userTemplateIDs = array(3, 53); $config->usersPageIDs = array(29, 1047);
  20. Ok thanks i will have a look. But the problem is that the edit button don´t show up..
  21. @zoeck My main goal is to have users, register > log in to their account > edit their own profile page > add children. so based on this post https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users i clone the user template and renamed it member. So now i can create a new user with another template and also change parent. And also the user now have a page under home/members/. The subpage under the "newuser" > newsubpage shows the edit button but not newuser.
  22. @zoeck thanks for the fast reply. I have really tried everything.. permissions etc.. can´t get it to work.. also i have tried to modify the module file but no luck. <?=$page->feel();?> This is how i outfut the button from the module. Have you also changed the guest role? Do you have a screenshot with your settings? The page is an user page renamed "member" with template name "member" that i have cloned and the parent is Home/Members/ and also listed in the users page. https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users
  23. Has anyone any clue how to enable the (Edit) button for non Superusers? I really need to solve this.. please help!!
×
×
  • Create New...