-
Posts
4,928 -
Joined
-
Days Won
321
Everything posted by Robin S
-
I hear what you're saying, but the idea for this module is to bring the behaviour of the core Images field to the Files field (albeit in a less ambitious way). Ideally the Files field would have a dropzone similar to the edit panel thumbnail of the Images field, and a file uploaded via that dropzone would immediately replace the edited file. But tackling the Javascript that would be involved feels like too much work, hence the less elegant approach taken in this module. Pull requests from JS wizards would be welcome. The way I'm imagining this module being used is you have a file with some metadata, and perhaps that file is linked to in a CKEditor field. You want to replace that file with another file (not yet uploaded) without having to manually copy the metadata or recreate the link in CKEditor. The new file is uploaded to the field and then immediately afterwards the target file is replaced. So it's like a poor man's version of the image replace feature, using the same underlying core code in InputfieldFile, in two steps instead of one. I hadn't imagined the replacement file being one that has already existed in the field for a while and has metadata associated with it (my screencast demo wasn't that well thought out - I'll redo it). But I think it should be quite easy to support what you've suggested, via a checkbox next to the select for "Replace metadata also". Or some other wording you think would be clearer?
-
An Images field allows you to: Rename images by clicking the filename in the edit panel or in list view. Replace images, keeping metadata and filename (when possible) by dropping a new image on the thumbnail in the edit panel. Introduced here. But neither of these things is possible in File fields, which prompted this module. The way that files are renamed or replaced in this module is not as slick as in the Images field but it gets the job done. The most time-consuming part was dealing with the UI differences of the core admin themes. @tpr, gives me even more respect for the work that must go into AdminOnSteroids. Most of the code to support the rename/replace features is already present in InputfieldFile - there is just no UI for it currently. So hopefully that means these features will be offered in the core soon and this module can become obsolete. Files Rename Replace Allows files to be renamed or replaced in Page Edit. Usage Install the Files Rename Replace module. If you want to limit the module to certain roles only, select the roles in the module config. If no roles are selected then any role may rename/replace files. In Page Edit, click "Rename/Replace" for a file... Rename Use the text input to edit the existing name (excluding file extension). Replace Use the "Replace with" select to choose a replacement file from the same field. On page save the file will be replaced with the file you selected. Metadata (description, tags) will be retained, and the filename also if the file extensions are the same. Tip: newly uploaded files will appear in the "Replace with" select after the page has been saved. https://github.com/Toutouwai/FilesRenameReplace http://modules.processwire.com/modules/files-rename-replace/
- 15 replies
-
- 18
-
[SOLVED] Only able to install modules via zip file upload
Robin S replied to ryanC's topic in General Support
I had an issue on local sites recently where communication with the Google Maps geocoder was failing due to an SSL error. The error message was a little different than what you are seeing, but it might be worth a shot. Have a read of this article: http://www.bigsoft.co.uk/blog/index.php/2017/04/29/file-get-contents-ssl-operation-failed-with-code-1-ssl3-get-server-certificate-certificate-verify-failed And follow the steps: Download the cacert.pem file to some suitable permanent location Edit php.ini to set the path to the downloaded file, openssl.cafile=/path/to/cacert.pem Restart Apache -
The reason in terms of the code is that a password inputfield is forced to display uncollapsed on unpublished pages because of this part of InputfieldPassword. There is no way to override this collapse status with a hook. As for the reason "why?", I can only speculate that Ryan sees the password field as a special case that is unlike other fields, and does not expect it to be used apart from the single built-in usage in the user template. Did you try the hook I suggested in my previous post? I'm not clear on whether you are using the password field a second time in the user template or in some other template besides the user template. If it's the latter and you are not editing the page via ProcessUser (i.e. not under the Access > Users section of admin) then you would modify the early return test to check for template instead. $wire->addHookAfter('ProcessPageEdit::buildFormContent', function(HookEvent $event) { $page = $this->process->getPage(); if($page->template != 'your_template') return; $form = $event->return; $pass = $form->getChildByName('pass'); // Assuming your password field is named "pass" if($pass) $form->remove($pass); $event->return = $form; });
-
Not sure, but it's working for me with non-superuser roles. Double-check that you have met all the requirements:
- 3 replies
-
- 1
-
- tags
- page-edit-created
-
(and 3 more)
Tagged with:
-
Modyfikacja por roku i odziezy najwyzszej jakosci
Robin S replied to james smith's topic in General Support
1. This part... // 4. // Split search phrase // If nothing above matches, try each word separatly if( !count($matches) ) { $q_separate = preg_replace('/\PL/u', ' ', $q); // "Remove" everything but letters $q_separate = preg_split('/\s+/', $q_separate); foreach ($q_separate as $q_word) { if ( $q_word != '' && strlen($q_word) > 4 ) { $append_products_separate = $pages->find("title|headline|summary~=$q_word, template=product, limit=50"); $matches->append($append_products_separate); } } } ...is needlessly inefficient. You don't need to do separate database queries per word here - you can use the pipe as an OR condition between words. So basically replace spaces with pipes in your search phrase and match against title|headline|summary. 2. Consider using the %= operator so you can match part words. So a search for "toast" will match "toaster". 3. If you don't have a huge number of products then maybe a fuzzy search using Levenshtein distance could be a possibility, for product title at least. I did a quick test against 196 country names (239 words) and it was reasonably fast. $q = 'jermany'; $countries = $pages->find("template=country"); $matches = new PageArray(); foreach($countries as $country) { $words = explode(' ', strtolower($country->title)); foreach($words as $word) { // Adjust max Levenshtein distance depending on how fuzzy you want the search if(levenshtein($q, strtolower($word)) < 2) { $matches->add($country); break; } } }- 5 replies
-
- 11
-
That is just how images work in ProcessWire. All images that you upload must be stored in an images field.
-
There is an option in the field access tab "Make field value accessible from API even if not viewable" that would probably resolve that. Alternatively you can prevent the field appearing in ProcessUser with this hook: $wire->addHookAfter('ProcessPageEdit::buildFormContent', function(HookEvent $event) { if($this->process != 'ProcessUser') return; $form = $event->return; $pass = $form->getChildByName('pass'); // Assuming your password field is named "pass" if($pass) $form->remove($pass); $event->return = $form; });
-
This tells you that there are no published, non-hidden pages using template "staff-page" under parent with id "1018" with a field named "locations" containing the current page. Try removing parts of the selector to find out what part of it causes no pages to match the selector. If you are wanting to match hidden or unpublished pages see the docs here: https://processwire.com/api/selectors/#access_control
-
In PHP you have to use double quotes if you want variables (i.e. $page) to be parsed inside a quoted string. See: http://php.net/manual/en/language.types.string.php#language.types.string.parsing $doctors = $pages->find("template=staff-page,parent=1018,locations=$page");
-
@tpr, this is a minor thing, but I'm wondering if the magnifying glass icon could be changed perhaps. One thing is that its direction changes in different usages: Another thing (and this is a personal opinion) is that this coloured icon is kinda ugly. It's style is too different to other icons in the UI and it stands out too much. I see that the icon is rendered using Segoe UI Emoji, so maybe the coloured appearance is just a Windows thing? Maybe you could use the Font Awesome version that is bundled with PW (although the magnifying glass icon there is also pretty naff). Or maybe bundle the Material Icons font with AOS? That could be quite handy in general, because then those icons would be available for use in admin UI customisations.
-
It's not so much an issue of which UTF glyph as which font is used to render the glyph. Each font designer is free to interpret each glyph (e.g. the letter "y", a "left arrow") any way they like, so changing to a different glyph wouldn't necessarily solve the issue. To get the same appearance on all devices you'll need to specify a font that will be available on all devices. Currently the font family is just "sans-serif", which in Windows 10 is Segoe UI, and no doubt something different in MacOS, Android, etc. So you could try and find a font that is included in the system fonts on all OSs. Or you could use the FontAwesome version that is bundled with PW. Or you could include a different webfont as part of Tracy Debugger, e.g. Material Icons. Or you could create your own custom symbol font that just contains the glyphs used in the module, using Fontastic or similar. Or you could use individual SVG icons for all buttons. Heaps of options.
-
Perfect now, thanks.
-
Thanks for the update @adrian - having these panels resizeable is a useful feature. I noticed some "twitching" in the console panel - I think due to the scrollbar appearing and disappearing. Maybe this could be avoided with an overflow rule?
-
Bug column width in UIKit admin template using if conditions
Robin S replied to Juergen's topic in General Support
There's a long discussion about column width issues in AdminThemeUikit in the issues repo: https://github.com/processwire/processwire-issues/issues/480 -
I shouldn't think so. The overhead in the search template would be negligible because searches are usually only for a few words at most. In the saveReady hook it would depend on how much content in the page you are saving sounds-like data for. I can't see it being an issue in most circumstances.
-
I took a quick look at it. The gist of it is that you would set the width of #tracyConsoleContainer with... width: calc(100% - 380px) !important; ...where 380px is whatever the width of #tracySnippetsContainer should be - there is something not quite right there currently, because the snippets container gets a width from an inline style that is narrower than its contents (which overflow). Also this rule... #tracy-debug fieldset { all: initial !important; ... ...would need to be overridden for the console/snippets panels with... width:100% !important; I don't mind it being there permanently myself. I have a wide enough screen that the Ace window is never so narrow that I'd want extra width by collapsing the sidebar. But maybe some people who work on smaller screens would appreciate that.
-
I'm loving this! On the Console and Snippets panel it seems that only vertical resizing is possible - horizontal resizing there would be handy.
-
Here's an example with a single "sounds_like" field containing both metaphone and soundex data. This is better I think. In /site/ready.php: $pages->addHookAfter('saveReady', function(HookEvent $event) { $page = $event->arguments(0); if(!$page->id || !$page->template->hasField('sounds_like')) return; $sounds_like = ''; $words = explode(' ', $page->title); // Get the individual words of field(s) foreach($words as $word) { if(strlen($word) < 3) continue; // Ignore short words $sounds_like .= metaphone($word) . ' ' . soundex($word) . ' '; } $page->sounds_like = $sounds_like; } In search template file: // $q is the sanitized search string $words = explode(' ', $q); $selector = ''; foreach($words as $word) { if(strlen($word) < 3) continue; // Ignore short words $selector .= 'sounds_like~=' . metaphone($word) . '|' . soundex($word) . ', '; } $results = $pages->find($selector);
-
A different approach which occurred to me is saving sounds-like data to hidden fields on a page and then searching those fields. This allows for other sounds-like algorithms such as metaphone, and allows for "contains" searches rather than only "equals" searches. Notes on the code that follows: You would create hidden fields "metaphones" and "soundex" and then add those to templates as needed. In the example I just save sounds-like data for the title field, but you could include other fields also. Using Double Metaphone would give more accurate results, but I just used metaphone in the example for simplicity. In the search code I am only searching the sounds-like data, but in the real world you would include other fields in the selector also as the "normal" part of the search. In /site/ready.php: $pages->addHookAfter('saveReady', function(HookEvent $event) { $page = $event->arguments(0); if(!$page->id || !($page->template->hasField('metaphones') && $page->template->hasField('soundex'))) return; $metaphones = ''; $soundex = ''; $words = explode(' ', $page->title); // Get the individual words of field(s) foreach($words as $word) { if(strlen($word) < 3) continue; // Ignore short words $metaphones .= metaphone($word) . ' '; $soundex .= soundex($word) . ' '; } $page->metaphones = $metaphones; $page->soundex = $soundex; }); In search template file: // $q is the sanitized search string $words = explode(' ', $q); $metaphones = ''; $soundex = ''; foreach($words as $word) { if(strlen($word) < 3) continue; // Ignore short words $metaphones .= metaphone($word) . ' '; $soundex .= soundex($word) . ' '; } $selector = "(metaphones~=$metaphones), "; $selector .= "(soundex~=$soundex)"; $results = $pages->find($selector); This allows matching a page title of "The quick brown fox jumps over the lazy dog" by search strings "offer took" and "quiz fogs" thanks to the differences between metaphone and soundex. Don't expect too much from it though - I found plenty of soundalike words that didn't match. The general principle could be expanded with other algorithms, and it would be cool to enhance this by allowing for mixed matches - for example, where in a two word search one word matches metaphone and the second word matches soundex. Edit: on that last point, a simple way would be to use just a single hidden field for both the metaphone and soundex data. The data from those two algorithms is sufficiently different that unwanted matches wouldn't happen. But if other algorithms were added you'd have to check to make sure the data from one algorithm wouldn't be confused with that of another.
-
Thanks for the new Buster feature! I'm sure you're right here, but some popular performance rating tools such as GTmetrix will deduct points for query strings on static assets, so that might be a reason to prefer filename versioning if clients will be evaluating the website with those tools.
-
I don't know anything about translations because where I live there is no demand for multi-language websites. I'm sure someone will help you with specifics for that soon. But as some general advice, you'll find that any development problem becomes a lot less confusing and frustrating as soon as you install Tracy Debugger and learn how the basic bardump works. Then you can start dumping variables in your template files, includes and functions and that way find out where your problem lies. I can testify that it's very empowering and greatly reduces feelings of hopelessness.
-
Welcome @MikeM! Probably not telling you something you don't already know: the project may be simple conceptually, but it won't be a simple development task. You'll need to work with an experienced developer in order to get a good result with this project. PW is an excellent platform to use for just about any web project, and considering where you are posting this you'll probably find lots of people here who will tell you the same thing. But to be honest, there are many platforms that could be used successfully for this project - in reality the success is more likely to come down to the experience and skill of the developer you hire than the platform used. So seeing as you won't be building the site yourself, your task is really to evaluate developers rather than evaluate ProcessWire. That sounds unusual to me - I haven't heard of people developing one site just to serve as an example for another site they want developed. More typical I think is to use a wireframing tool to show the flow of interactions. This helps you clarify to yourself how the website will work and also helps communicate your intentions to the developer. The wireframe could also demonstrate the design if you wanted that, using a tool such as Invision. Here are some links to a few popular wireframing apps if you want to look at that approach instead: https://www.invisionapp.com/ https://www.mockflow.com/ https://wireframe.cc/
-
Hi @teppo, The Version Control module is preventing the red asterisk from appearing in the header of required fields. The relevant admin CSS is: .InputfieldStateRequired>.InputfieldHeader:first-child:after { content: ' *'; color: #C00C19; } The addition of the field-revisions div interferes with this.