Jump to content

joeck

Members
  • Posts

    37
  • Joined

  • Last visited

Everything posted by joeck

  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
  15. I never thought about that and the website is actually hosted on a Windows (IIS) server which might be an issue. However, the CRLF/LF doesn't seem to change any of the output. Actually, I just tested the exact same code on a UNIX apache server and there it is formatted as expected. So there must be something related to the IIS server. I'll contact the hosting support. Thanks a lot for the link, looks very very interesting, I'll try this for my next project. I was already amazed by the flexibility of Processwire and I didn't even know about this way. This just puts flexibility on another level. Processwire never fails to impress me. Thanks a lot for your help @szabesz !
  16. Hi there, I'm currently using the direct output method for my templates where the prependTemplateFile is my header & navigation and my appendTemplateFile is the footer of the website. In addition to that, I include other commonly shared files into the templates via "include_once('file.php')". The navigation file that gets appended to every template: <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation"> <div class="container"> <!-- Brand and toggle get grouped for better mobile display --> <div class="navbar-header sc-content"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="<?php echo $pages->get(1)->url; ?>"><img src="<?php echo $config->urls->templates?>/images/titlebar.png"></a> <!-- link zu Startseite (id=1) mit bild f�r navigationsleiste --> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse sc-content" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav navbar-right"> <!-- In Mobile ansicht (xs) anzeigen wegen Anordnung. --> <li class="visible-xs"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"><img src="<?php echo $user->language->image->first->url; ?>" alt="<?php echo $user->language->title; ?>"> <b class="caret"></b></a> <ul class="dropdown-menu"> <?php // remember what language is set to $savedLanguage = $user->language; foreach($languages as $language) { //alle sprachen durchgehen // 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, skip it if(!$page->viewable($language)) continue; // 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->first->url; echo "<li><a href='$page->url' alt='$language->title'><img src='$path' alt='Flagge von Sprache'> $language->title</a></li>"; } // restore the original language setting $user->language = $savedLanguage; ?> </ul> </li> <!-- Telefon mit link zu kontakt in mobile ansicht verborgen --> <li class="hidden-xs"> <a href="<?php echo $pages->get(1022)->url; ?>">Tel: xxxxxxxx</a> </li> <!-- Telefon mit link um anzurufen in mobile ansicht sichtbar --> <li class="visible-xs"> <a href="tel:+41-44-233-30-30">Tel: xxxxxxxx</a> </li> <li class="visible-xs"> <a href="<?php echo $pages->get(1)->url; ?>"> <span class='glyphicon <?php echo $pages->get(1)->glyphicon; ?>' aria-hidden='true'></span> <?php echo $pages->get(1)->title; ?> </a> </li> <!-- Ausgabe aller Seiten f�r Mobileansicht (visible-xs) --> <?php foreach ($pages->get(1)->children as $navitem) { echo "<li class='visible-xs'> <a href='$navitem->url'> <span class='glyphicon $navitem->glyphicon' aria-hidden='true'></span> $navitem->title </a> </li>"; } ?> </ul> <!-- navbar-nav --> </div> <!-- /.navbar-collapse --> </div> <!-- /.container --> </nav> The template file and the appended footer file are very similar in terms of format and coding style. Now the final output/source of the website is not formatted at all, not even all the linebreaks. I tried to include the formats in the echos and use as much HTML as possible (like thomas descirbed above) but I feel like the prepend/append and included files mess up/ignore the format: <!DOCTYPE html><html lang="de"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1"><meta http-equiv="content-type" content="text/html;charset=ISO-8859-1" /><meta http-equiv="content-language" content="de" /><link rel="stylesheet" href="/site/assets/aiom/css_fcf3e08b16c1fb16f6f309285c212e13.css"><link rel="shortcut icon" type="image/png" href="/site/assets/files/1062/favicon.png"/><!--[if lt IE 9]><script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script><script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script><![endif]--> [..] </head><body><nav class="navbar navbar-inverse navbar-fixed-top" role="navigation"><div class="container"><div class="navbar-header sc-content"><button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button><a class="navbar-brand" href="/"><img src="/site/templates//images/titlebar.png"></a></div><div class="collapse navbar-collapse sc-content" id="bs-example-navbar-collapse-1"><ul class="nav navbar-nav navbar-right"><li class="visible-xs"><a href="#" class="dropdown-toggle" data-toggle="dropdown"><img src="/site/assets/files/1017/germany-v1.png" alt="Deutsch"><b class="caret"></b></a><ul class="dropdown-menu"><li><a href='/en/' alt='English'><img src='/site/assets/files/1019/english-v1.png' alt='Flagge von Sprache'> English</a></li><li><a href='/fr/' alt='Francais'><img src='/site/assets/files/1020/french-v1.png' alt='Flagge von Sprache'> Francais</a></li></ul></li><li class="hidden-xs"><a href="/kontakt/">Tel: xxxxxxx</a></li><li class="visible-xs"><a href="tel:xxxx">Tel: xxxx</a></li><li class="visible-xs"><a href="/"><span class='glyphicon glyphicon-home' aria-hidden='true'></span> xxxx </a></li><li class='visible-xs'><a href='/standort/'><span class='glyphicon glyphicon-map-marker' aria-hidden='true'></span> Standort - so finden Sie uns </a></li><li class='visible-xs'><a href='/kontakt/'><span class='glyphicon glyphicon-earphone' aria-hidden='true'></span> Kontaktinformation </a></li><li class='visible-xs'><a href='/angebot/'><span class='glyphicon glyphicon-apple' aria-hidden='true'></span> Unser Angebot </a></li><li class='visible-xs'><a href='/konzept/'><span class='glyphicon glyphicon-file' aria-hidden='true'></span> Unser Konzept </a></li><li class='visible-xs'><a href='/team/'><span class='glyphicon glyphicon-user' aria-hidden='true'></span> Das xxxx-Team </a></li><li class='visible-xs'><a href='/links/'><span class='glyphicon glyphicon-globe' aria-hidden='true'></span> Links </a></li><li class="hidden-xs"><a href="#" class="dropdown-toggle" data-toggle="dropdown"><img src="/site/assets/files/1017/germany-v1.png" alt="Deutsch"><b class="caret"></b></a><ul class="dropdown-menu"><li><a href='/en/' alt='English'><img src='/site/assets/files/1019/english-v1.png' alt='Flagge von Sprache'> English</a></li><li><a href='/fr/' alt='Francais'><img src='/site/assets/files/1020/french-v1.png' alt='Flagge von Sprache'> Francais</a></li></ul></li></ul></div></div></nav> Is there a way to keep the format of the files included and or prepended/appended? or what am I doing wrong?
  17. Resolved the issue by myself: Works perfectly fine! In case somebody else lands here: double check the connection & credentials to the database in your config.php file
  18. Hi there, I'm trying to have a multi-site (multiple databases) setup on a IIS (Microsoft) server. I know that IIS is not officially supported by ProcessWire but customer is insisting on IIS. I get an 500 Error when trying to access the sub-domain/other processwire site. Did somebody do this before or is it not possible at all to have a multi-site setup on IIS? Thanks
  19. Just saw this post: making my question an ugly duplicate. Please consider this topic as closed because of duplicate.
  20. Hi Everyone, I was playing around with the ProcessWire command-line script sitemap.sh (https://processwire.com/docs/front-end/include/) I currently have a multi-site setup (with separate databases). -> site -> site-other The sitemap works but it shows only the pages from the default site directory. How can I get the sitemap of the site-other directory? Here is my working code that prints the sitemap of 'site': #!/usr/bin/php <?php namespace ProcessWire; include("index.php"); // bootstrap ProcessWire function listPage($page, $level = 0) { echo str_repeat(" ", $level) . $page->title . "\n"; foreach($page->children as $child) { listPage($child, $level+1); } } listPage($pages->get("/")); // start at homepage I tried including index.config.php instead of index.php but that didn't help...
  21. Oh wow, Thank you so much @elabx I could have come up with that myself. Sometimes you don't think of the easiest solution. Thanks for giving me a heads up! You have a great day!
  22. Hi everyone, I read a few things about implementing a multi-language feature of this module but I can't find anything in the module. Has anyone managed to do a multi-language setup with SEO? Also the meta tags are in the source file but Google doesn't use them. Same issue as @Roych
  23. @Tobi C. I had the same issue. After I checked the "Revoke Authentication" button in the settings of the GA-Module I finally saw the drop-down with the domains and everything is working now. Not sure what caused the problem...but hey it's working now. Awesome module @Wanze and greetings from Switzerland
×
×
  • Create New...