Jump to content


Popular Content

Showing content with the highest reputation on 02/13/2020 in all areas

  1. 8 points
    Heya! Just wanted to drop a quick note here regarding this point 😊 I get why you feel that this is a problem and "an ivory-tower approach to things", but it's worth keeping in mind that with all design decision you'll get some benefits, but also some drawbacks. In systems where there's no "true" tree structure (some CMS products have gone this route) this would likely be an easy thing, but since ProcessWire is indeed hierarchical, it's going to need a bit more work. At the same time the structure in ProcessWire is predictable, efficient, and works great when a site consists of a variety of different content types. I've worked with other types of systems as well (including WP), and would choose PW's hierarchy any day over any of the alternatives. Regarding "switching the root", I've run into something similar once, and that's after being around PW for almost a decade and having built, maintained, and rebuilt quite a few ProcessWire sites in that time. What you're asking for may seem like a simple thing, but it's really not (given our context), and it's also quite a rare request — if it wasn't, it'd probably make sense to give it more consideration at core level 🙂 To give you a bit of context, this is roughly the same as a Linux user stating that "I just need to switch the system root, it's an easy thing right?". Well, you can do that as well, but it's really not an easy thing, and may in fact be very destructive (unless you know exactly what you're doing). Again, design decisions; you may disagree with them, but the fact that this issue rarely comes up tells me that this particular design decision was likely a good one. Just my five cents 🤷‍♂️
  2. 4 points
    You can't, without running into major headaches, change the root page (i.e. "Home"). What you can do is create a copy and move all children with the exception of the system fields (admin, trash, 404) under the new home. Then you can adapt the Home page to your liking (i.e. switch template, edit contents, whatever). Here's a small script that automates that task. This hasn't been tested extensively, so I don't advise to run this on a production system, only on a copy (or at the very least make a test run on a copy and then make sure you have a full, working database backup at hand). You can copy this code into a script (e.g. as "clonehome.php") in your PW installation root and run it from the command line. <?php namespace ProcessWire; if(PHP_SAPI != 'cli') exit; include('index.php'); error_reporting(E_ALL); ini_set("display_errors", true); /* ************************************************************** * CONFIGURATION FOR CLONING * *************************************************************/ $adminUser = "admin"; // PW Backend User $childrenToLeave = [ $config->adminRootPageID, $config->trashPageID, $config->http404PageID = 27 ]; /* ************************************************************** * END OF CONFIGURATION * *************************************************************/ $session->forceLogin($users->get($adminUser)); $home = $pages->get($config->rootPageID); echo "Cloning Home" . PHP_EOL; $newOldHome = clone $home; $newOldHome->setQuietly('_cloning', $home); $newOldHome->addStatus(Page::statusSystemOverride); $newOldHome->removeStatus(Page::statusSystem); $newOldHome->removeStatus(Page::statusSystemID); $newOldHome->id = 0; $newOldHome->setIsNew(true); $newOldHome->parent_id = $home->id; $newOldHome->of(false); $newOldHome->set('numChildren', 0); $newOldHome->removeStatus(Page::statusSystemOverride); $pages->save($newOldHome, ["quiet" => true]); echo "Home page cloned, new id is {$newOldHome->id}." . PHP_EOL; $childrenToLeave[] = $newOldHome->id; echo "Moving children:" . PHP_EOL; // Now move all children, with the exclusion of admin tree and special pages (404, Trash) // as configured in $childrenToLeave foreach($pages->find("parent=$home, include=all") as $child) { if(in_array($child->id, $childrenToLeave)) continue; echo "- {$child->name}..."; $child->of(true); $child->parent = $newOldHome; $child->save(); $child->of(true); echo "[X] Done" . PHP_EOL; } echo "FINISHED. All children moved." . PHP_EOL;
  3. 3 points
    Is the event handler specific to the page reference field inside only new repeater items, or should it handle events of the page reference field inside all repeater items? Because if it's the latter you probably don't need to do anything in particular when a new repeater item is added - rather you can attach the handler to "document" and then use a selector to filter descendants. So supposing your handler is for the "change" event of selects named "foo" inside repeater items... $(document).on('change', 'select[name^=foo_repeater]', function() { console.log('repeater select changed'); }); Edit: and if only inside new repeater items then this seems to do the job: $(document).on('change', '.InputfieldRepeaterItemRequested select[name^=foo_repeater]', function() { console.log('new repeater item select changed'); });
  4. 2 points
    thank you @teppo, your point of view makes a lot more sense than telling me that what I'm trying to do doesn't make any.
  5. 2 points
    No worries! Can confirm had setlocale(LC_ALL, 'en_US.UTF-8'); in my site config. I only do this when PW tells me to, haven't taken the time to even understand why. Turning that off fixed the issue also. There's enough discussion within that silverstripe GitHub issue about the alternatives. Very very edge, will leave up to you!
  6. 2 points
    And it only happens on mac as well! Wow, what an edge case.
  7. 2 points
    Here is the exact issue. Set locale seems to be the problem, when combined with preg_replace on white-space... https://github.com/silverstripe/silverstripe-framework/issues/7132 Not at the comp right now but will check when I get back.
  8. 2 points
    To do this you would set the "maxFiles" property of the inputfield dynamically. In the field settings set "0" for "Maximum files allowed" (i.e. no limit). In /site/ready.php: $wire->addHookBefore('InputfieldImage::processInput', function(HookEvent $event) { /* @var InputfieldImage $inputfield */ $inputfield = $event->object; $process = $event->wire('process'); $user = $event->wire('user'); // Only for a specific field if($inputfield->hasField != 'images') return; // Only in ProcessPageEdit if($process != 'ProcessPageEdit') return; $page = $process->getPage(); // Only for a specific template if($page->template != 'basic-page') return; $limit = null; if($user->hasRole('basic-member')) $limit = 2; if($user->hasRole('silver-member')) $limit = 5; // Only if a limit applies to this role if(!$limit) return; $inputfield->maxFiles = $limit; });
  9. 2 points
    $(document).on('repeateradd', function() { alert('added'); }); https://github.com/processwire/processwire/blob/master/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.js#L330
  10. 2 points
    Table field is now one of the supported fieldtypes in SearchEngine 0.17.0. The indexing part makes use of TableRows::render(); I may have to revisit this at some point, but this approach seemed to work quite well in my initial tests, and this way I don't have to identify each possible value but can rather let the fieldtype do all the heavy lifting 🙂
  11. 1 point
    @wesp You don't need the Functions API for the functionality you asked for - it's just the syntax Zeka used that requires it, e.g. pages() instead of $pages etc. I have tried this combination here, and it works fine: // at the very top of home.php if ($input->urlSegment1) { $pagename = $input->urlSegment1; $match = $pages->findOne("template=article, name=$pagename"); if (!$match->id) { throw new Wire404Exception(); } echo $match->render(); return $this->halt(); } // site/ready.php // taken from this great case study: https://processwire.com/talk/topic/3987-cmscritic-development-case-study/ wire()->addHookBefore('Page::path', function($event) { $page = $event->object; if($page->template == 'article') { $event->replace = true; $event->return = "/$page->name/"; } }); If you copy-and-paste, pls note that my template is called 'article', not 'article-page' 🙂 Attached also the home template URL segment settings.
  12. 1 point
    Hi @horst ProcessWire 3.0.98Pageimage Manipulator 2 0.2.9 exact urls something like : site/assets/files/9771/30x30.jpg pim image : site/assets/files/9771/30x30.-pim2-wm3.jpg Also i was lazy to rename images so i just count loops in PageImageManipulator02.class.php // Construct & Destruct the ImageManipulator02 for a single image public function __construct($entryItem=null, $options=array(), $bypassOperations=false) { ... if(!$this->isOriginal) { // traversing up 'til reaching root reference $this->originalImage = $entryItem->original; $countloop = 0; while(null !== $this->originalImage->original) { $countloop++; $reference = $this->originalImage->original; $this->originalImage = $reference; if($countloop > 5) { error_log("---- ImageManipulator02 loop! ".__LINE__); error_log("---- loop filename= ".$this->filename .", ".__LINE__); break; } } } ...
  13. 1 point
    Awesome — thanks for digging these out! 🙂
  14. 1 point
    Here is a dump adding that unicode aware regex tag: Sorry about the line numbers in Tracey output, I had hacked your module to add tables 😏
  15. 1 point
    I've edited this reply, since I double-checked and it is happening both with and without entity encoders active on CKEditor fields when trying to save the search index. See screenshots below, with the text Testing “testing” à 123 in a ckeditor field. Strange quotes get converted to utf-8 from html encoding, but the "à" symbol utf-8 gets clipped in half. Can confirm PW / DB / db table / db column all using utf8mb4 + unicode_ci (learnt alot about this stuff past few days!).
  16. 1 point
    Heya! I've looked a bit into this, but to be honest I'd like to gain a better understanding of the situation before applying the fix. Any chance you could check the charset and collation of the field_search_index table (assuming search_index is your search index field)? The output of "SHOW FULL COLUMNS FROM field_search_index" should be enough. The "u" modifier for preg_replace() does some things I'm slightly worried about, i.e. it's documented as "not compatible with Perl", it changes how matches are treated, and it may also result in warnings if the subject string invalid UTF-8 — so at the very least it may require a bit of extra validation as well to account for that. Before going there I'd like to figure out how to reproduce this issue first. I've tried all sorts of special characters with no luck, so far everything has worked just fine here 🙂 Also, when you say that the ""à" character it is getting encoded as \xc3 when it should be \xC3\xA0", what do you mean exactly? I mean... do you literally see \xc3 somewhere, or do I have to grab the value and pass it through some sort of inspection process to see that it's wrong? If I dump the result of processIndex(), I see "à" character on the screen, and that's also what's being stored in the database. Sorry, I'm easily confused when it comes to things like character sets etc. 😅 Edit: forgot to mention that based on StackOverflow this definitely looks like a character set issue, i.e. typical case where this error occurs is when you're trying to store UTF-8 data into a latin1 table. Assuming that the CKEditor field in question is some form of UTF-8, the index field data column should definitely also be UTF-8 — and if it's not, that sounds really weird.
  17. 1 point
    @daiquiri - with respect, i think you're missing a larger point about this system. Basically what you are trying to do doesn't make any sense, and you can't compare to WordPress because WP is a bucket structured system whereas PW is a hierarchical tree system. The homepage represents the root of your site (/). That is basically a sacred thing here - it should not be changed, and it should not need to be changed so i think you should re-assess why you need/want to do this and come up with a different way or reconfigure your thinking about how to achieve what you want. and in all of the years of working and developing in this, i have never heard of anyone needing or wanting to clone the homepage. The easy way to do it is: Current Home Page with old template (home.php) New Homepage (subhome.php) move all public content branches below this new branch Some subpage Some other subpage Hundreds of other sub and sub sub sub pages with lots of content, which I don't want to manually move around/clone etc then just reconfigure your code in home.php and subhome.php (e.g. create a new home.php and rename home.php to subhome.php)
  18. 1 point
    Got it working by adding a custom class via the beforeShow function: // show time pickers $(document).on("focus", ".RockDaterange .time", function() { $(this).timepicker({ timeFormat: 'HH:mm', dynamic: true, timeOnly: true, showTime: false, beforeShow: function(el, obj) { $(obj.dpDiv).addClass('RockDaterange'); }, }); }); .ui-datepicker.RockDaterange .ui-timepicker-div { border-top: 0; margin-top: 0; } .ui-datepicker.RockDaterange .ui-widget-header { display: none; } .ui-datepicker.RockDaterange dl { margin: 0; } 🙂 PS: Here are the datepicker docs: https://api.jqueryui.com/datepicker/#option-beforeShow
  19. 1 point
    Definitely an interesting topic! We've developed a few PWA's for our clients recently, and I'd say that they've been very well received — but, to be fair, they've been a) services for existing members and b) basically apps that wouldn't work (well) as regular websites, so that option was out of the question. When it comes to native vs. PWA, in our case PWA seems like the obvious choice: easy to use and efficient to maintain, upgrades are effortless, and obviously the web platform is "our thing" (more than native anyway) 🙂 Some "random" websites (news sites, blogs, etc.) are now offering the option to install, but to me that feels a bit weird: unless it's a service I'm going to use regularly and there's a clear benefit for me in installing it, I don't really see the point. In fact it can also be a little intimidating: why do I need to install this service to use it? Again I think it boils down to the question of "would it work as a regular website": if the answer is "yes", then perhaps it should just be that 🤷‍♂️ (Sorry to hijack the thread, by the way!)
  20. 1 point
    Cheers! I am storing magazine style story credits (role, name, website url etc) in the Table. I feel that since Table only accepts text based fields this is an ok candidate for indexing. Can try to hack away at your module myself for now, no rush. Yeah I originally was thinking I wanted to use a client side library like to handle the search itself (fuzzy style to handle mis-spellings eg https://rawgit.com/farzher/fuzzysort/master/test.html ), but now I am thinking that is overboard and probably confusing. Will most likely stick with your module / pw search, and just do client side querying / rendering. Cheers!
  21. 1 point
    Great work @teppo! Could explain a bit this feature "- Support for rendering pages that have not been "routed" to Wireframe using the altFilename template setting." Or just point the docs - did not fins corresponding article there.
  22. 1 point
    I know from a trusted source that some of you use Laragon as their prefered Windows DEV solution. Due to a recent conversation I noticed that there might be a nice little feature some of you may not know about. Laragon offers the Quick app option with some tools already predefined. In order to have ProcessWire there as well you just have to add one (two with a comment) line to your Laragon configuration. # ProcessWire ProcessWire=composer create-project processwire/processwire %s Just in case you want to start your next project a little bit faster.
  23. 1 point
    Just released SearchEngine 0.13.0. This version adds more validation regarding the search index field: there's a warning if the field is of wrong type, an option to automatically create it if it doesn't exist (i.e. it has been removed after the module was installed), and there's a notice in the module settings screen if the index field exists and is valid but hasn't been added to any templates yet. Additionally there's a fix for an issue where FieldtypeTextareaLanguage wasn't recognised as a valid index field type in module settings. This could've resulted in the index field setting getting unintentionally cleared if/when module settings were saved.
  24. 1 point
    I will do that on Monday, in the meantime thanks for your support and kindness :)
  25. 1 point
    The trick is to whitelist "q", after which MarkupPagerNav automatically sticks with it. Add this after you've validated the $q variable: $input->whitelist('q', $q); Note also that if this is your literal code, you should move the renderPager call in the if statement – if $q isn't set or validated, $results will be null, and this will cause an error 🙂
  26. 1 point
    @ceberlin @3fingers As of 0.12.0 SearchEngine now supports multi-language indexing and searching. This is based on the native language features, so the results you see depend on the language of current user etc. While I don't have a good test case at hand right now, I did some quick testing on one of my own sites and it seemed to work pretty much as expected – though please let me know if there are problems with the latest version 🙂 What you need to do to enable this is convert the index field (which is by default called search_index) from FieldtypeTextarea to FieldtypeTextareaLanguage.
  27. 1 point
    Reading the core, you can learn how something works but not why it's done in this way and what is the best way to use it.
  28. 1 point
    Thanks for the quick answer! (I am impressed of the processwire api and the community support)
  29. 1 point
    One more option, but requires a pro module. Lister Pro has a delete/trash action in its set of bundled actions. I use this one a lot.
  30. 1 point
    3 solutions in 5 minutes. Amazing. Thanks Adrian
  31. 1 point
    Almost one click - check out the Batch Child Editor module: http://modules.processwire.com/modules/batch-child-editor/ - either Edit or Replace mode. You could also code an API snippet and store it in the Tracy Console panel snippets list - just run it from the parent page (either on the frontend, or while editing the parent page in the backend - the console will get $page as the page being edited): Or you could use that code in an AdminActions (http://modules.processwire.com/modules/process-admin-actions/) action.
  • Create New...