Jump to content

joeck

Members
  • Posts

    37
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

joeck's Achievements

Jr. Member

Jr. Member (3/6)

5

Reputation

  1. Turns out the pdf file was actually broken and the code was working just fine... For anyone else who might end up here, this is the code I used (in Tracy Debugger console): // $page->files targets the field on the page with name "file". Change name with your own $directory = $directory = $config->paths->assets . "files/$page->id/"; //path to asset folder of current page $page->of(false); foreach (scandir($directory) as $file) { // loop through all files in directory if ($file !== '.' && $file !== '..') { if ($page->files->has($file)) { continue;} //skip if file is already in field $page->files->append($file); //append file to field $files->rename($directory . $file, $directory . $page->files->last()->name); //rename original file to name in field after sanitizer } } $page->save(); $page->of(true); thanks @MarkE for your assistance
  2. Yes absolutely! I am using Tracy Debuggers console to try the script but I wasn't sure if it is at all possible what I'm trying to achieve and if my assumption was correct. But I'll try some more debugging.
  3. yes the echo is showing the file name (handout.pdf). one issue I see is that the file name in the PW "file" field is all lowercase however the name of the file is not. I tried renaming the file to the newly added entry in the array of the "file" field but that didn't work either. echo rename($directory . '/' . $file,$directory . '/' . $page->file->last()->name); I then saw the entry in the "file" field in PW and it always showed 1kB as the size. When clicking on the name to open the document in a new tab the path would be correct and a loading animation appears but the file is not shown. Not sure why.
  4. Hi, I'm facing the issue where a customer has only 1GB of RAM on its server available (and doesn't want to upgrade). They have a few large files (videos) that they want on the website but when uploading via the processwire backend the progress bar gets stock after some time (assuming because it ran out of RAM). I see that files are saved to site/assets/files/1048 and 1048 being the page id. I tried uploading the files via ftp (to avoid the shortage of RAM) to the same folder but the images don't appear in the files field. I'm assuming the files field is just an array with the file names that are then searched in site/assets/files/1048 . Is there a way where I can have the field look for other files in that folder and have it automatically added to the array so it appears in the files field of the page? My attempt didn't work and I didn't quite understand why: $directory = "../../files/1048"; // files uploaded here via ftp $page->of(false); foreach (scandir($directory) as $file) { //go through all files if ($file !== '.' && $file !== '..') { echo $file; $page->file->add($file); } } $page->save(); $page->of(true);
  5. Hi, I'm facing the issue where i have a repeater field with a multi language textarea (german & english, german beeing default). In german more blocks should be displayed as in english. The textarea field is configured as inherit default language if blank (I don't want to change this since it is the wanted behaviour for all other pages...). Now I want to access the unformatted value of the textarea field in the repeater and only show it if it is not empty. Something like this: $body = ""; $page->of(false); foreach($page->blocks as $block){ //blocks is repeater field, each block has title and textarea if ($block->textarea->getLanguageValue($user->language)){ $body .= <<<EOD <div> <div class='uk-card uk-card-default uk-card-body'> <h3 class='uk-card-title'>$block->title</h3> $block->textarea </div> </div> EOD; } } $page->of(true); print $body; However this doesn't work: Call to a member function getLanguageValue() on string. I also tried the other syntax for getLanguageValue: $page->getLanguageValue($language, $field) But I didn't manage to get a unique name of the textarea field in the repeater. I looked into the API of FieltypeRepeater but couldn't find anyhting that fixed my issue. Any ideas?
  6. I am struggling with an issue where my language switcher with flags sometimes doesn't show the flag. It works in the default language (german): but when the site is in english the german flag is not shown (path to image is not found): I don't really understand why it works if the site is shown in german but not in english.. Code for language switcher: // remember what language is set to $savedLanguage = $user->language; $languageImage = $savedLanguage->image->url; echo "<li><a href='#' class='dropdown-toggle' data-toggle='dropdown'><img src='$languageImage' alt='$savedLanguage->title'> <span uk-icon='icon: chevron-down'></span></a>"; echo "<div class='uk-navbar-dropdown'>"; echo " <ul class='uk-nav uk-navbar-dropdown-nav'>"; foreach($languages as $language) { //go through all languages // if user is already viewing the page in this language, skip it if($language->id == $savedLanguage->id) continue; // if this page isn't viewable (active) for the language, display root page $viewable = true; if(!$page->viewable($language)) $viewable = false; // set the user's language, so that the $page->url and any other // fields we access from it will be reflective of the $language $user->language = $language; // output a link to this page in the other language $path = $language->image->url; $pagePath = $page->url; if(!$viewable) $pagePath = $pages->get(1)->url; echo "<li><a class='uk-text-medium' href='$pagePath' alt='$language->title'><img src='$path' alt='$language->title flag'> $language->title</a></li>"; } echo " </ul>"; echo "</div>"; echo "</li>"; // restore the original language setting $user->language = $savedLanguage; Language template: image field is configured as automatic (array if multiple) in language page (both german and english) only one image is saved html output of language switcher dropwon (image couldn't be loaded): html output when image can be displayed:
  7. I'm having the same issue. Is the solution from @DaveP still the recommended way? Edit: it is working for me like Tom (OP) posted, I was missing a comma in the selector.
  8. update: If I remove the pageSelect field from the registration form the error no longer shows but the registration process is still not working (not sure why) The problem seems to be on the registration form only. Profile edit works just fine with the pageSelect field.
  9. I removed the hook but error message still shows. I don't have any setup with nginx or other framework (apart from jQuery but I assume that is not considered weird, nor a framework) Tracy is on version 4.19.13 and apparently up-to-date. No recent tracy logs I haven't found any serialize() in my code and I'm pretty sure I didn't use it since this is the first time I hear about this function, let alone knowing what it does.
  10. yes I have a hook in ready.php that should only apply on a different PageSelect field called team_owner: $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->hasField == 'team_owner' && !$this->wire('user')->isSuperUser()) { $permissions = $this->wire('user')->getPermissions(); $authorized_pages = new PageArray(); foreach($permissions as $permission){ if (!$permission->team_owner) { continue; } //skip permissions without team foreach($event->pages->find("template=team") as $page){ if ($page === $permission->team_owner){ $authorized_pages->add($page); } } } $event->return = $authorized_pages; } }); I think this is working as desired, since I see all the options in the dropdown of the registration form field (called team_reference) and if the hook would execute I shouldn't see all the fields in the dropdown. these modules are installled: AdminOnSteroids FieldtypeColorPicker InputfieldCKEditor LoginRegister PageEditFieldPermission TracyDebugger fullcalender.io (not a processwire module)
  11. oh boy, turns out that my css library materialize.css sets all the select inputs to display: none 💩 The select has all the desired data simply not visible due to css... But now i get another error when trying to register with a new account: Fatal error: Uncaught Exception: Serialization of 'Closure' is not allowed in [no active file]:0 Stack trace: #0 {main} thrown in [no active file] on line 0 Again no logs in Processwire admin or browser console. The registration email actually gets sent out but when you click the link you receive the error message: Unable to complete confirmation, please re-register and try again.
  12. First of all, thank you so much for your reply @wbmnfktr I guess this means I broke something... I'll try on a fresh installation. What confuses me is that I don't get any errror, warnings or notices in any logs
  13. Hi there, I'm trying to have a PageReference (single) Select field in the registration form and profile page of the user. I'm trying to achieve this with the module LoginRegister: https://modules.processwire.com/modules/login-register/ I simply added the desired field (team) to the user template and then added the field to the field selection in the module configuration. but the select doesn't render properly (see image attached). I'm assuming the reason is because the PageSelect field isn't text-based: I tried to add the InputFieldPage field to the form manually but only got the error that the field needs to be configured. Even with this blog or this one: I wasn't able to get the Select displaying correctly. This is a very strange and new feeling for me: searching a functionality in Processwire for more than a day and not being able to find a very easy and smart solution. Can someone point me into the right direction?
  14. Hi everyone, I'm trying to have a page reference field on the registration and profile edit page. I know that only 'standard' fields are supported but I'm not sure whether the page reference field is 'standard' or not. Currently it is not rendered correctly, I don't see the select dropdown to select a page (see image) Has anyone done this before? Or can point me into the right direction? I'm trying to add the InputfieldPage manually but I wasn't able to find API for a page reference field. Thanks, Joeck
×
×
  • Create New...