Jump to content

webhoes

Members
  • Posts

    233
  • Joined

  • Last visited

Everything posted by webhoes

  1. I did. But for them to change their own page they need page-edit rights. When they see the page tree that also means they can see and edit pages of other users. Also hooking into the page output is not good practice (read here on the forum).
  2. thanks @Macrura, that is not what I am looking right now. However if this site works and might want to add more types of animals all with specific fields, then this would come in handy.
  3. User are not allowed to the admin because they can see privat information of others. The classifieds part is an extra feature to the site. That is why all pages are done via the api and they can only see their own content. I have created seconday admin for that. It looks like this. All entered classified of that user are placed under the submit form for a new classified. All is working except editing a classified and adding an image. That is why I am thinking a editing the classified through another template. I tried putting all entered classifieds in a forms, but could not get this working with images and making sure the right page gets updated.
  4. I have a page my classifieds that allows for adding a new classified. All is done with API because user are not allowed acces to the admin. User also don't have page edit rights. The new classified has template classified and is a child of classifieds. These are visible to the frontend. Can use another template like classified edit to let user edit their classified. I was thinking about a edit button/link on the my classifieds page per classified who are presented there in a list. Can this be done? And if so, how?
  5. A user needs to use the datepicker to fill in a date and check 2 checkboxes. On submit a new page will be generated. Everything works except getting wich checkboxes are checked and also set them checked on the page. How do I solve this? <?php if (isset($_POST['submit_mating'])) { $date = $input->post->mating; $date = $sanitizer->date($date); $title = date("Y-m-d-g-i", $date); $p = new Page(); $p->setOutputFormatting(false); $p->template = 'feeding'; // example template $p->parent = 1089; //$user->id; // example parent $p->name = $user->name . "-mating-" . $date; // example name $p->title = date("dd-mm-YYYY-g-i",$date); $matingTurtles = new PageArray(); foreach ($turtles as $check) { if($input->post->mating == $selected) $matingTurtles->add($check->id);//how to check if the box is checked? } $p->turtles_mating = $matingTurtles; $p->save(); $p->title->setLanguageValue('default', $title); //default $p->title->setLanguageValue('de', $title); //german $p->title->setLanguageValue('nl', $title); //dutch //echo var_dump($p); $p->save(); $session->redirect($page->url); } else { echo "Click the datepicker to set the date of mating"; $options = ''; foreach ($turtles as $mating){ $selected = $mating->id == $input->whitelist->mating ? " selected='selected' " : ''; $options .= '<label><input$selected class="uk-checkbox" name="mating[]" type="checkbox" id="' . $mating->id . '">' . $mating->title . '</label>'; } echo '<form role="form" method="post" action="" > <div class="form-group"> <div class="InputfieldContent uk-form-controls"> <input id="mating" class="uk-input uk-form-width-medium uk-datepicker" name="mating" type="text" maxlength="2048" size="25" data-uk-datepicker="{format:\'DD-MM-YYYY\'}"></div> </div> <div class="uk-fieldset"> <div class="uk-margin uk-grid-small uk-child-width-auto uk-grid"> ' . $options . '</div></div> <button type="submit" name="submit_mating" class="btn btn-default">Submit</button> </form>'; } ?>
  6. got it figured out. A faulty reference to uikit v2 was messings things up.
  7. I have been searching whole day and had all topics on this forum. I can't get a datepicker working on the frontend. The frontend is build with uikit (same as admin). I have this code at the moment. The field gets filled but no datepicker. I also have this in <head> <script src="/wire/modules/Jquery/JqueryCore/JqueryCore.js"></script> <script src="/wire/modules/Jquery/JqueryUI/JqueryUI.js"></script> <script type='text/javascript' src='/wire/modules/Inputfield/InputfieldDatetime/InputfieldDatetime.min.js?v=106-1529786878'></script> <script src="/wire/modules/Inputfield/InputfieldDatetime/timepicker/jquery-ui-timepicker-addon.min.js"></script> <link rel="stylesheet" href="/wire/modules/Inputfield/InputfieldDatetime/timepicker/jquery-ui-timepicker-addon.min.css"/> <?php $out = ''; // create a new form field (also field wrapper) $form = $modules->get("InputfieldForm"); $form->action = "./"; $form->method = "post"; $form->attr("id+name", 'subscribe-form'); $form->attr("class", "InputfieldContent uk-form-controls"); //$f = $modules->InputfieldDatetime; $f = $modules->get('InputfieldDatetime'); $f->label = "Date"; $f->attr("name+id", "date"); $f->attr("class", "FieldtypeDatetime uk-input hasDatepicker initDatepicker InputfieldDatetimeDatepicker "); $f->datepicker = 3; $f->dateInputFormat = "Y-m-d"; $f->timeInputFormat = "H:i:s"; $f->attr("value", time());; $form->append($f); // oh a submit button! $submit = $modules->get("InputfieldSubmit"); $submit->attr("value", "Add"); $submit->attr("id+name", "submit_mating"); $form->append($submit); // form was submitted so we process the form if ($input->post->submit_mating) { // user submitted the form, process it and check for errors $form->processInput($input->post); if ($form->getErrors()) { // the form is processed and populated // but contains errors $out .= $form->render(); } else { $date = $form->get("date")->value; $date = $sanitizer->date($date); $title = date("Y-m-d-g-i", $date); $p = new Page(); $p->setOutputFormatting(false); $p->template = 'feeding'; // example template $p->parent = 1089; //$user->id; // example parent $p->name = $user->name . "-mating-" . $date; // example name $p->title = $title; $p->save(); $p->title->setLanguageValue('default', $title); //default $p->title->setLanguageValue('de', $title); //german $p->title->setLanguageValue('nl', $title); //dutch //echo var_dump($p); $p->save(); $session->redirect($page->url); } } else { // render out form without processing $out .= $form->render(); } echo $out; What am I missing?
  8. This one is really nice... https://gist.github.com/somatonic/5011926 Doesn't work with repeater on my test site. If that would work too it would be awesome and make sooo much easier.
  9. Got it... with a lot of trail and error. $this->user. $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->hasField == 'turtles_fed') { $event->return = $event->pages->find("template=turtle, created_users_id=$this->user"); } });
  10. thanks @Soma. I also tried that with several version like this. No error but also no output. Namespace Processwire is added at the top of ready.php so I assumed $user would be useable here... $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->hasField == 'turtles_fed') { $event->return = $event->pages->find('template=turtle, created_users_id={$user}'); } });
  11. Hello, I have the following selector on a pagereference field. It returns no output (an echo of the same selector returns output). If I replace $suser with 41 it does work. I also tried to do this via ready.php. Also no output. What is wrong?
  12. Hello, I am trying to make a hook in ready.php. A user can create a new page wich will be a child of his user template. I want to check the amout of children before adding a new page. If the count is more than 3 do a redirect. $wire->addHookBefore('Pages::add', function(HookEvent $event) { // Get the object the event occurred on, if needed $pages = $event->object; // Get values of arguments sent to hook (and optionally modify them) $template = $event->arguments(0); $parent = $event->arguments(1); $name = $event->arguments(2); $values = $event->arguments(3); /* Your code here, perhaps modifying arguments */ $userCount = wire('pages')->get($this->user)->children->count(); if($template == 'animal' && $userCount > 3) $session->redirect('/subscribe/'); //also implement check of user role user = max 3, paid-user is unlimited // Populate back arguments (if you have modified them) $event->arguments(0, $template); $event->arguments(1, $parent); $event->arguments(2, $name); $event->arguments(3, $values); }); I have this code, but it seems not to do anything.
  13. Ahh... figured it out. Had some code in ready.php that prevented the initial show. ?
  14. @Robin S, thanks. Your code works excellent but it won't save the selected states. After I save all the options (states) are gone, also the selected ones. I have selected Select Multiple as input field type. If I want to use something like this: return $page->country->children(); Where would I put that?
  15. Hello, I have 2 fields in on a template. field 1 is country and field 2 is state. states are children of a country. Now if I select one ore more countries I would like to see the children of the selected countries in the field state (select multiple). I tried something in ready.php but I can't get this to work. $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->hasField == 'state') { $event->return = $event->pages->find('template=country')->children; } }); It this the way to do it, or is another way better? I don't mind to have to save the page first before I can see the children of the selected countries.
  16. Hello, I am working of a site for a sport organisation. All affiliated gyms can edit their profile. I have used the advaced mode so that if you create a new page under location the gym can login and edit their profile. i also want that they can add instructors as child of their profile and also are able to edit those instructors. I can not get passed the able to edit all subpaged or none. How should this be done? Or is this not possible?
  17. I now have 100% for PWA in lighthouse on all pages. I forgot the url to the pwabuilder-sw.js in _main.php. Still not sure how it all works but the tips above do help. thanks.
  18. Hello @psy, I got it working for the home page, but not for the pages down the tree. I tried putting the full url everywhere I think it should be... Is it possible to show full examples of the files?
  19. BTW, if you use width() you get a cached image with name-200-0.jp. That means it has no height and therefor is not really an image. Using size() gets a correct image.
  20. I don't understand them either. Was just working based of the sample's. I googled and it does not seem to matter if you use one block or more. I did quick and dirty fix... looking like this. Note I always have atleast 2 schemes and therefor kinda hardcoded the brackets. There is also a ',' between 2 schemes. <?php $jsonld = $modules->get('MarkupJsonLDSchema'); ?> <script type="application/ld+json">[ <?php switch ($page->template) { case 'product': $options = array( 'logo' => $pages->get(1)->logo->size(200, 200), 'image' => $page->images->first()->size(200, 200) ); echo $jsonld->render('Product', $options) . ","; echo $jsonld->render('BreadcrumbList'); break; case 'categorieen': $options_c = array( 'logo' => $pages->get(1)->logo->size(200, 200), 'description' => $page->summary, 'image' => $pages->get(1092)->images->first()->size(200, 200) ); echo $jsonld->render('Product', $options_c) . ","; echo $jsonld->render('BreadcrumbList'); break; default: $options = array( 'logo' => $pages->get(1)->logo->size(200, 200), 'image' => $page->images->first()->size(200, 200) ); echo $jsonld->render('WebPage', $options) . ","; echo $jsonld->render('LocalBusiness') . ","; echo $jsonld->render('BreadcrumbList'); break; } ?> ]</script>
  21. Hello Psy, I currently have this and it looks like images are outputted I must have made a stupid mistake somewhere. On another site I got it working in one time. $jsonld = $modules->get('MarkupJsonLDSchema'); ?> <script type="application/ld+json"> <?php switch ($page->template) { case 'product': $options = array( 'logo' => $pages->get(1)->logo->size(200, 200), 'image' => $page->images->first()->size(200, 200) ); echo $jsonld->render('Product', $options); // echo $jsonld->render('BreadcrumbList'); break; case 'categorieen': $options_c = array( 'logo' => $pages->get(1)->logo->size(200, 200), 'description' => $page->summary, 'image' => $pages->get(1092)->images->first()->size(200, 200) ); echo $jsonld->render('Product', $options_c); echo $jsonld->render('BreadcrumbList'); break; default: $options = array( 'logo' => $pages->get(1)->logo->size(200, 200), 'image' => $page->images->first()->size(200, 200) ); echo $jsonld->render('WebPage', $options); echo $jsonld->render('LocalBusiness'); echo $jsonld->render('BreadcrumbList'); break; } ?> </script>
  22. I keep getting undefined index 'image' Tried several ways to get rid of this error. What is recommended/correct way to add the code for the images in the template?
  23. I have been working with docker the last few days and in the end created a simple but flexible docker setup for local development. You can find the repository here https://gitlab.com/webhoes/pw-docker.git This is based on the work of undernewmanagement. The difference is that in that repository you had to put your files in /src. Side effect is that all projects in PHPstorm are now referenced as src... So I changed it so that you can put your files in the root. Therefor the directory of your project is referenced in PHPstorm. I also changed the docker-compose file and added a default config-dev.php. As long as there is a config-dev.php is will be used instead of config.php. This means you don't need to change you config.php on a local setup. Now it wil use config-dev.php. Ofcourse never upload config-dev.php to production. Add it to your .gitignore. There are 2 flavors of using this repository: 1 with a new install 2 with an existing site 1 With a new install git clone https://gitlab.com/webhoes/pw-docker.git <new project folder> git remote remove origin git remote add origin <your own git repository> Make sure that Docker/db/ is empty. copy the proceswire files in the root. remove folder and file /site/config-dev.phpp from a terminal make sure you are in your project folder and type docker-compose up. Go through the installer. The database settings are in the docker-compose file. Note: database location is mysql (not localhost) You now have a working local processwire on localhost 2 use a working copy from development For this setup you need the database backup module by @ryan (ProcessDatabaseBackups). Make sure you only have one file in the default backups/database directory. git clone https://gitlab.com/webhoes/pw-docker.git <new project folder> git remote remove origin git remote add origin <your own git repository> Make sure that Docker/db/ is empty. copy the proceswire files of your existing site in the root. The config-dev.php will take care of the connection to your database. the database will be filled with the sql file (see steps) disclaimer: I am not an expert of docker and stuff or processwire - just figured this out the last few days to make (my) life easier. If you find any mistakes or security issues, let me know.
  24. I have implemented this module. It works great but it prints the page as it was when it got created (cached). On this page some moderations are done through editable fields. After that is needs to be printed as a pdf. Now I need to save the page before I can print. How can I either save the page before printing or don't use a cached version for printing?
  25. Got it! $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->hasField == 'tests') { $currentPage = $event->arguments('page'); //current test page $rootParent = $currentPage->parent->parent; //project page // $rootParent = $currentPage->rootParent; $testParent = $rootParent->child('template=user-stories'); $tests = $testParent->children('template=user-story'); //all tests of that project $event->return = $event->pages->find("id=$tests"); } });
×
×
  • Create New...