Jump to content

ngrmm

Members
  • Posts

    414
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by ngrmm

  1. @JonI would recommend to rule out the sources of error. Create another page with the same template and test it there. Create another template with the exact same code as your home template. Try different browsers (I know it sounds silly), but you never know.
  2. @Jon Do you have any Errors or warning in the browser console? Or any hints in the PW Logs?
  3. @canwild I think the way to go is to have multiple selectors // selectors $selector_title = "title%=$q"; $selector_summary = "summary%=$q"; // do the search // make matches unique $matches_summary->removeItems($matches_title); $matches_title->import($matches_summary);
  4. @Boost how are those H2 headings created? Through a textarea field or through custom textfield inside a repeater?
  5. @joe_g Please check if you have any typing errors. I also have a repeater matrix and it works for me. foreach ($wire->languages as $lang) { $page->set("status$lang", 1); } $page->save(); 1. You could check if status$lang is 1 2. If there is no translation, PW automatically views the default content. But you could also check for translations an do a redirect
  6. I'm not an expert 🙂 but this sounds good. And another issue I had was this: I generate a page with the values of the submitted form. The filenames get sanitized after submitting. An uploaded Image.jpg is saved as image.jpg. So in order to save add the files uploaded to a page, you have to sanitize them. Because the values-array has the original filenames I did it this way: if($form->isValid()){ $p = new Page(); // create new page object $p->template = 'template_name'; // set template $p->parent = $pages->get(1111); // set the parent $p->name = $sanitizer->pageName($form->getValue('surname'), true); // give it a name used in the url for the page $p->title = $form->getValue('textField'); // set page title $p->save(); $p->addStatus('unpublished'); foreach($form->getValue('fileuploads') as $fileItem) { // // sanitizing // $sanitizer->fileName() did not work for me :( // $sFile = $sanitizer->pageName($fileItem, true); $p->images->add("https://domain.com/site/assets/files/{$page->id}/{$sFile}"); } $p->save(); } Maybe it be an option in the future to output the url of the image inside the values fieldarray?
  7. Thanks @Juergen it worked! My other question is, if there is an option for unique filenames. I would like to use the form for submission. If someone uploads a file with the image.jpg, this file would be overwritten if someone else uploads another image with the same filename (image.jpg). Maybe something like this would help? $base = $pathinfo["filename"]; $filename = $base . "." . $pathinfo["extension"]; $destination = __DIR__ . "/uploads/" . $filename; $i = 1; while(file_exists($destination)) { $filename = $base . "($i)." . $pathinfo["extension"]; $destination = __DIR__ . "/uploads/" . $filename; $i++; }
  8. @Juergen thanks for the module. I tried this: $form = new \FrontendForms\Form('myForm'); … $file1 = new \FrontendForms\InputFile('fileupload1'); $file1->setLabel('Multiple files upload'); $file1->setMultiple(true); $file1->setRule('allowedFileSize', '100000'); $file1->setRule('allowedFileExt', ['jpg','jpeg','png']); $form->add($file1); $button = new \FrontendForms\Button('submit'); $button->setAttribute('value', 'Send'); $form->add($button); if($form->isValid()){ print_r($form->getValues()); } echo $form->render(); But it renders this for the fileupload: <form method="post" action="/path/" id="myForm" name="myForm-1705439668" novalidate="" autocomplete="off" class="form" enctype="multipart/form-data"> … <div class="fieldwrapper" id="myForm-fileupload1-fieldwrapper"> <label class="label" for="myForm-fileupload1">Multiple files upload</label> <div class="inputwrapper" id="myForm-fileupload1-inputwrapper"> <input id="myForm-fileupload1" name="myForm-fileupload1[]" type="file" class="input input-file" multiple="" onchange="showClearLink(event)" accept=".jpg,.jpeg,.png" max-size="2048"> <div id="myForm-fileupload1-clearlink-wrapper" class="clear-link-wrapper" style="display:none;"> <a id="myForm-fileupload1-clear" href="#" class="clear-link" onclick="event.preventDefault();clearInputfield(this); return false;">Clear the input field</a> </div> </div> <p class="notes">Please do not upload files larger than 2,0 kB<br>Allowed file types: jpg, jpeg, png</p> </div> … </form> Do I have set the attribute allowedFileSize in another way, so that it allows larger files?
  9. Could you tell a little bit more? Any Errors? At which step are you stuck?
  10. Just FYI for those pages you would need to loop through $championship->winner_name. So you better loop always
  11. What is the output for this: echo gettype($championship->winner_name);
  12. @da² yes, but user IDs have normally only two digits
  13. I'm curious and would like to know how the Drupal way handles the problem of layout shifts if images and image dimensions are not available on load?
  14. Then maybe winner_name is a multipagefield and you try this: $playerChampionships = $pages->find("template=Championship_results, winner_home_club={$page->id}"); foreach($playerChampionships as $championship) { echo "<li><a href='$championship->url'> $championship->title - {$championship->winner_name->first->title}</a></li>"; }
  15. as @da² mentioned you missed adding the "->title" $playerChampionships = $pages->find("template=Championship_results, winner_home_club={$page->id}"); foreach($playerChampionships as $championship) { echo "<li><a href='$championship->url'> $championship->title - {$championship->winner_name->title}</a></li>"; }
  16. @JerryDi could you paste in here the latest version of your code.
  17. @neophron you could to set your settings here Setup > Templates > your-template > Advanced > List of fields to display in the admin Page List And maybe you look into a css solution to hide it for non-superusers. But I don't know if that is possible
  18. @neophron why is code bad? Do you get an error or any output?
  19. @da² the PageReference field needs a pagearray. Try this $classPageIds = PageArray([16988]); $page->carClasses = $classPageIds; echo $page->carClasses; // should output 16988 Be aware that this change will not be saved!
  20. @JerryDi you can access fields and variables of your page (in this case champrionship pages) echo "<a href='$championship->url'>$championship->title</a>; have a look here: https://processwire.com/api/ref/page/
  21. try this $playerChampionships = $pages->find("template=championship_results, winner_name=$page->id"); // or $playerChampionships = $pages->find("template=championship_results, winner_name={$page->id}");
  22. I guess, it's this typo winner_name=§page->id' Should be winner_name=$page->id' You could also try winner_name=$page'
×
×
  • Create New...