Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/29/2021 in all areas

  1. Hi @Bike There is Textformatter type of modules that are applicable in such cases. You can take a look at this module https://github.com/Toutouwai/TextformatterProcessImages from @Robin S Probably it can suit your needs or at least you can use it as a staring point.
    2 points
  2. Looks like you uncommented all RewriteBase lines. AFAIK you can only have one. Probably only the last one will have any effect, but you need the one in the middle. Try putting the #s back in the first and third RewriteBase. If it still doesn’t work, maybe paste your entire .htaccess here?
    2 points
  3. Hi @rushy AFAK there is no built-in option. There is a way how you can override core modules https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-copies-of-the-same-module. After that you can adopt 'getAdminThumb' method so your default image variation will match one that you are using on the frontend. Potentially there could be some issues with admin UI.
    2 points
  4. This is a holiday week here in the US, at least for my kids (school break). With kids home I've been off work this week so don't have any ProcessWire updates to report, but I'm looking forward to getting back to work next week and will have more updates to report then. Yesterday was Thanksgiving here in the the US and that kind of marks the beginning of the holiday season here. So today the Christmas tree went up, the lights are coming out and the holiday music has taken over the radio (or Alexa or Google or whatever we call it). Cheers and Happy Holidays!
    2 points
  5. Here is a new module for ProcessWire 2.1 that imports pages from a CSV file. By default it will create new pages from data in the CSV file, but you can also configure it to modify existing pages too (existing pages that have the same title). Please give it a try and let me know how it works for you and if you run into any issues with it. This module is something I've had in the works for awhile, and regularly use on various projects, so figured I should clean it up a bit and release it. Also attached are a couple screenshots from it. How to Install: 1. Download from: https://github.com/r.../ImportPagesCSV 2. Place the file ImportPagesCSV.module in your /site/modules/ directory. 3. In ProcessWire admin, click to 'Modules' and 'Check for new modules'. 4. Click 'install' next to the 'Import Pages CSV' module (under heading 'Import'). Following that, you'll see a new menu option for this module on your Admin > Setup menu. Supported field types for importing:* PageTitle Text Textarea (including normal or TinyMCE) Integer Float Email URL Checkbox (single) *I'll be adding support for multi-value, page-reference and file-based Fieldtypes in a future version.
    1 point
  6. Use this site, to generate all needed favicons and also the needed HTML code: Favicon Generator for perfect icons on all browsers (realfavicongenerator.net)
    1 point
  7. Can you please post your Apache2 host/vhost configuration file. Especially the <Directory ...> part could be interesting - as this is crucial in most cases. My configuration looks like this: <VirtualHost *:80> ServerName pw.test ServerAlias www.pw.test pw.test DocumentRoot /home/YOURUSERNAME/www/pw.test <Directory /home/YOURUSERNAME/www/pw.test> AllowOverride all allow from all Options None Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/pw.test-error.log CustomLog ${APACHE_LOG_DIR}/pw.test-access.log combined </VirtualHost>
    1 point
  8. It doesn't work because your condition must be inside the foreach loop below, why you need it to be outside of the loop?
    1 point
  9. Sorry to unearth this thread again, but I must apologise. It was indeed a collation thing. I had only checked the relevant field tables, but after switching everything except field_password to mb4, the problem disappeared. The issue must have started when my hoster migrated from MySQL to MariaDB months ago, because I’m sure I originally installed PW with mb4, but apparently I didn’t notice until after switching to PHP 8 recently. Probably because earlier I didn’t run Tracy constantly. Not sure how exactly it was implicated, but it was entirely my fault anyway ? Just wish I had had some hints in the logs. Eventually I got an SQL collation exception when purposely searching for an emoji in the Admin, but never with the random logouts. Anyway, glad to have this thread!
    1 point
  10. Have you set a RewriteBase in your .htaccess?
    1 point
  11. This does seem like an issue with htaccess not kicking in or mod_rewrite, does writing gibberish on the access throw an error? Cheap trick to see if it works ha! ?
    1 point
  12. Hi!! Try this: $found = $pages->find('template=customer_project'); forach($found as $p){ $p->setAndSave('location',"Hello world" ); } EDIT: Just reading again that you have this in ready.php so this will run on every page load, for every page with custom_project template, not very efficient lol. Like you mention, perhaps a hook after certain action would be better?
    1 point
  13. Does your Apache install have mod_rewrite enabled? If the home page is loading, but no other URLs are working, it sounds as though URLs are not being parsed. Also check permissions and ownership on directories and files. Directories should be 755, files 644.
    1 point
  14. Further to this, I've posted a feature request to Github, for a new method getColumns in WireDatabasePDO class, as this would enable: $database->getColumns($table) which would be helpful for getting a list of custom table fields and their types. there's already a getTables method and tableExists method, also a columnExists method, but currently no getColumns. I might be able to have a go at building a module myself to map custom table columns to inputfields, and of course I could write a method myself, but if other people are accessing custom tables, it would seem to make sense to have a getColumns method in the core. Copying the columnExists method, removing the WHERE condition and returning an array of the results rather than a boolean is probably all that's needed to implement a getColumns method.
    1 point
  15. Mine was also ? This helped me and may also help others: https://youtu.be/EeCNlB7v08I?t=161
    1 point
  16. I've never done that myself but you could also do a get request to that page automatically on save: <?php $wire->addHookAfter("Pages::saved(template=yourtemplate)", function($event) { $page = $event->arguments(0); (new WireHttp())->get($page->httpUrl); }); This might slow down saving the page for the client, but it would create all image variations for website visitors and you'd not need to define all the image variations in the hook or keep your template and the hook in sync... Happy to hear how that worked!
    1 point
  17. Hi @picarica You can achive it by hooking InputfieldFile::fileAdded like in the example below: $this->wire()->addHookAfter('InputfieldFile::fileAdded', function ($event) { $inputfield = $event->object; if ($inputfield->hasField != 'image' && $inputfield->hasField != 'images') return; $image = $event->argumentsByName("pagefile"); // Main post image if ($inputfield->hasField == 'image' && $inputfield->hasPage && $inputfield->hasPage->template->name == 'post') { $image->size('postMainImageSmall'); $image->size('postMainImageMedium'); $image->size('postMainImageMediumPortrait'); $image->size('postMainImageLarge'); } // Matrix block 'Gallery' if ($inputfield->hasField == 'images' && $inputfield->hasPage && $inputfield->hasPage->repeater_matrix_type == 5 && $inputfield->hasPage->template->name == 'repeater_builder') { $image->size('postBlockGallerySmall'); $image->size('postBlockGalleryMedium'); $image->size('postBlockGalleryLarge'); $image->maxSize(config('imageSizes')['postBlockGalleryLarge']['width'], config('imageSizes')['postBlockGalleryLarge']['width']); } // Matrix block 'Slider' if ($inputfield->hasField == 'images' && $inputfield->hasPage && $inputfield->hasPage->repeater_matrix_type == 6 && $inputfield->hasPage->template->name == 'repeater_builder') { $image->size('postBlockGallerySmall'); $image->size('postBlockGalleryMedium'); $image->size('postBlockGalleryLarge'); $image->maxSize(config('imageSizes')['postBlockSliderLarge']['width'], config('imageSizes')['postBlockSliderLarge']['width']); } // Matrix block 'Image' if ($inputfield->hasField == 'image' && $inputfield->hasPage && $inputfield->hasPage->repeater_matrix_type == 7 && $inputfield->hasPage->template->name == 'repeater_builder') { $image->size('postBlockImageSmall'); $image->size('postBlockImageMedium'); $image->size('postBlockImageLarge'); $image->maxSize(config('imageSizes')['postBlockImageLarge']['width'], config('imageSizes')['postBlockImageLarge']['width']); } });
    1 point
  18. I suggest checking that the PHP extensions and settings are the same between your PHP 7.4 instance and your PHP 8 instance. For example, someone posted recently with the same issue and found that the problem was due to unexpected settings in php.ini
    1 point
  19. EDIT: So this here is my final workaround: I wrote a hook that deletes the image variations (only those with the -srcset suffix) for one specific image when the page is saved after a focus change. $wire->addHookAfter('InputfieldImage::processInputFile', function($event) { if ($event['return']) { $pagefile = $event->arguments('pagefile'); $suffix = 'srcset'; $dir = new \DirectoryIterator($event->object->destinationPath); foreach($dir as $file) { if(strpos($file->getFilename(), '-' . $suffix . '.') !== false && strpos($file->getFilename(), pathinfo($pagefile->name, PATHINFO_FILENAME)) !== false) { $this->wire('files')->unlink($file->getPathname()); $this->message("Focus Changed. Image variations deleted for $pagefile->name."); } } } });
    1 point
  20. For a customer I needed a bunch of pictures to make a mosaic in Photoshop (cropped as a square) ? 20 lines of ProcessWire "et voila": a folder full of first pictures of every page from a certain template. <?php namespace ProcessWire; // boot api include('index.php'); // find estates from web database $estates = $pages->find("template=archief-pand"); // if estates count not zero if(count($estates)){ // loop over estates ($e is single estate) foreach($estates as $e){ // if images not null if(count($e->images)){ // get first image of estate gallery $firstPic = $e->images->first(); // resize and crop image to square 800x800px $firstPic = $firstPic->size(800,800); // if picture not null then copy picture to folder propics if(!empty($firstPic)) copy($_SERVER['DOCUMENT_ROOT'].$firstPic->url, $_SERVER['DOCUMENT_ROOT'].'/propics/'.$firstPic); } } }
    1 point
  21. Hi. Not tested but should work $this->wire()->addHookAfter('LanguagesPageFieldValue::getStringValue', function ($event) { $value = $event->return; $languagesPageFieldValue = $event->object; $languages = $this->wire()->languages; $userLanguageID = $this->wire()->user->language->id; $chineseLanguageID = $languages->get('chinese')->id; $newFallbackLanguageID = $languages->get('english')->id; if($userLanguageID === $chineseLanguageID && !$languagesPageFieldValue->getLanguageValue($chineseLanguageID)) { $value = $languagesPageFieldValue->getLanguageValue($newFallbackLanguageID); if(!strlen($value)) { $value = $languagesPageFieldValue->getDefaultValue(); } }; $event->return = $value; });
    1 point
  22. Don't worry, it's not a stupid question ? You can definitely build a custom search feature and get great results with that, but things tend to get a little more complicated if your site contains a larger amount of fields, and particularly if you're using Repeater, RepeaterMatrix, PageTable, or other types of fields with repeatable content — or perhaps page reference fields gluing content from different pages together. In other words content that isn't technically (directly) part of the page, but needs to be tied with the page in the context of site search. Although in many cases you could no doubt include all those fields in your search queries, this can result in pretty complex queries, and such queries also tend to become inefficient. Generally speaking the more fields you join in the query, the more complex the resulting SQL query will get, and the more time and resources it'll take to process. Not a great thing for scalability. First version of SearchEngine was really just an easy way to reuse bits and pieces of code that were developed over time to mash field values together so that they could be searched more efficiently. Soon after along came the markup generating parts (which now make up a notable portion of the module), a set of features for automatically filtering and sanitizing queries and processing the index, JSON output option (mostly for AJAX requests), indexing support for field types requiring specific handling (core ones as well as third party), etc. From the initial post in this thread: These days in my projects I install SearchEngine, set it up, and trigger the render function. The module takes care of everything else and "just works". In a nutshell SE bundles most of the stuff a typical site search will need into one package, and tries to do it efficiently and following best practices ? Hope this answered your question!
    1 point
  23. It was a timing problem. I tried to set headlines of repeater elements that didn't exist on the first ProcessPageEdit::loadPage. The solution was to set min repeaters back to 0 and create the needed repeaters by api on Pages::added. <?php namespace ProcessWire; class SetDefaultValues extends Process implements Module { public static function getModuleInfo() { return array( 'title' => 'Set Default Values', 'version' => 1, 'summary' => __('Set default values on new pages'), 'singular' => true, 'autoload' => true, ); } public function init() { $this->addHookAfter('Pages::added', $this, 'createDefaultRepeaterFields'); } public function createDefaultRepeaterFields(HookEvent $event) { $page = $event->arguments(0); if ($page->template == 'my_template') { if (count($page->my_repeater) < 1) { $defaults = array( 'Headline A', 'Headline B', 'Headline n', ); foreach ($defaults as $default) { $r = $page->my_repeater->getNew(); $r->headline = $default; $r->save(); $page->my_repeater->add($r); } $page->save(); } } } } Thanks for helping with this.
    1 point
  24. You can do this with a hook to Pages:added() in /site/ready.php $pages->addHookAfter('added', function(HookEvent $event) { $page = $event->arguments(0); if($page->template->name !== 'project') return; // Only for this template // Define your default labels and values $defaults = [ 'Size' => '', 'Year' => '2017', 'Location' => 'New Zealand', 'Status' => '', ]; // Add default items to repeater field foreach($defaults as $key => $value) { $item = $page->meta_fields->getNew(); // Populate subfields $item->field_1 = $key; $item->field_2 = $value; $item->save(); $page->meta_fields->add($item); $page->save(); } });
    1 point
×
×
  • Create New...