-
Posts
5,008 -
Joined
-
Days Won
333
Everything posted by Robin S
-
Adding a comment to markup for cached pages
Robin S replied to ethanbeyer's topic in API & Templates
If you only want to output the timestamp comment if the page has template cache enabled you could do a conditional like this: if($page->template->cache_time > 0) { // Output your timestamp comment } There are some other cache-related properties present in Template objects that you can explore with Tracy Debugger in case they are useful to your goal. bd($page->template); -
[Solved] Selectors As Arrays - Help with OR-groups
Robin S replied to ethanbeyer's topic in General Support
Put quote marks around your search string so PW can distinguish between the selector string and the search string, e.g. $selector[] = "(repeaterField.fieldX|repeaterField.fieldZ%='{$search}')"; That is a more advanced usage than what is covered in the blog post. You'll need to use the "verbose" version of a selector array. Ryan gives an example of a verbose selector array this in this GitHub comment. And for more details and the specifics of OR-groups in a selector array see the comments in Selectors.php here and here. TBH you might find it easier to stick with selector strings for such things until we have proper documentation for selector arrays. -
Adding a comment to markup for cached pages
Robin S replied to ethanbeyer's topic in API & Templates
I haven't used template cache because I use ProCache instead, but wouldn't it simply be a matter of including the current date/time inside an HTML comment in your template files (or _main.php if using delayed output)? When a cached version is served you will see the time that was current when the markup was generated. -
@alexmercenary, when I test it using the function proposed in the blog post that introduced $config->sessionAllow... $config->sessionAllow = function($session) { // if there is a session cookie, chances are user is logged in if($session->hasCookie()) { return true; } // if requested URL is an admin URL, allow session if(strpos($_SERVER['REQUEST_URI'], '/processwire/') === 0) { return true; } // otherwise disallow session return false; }; ...then it works as advertised. That is, when I am not logged into the back-end there is no cookie set. Are you deleting any old cookies before you check for the cookie when not logged in?
-
No, I don't think it does, because it extends InputfieldMarkup and it seems that InputfieldMarkup does not support multiple languages. As a workaround maybe you can add one MarkupCKEditor field per language and then hide the ones not needed using CSS or a FormBuilder hook. If you have questions about how to hide fields like this then the FormBuilder sub-forum would be the place to ask.
- 17 replies
-
- module
- form builder
-
(and 1 more)
Tagged with:
-
Welcome @Beetrootman! Seems you found a bug. I have opened an issue at GitHub: https://github.com/processwire/processwire-issues/issues/603 P.S. LICEcap is a nice tool for doing screen captures in a forum-friendly embeddable GIF format, so users don't have to download a video file.
- 1 reply
-
- 3
-
-
-
When you use a single "." at the start of a URL it means "the current path". Your Javascript executes from "/admin/myprocess/option1/", so when you define the AJAX URL as "./option1-list/" the resulting URL will be "/admin/myprocess/option1/option1-list/". There is no execute method for that URL. Generally you would expect a 404 error, but because URL segments are enabled for Process modules the URL segments are parsed and the valid segment "option1/" is found, and the "option1-list/" doesn't resolve to anything so is effectively ignored. So that is why executeOption1() is executing and you are getting that data back in the AJAX response. For your own clarity I suggest assigning an absolute URL to a variable in Javascript and using that as your AJAX URL. That way you can log the URL to debug and be sure it is what you are expecting. var url = ProcessWire.config.urls.admin + 'myprocess/option1-list/'; console.log("url: " + url); // ...
-
Hi rick, I think you need a trailing slash for AJAX URLs in PW. Try "./some-thing/"
-
Thanks horst. I did some searching and thought it might be useful to compile a list of the issues, which are mostly (or perhaps all) resolved now. Solved: The issue mentioned above where some images were lost when multiple large images were uploaded simultaneously. https://github.com/ryancramerdesign/ProcessWire/issues/1871 https://processwire.com/talk/topic/13522-problem-with-ajax-images-upload-and-sessionhandlerdb/ Solved: Session times recorded incorrectly when MySQL timezone does not match local time. https://github.com/ryancramerdesign/ProcessWire/issues/1838 https://processwire.com/talk/topic/13307-session-handler-database-times-out-by-two-hours/ Solved: Truncated session data when Tracy Debugger installed. https://processwire.com/talk/topic/15784-what-will-trigger-a-csrf-error/ Solvable: Old sessions not deleted on some Ubuntu servers. I have struck this one myself and @horst's suggestion in the post below solved it. https://processwire.com/talk/topic/5796-session-handler-database-do-not-delete-old-sessions/?do=findComment&comment=56596 Fatal error thrown on Windows server using IPv6. https://github.com/ryancramerdesign/ProcessWire/issues/1596 https://processwire.com/talk/topic/12935-issues-moving-from-iis-localhost-machine-into-windows-server-production/ Slow performance with large number of sessions. https://processwire.com/talk/topic/18718-session-handler-db-issue/ But with huge amounts of traffic performance may be affected without SessionHandlerDB installed too. Login problems after website migration. Might be solvable by clearing caches. https://processwire.com/talk/topic/5317-cant-log-in-this-request-was-aborted-because-it-appears-to-be-forged/?do=findComment&comment=142160 https://processwire.com/talk/topic/13781-problems-after-installing-remote-copy-to-local/
-
Great, that will be really useful on sites with premium (paid) memberships where you want to prevent multiple users being sneaky and sharing a single account. Thanks @kixe and Ryan. I've avoided SessionHandlerDB apart from when I really need it because I've heard of strange issues that have eventually been traced back to this module. Unfortunately I can't remember what those issues were. For regular users of SessionHandlerDB: are there any issues or incompatibilities with other modules to be aware of? Nice! I only wish the announcement had come a couple of weeks earlier. ? I spent some time recently modifying ProcessForgotPassword for just this purpose. Excellent, I have closed an old request relating to this.
-
Autojoining fields with a specific $pages->find()
Robin S replied to thetuningspoon's topic in Tutorials
I think of the API reference as the official docs rather than the cheatsheet. The cheatsheet hasn't had a comprehensive update for a long time and there are loads of things in the API reference that aren't in the cheatsheet. The loadOptions / joinFields options are covered in the API reference: https://processwire.com/api/ref/pages/find/ loadOptions (array): Optional associative array of options to pass to getById() load options. https://processwire.com/api/ref/pages/get-by-id/ joinFields (array): Autojoin the field names specified in this array, regardless of field settings (requires autojoin=true). (default=empty) -
Welcome @Shoekrates, FormBuilder is a Pro module so you can get support from Ryan in the dedicated FormBuilder sub-forum.
-
In AdminThemeUikit (might be dev branch only at the moment) you can choose from a few colour options for inputfields: But it would be more flexible to use your browser dev tools to inspect the markup in Page Edit, find what class is unique to the inputfield you want to change, then use AdminOnSteroids or AdminCustomFiles to add a custom CSS file to change the background colour.
-
Module: Video embed for YouTube/Vimeo (TextformatterVideoEmbed)
Robin S replied to ryan's topic in Modules/Plugins
The module does not support this, but you could edit the module file, adding the following line here: $embedCode = str_replace('youtube.com', 'youtube-nocookie.com', $embedCode); If you later update the module the change would be overwritten and you would have to redo it. -
Giving privileges to edit only the content - After login
Robin S replied to SIERRA's topic in General Support
It would pay to think about how it will work if a user has permission to edit a child page but not its parent. Hiding non-editable pages means hiding any branches under those pages. -
Cloning pages seems to have different effects
Robin S replied to louisstephens's topic in General Support
It's annoying, right? You could thumbs-up the existing request for a change to this behaviour: https://github.com/processwire/processwire-requests/issues/186 And as a workaround in the meantime try this hook in /site/ready.php: $wire->addHookAfter('ProcessPageListActions::getExtraActions', function(HookEvent $event) { $page = $event->arguments(0); $actions = $event->return; if(isset($actions['copy']['ajax'])) { unset($actions['copy']['ajax']); $actions['copy']['url'] = "{$this->config->urls->admin}page/clone/?id={$page->id}"; } $event->return = $actions; }); If you find it's not working for you then it might be getting called before the equivalent hook inside ProcessPageClone, in which case you could try experimenting with the "priority" option for hooks: https://processwire.com/api/ref/wire/add-hook-after/ -
There are also specific elements within the $page->render() $options array for prependFile and appendFile, see here. So you can do: foreach($page->children('template=child') as $child) { echo $child->render(['prependFile' => null, 'appendFile' => null]); }
-
Repeated frontend login errors cause 500 internal server error
Robin S replied to Gideon So's topic in General Support
You have to handle the login throttle exception: -
Hi @tpr, a feature request: could you add a cache-busting query string (e.g. using filemtime) to the assets added from the "Asset Paths" section of AOS? Thanks!
-
My regex is rather weak also, but I think this will work... $cc = $modules->get('ServiceCurrencyConversion'); $text = $page->body; $regex = '/\x{20AC}([0-9]+\.?[0-9]+)/u'; $text = preg_replace_callback( $regex, function($matches) use ($cc) { $dollars = number_format($cc->convert('EUR', 'USD', $matches[1]), 0); return "{$matches[0]} (\${$dollars})"; }, $text ); echo $text; Would makes sense to put this into a simple Textformatter module and use it that way. See TextformatterNewlineBR for a basic example to start from.
-
Hi @bernhard, A bit OT, but in your development of this module have you had the need yet to get the path or URL of the pages you are including in a query? Do you know a way of getting or constructing the page path/URL from the database data without getting Page objects involved? From a quick investigation it looks like PW builds the path/URL with methods in the Page class but I was hoping to avoid having to load Page objects. Any tips?
-
Acces multilang field values inside processInput Hook
Robin S replied to Andreas Augustin's topic in General Support
@Andreas Augustin It's interesting - if you dump/log the $value here directly in InputfieldTextarea::processInput you can see that the method is called for every language. However, you can only actually hook the call for the default language - for the other languages the method must be called in such a way that hooks are not triggered (by calling the method name with the three underscores included). So you'll probably have to get the other language values from $input (either the WireInput argument to the method or via the API $input variable). For example... $wire->addHookBefore('InputfieldTextarea::processInput', function(HookEvent $event) { $inputfield = $event->object; $input = $event->arguments(0); if(!$inputfield->hasField || $inputfield->hasField != 'your_field_name') return; // The value for the default language $default_language_value = $inputfield->value; // The value for French language $french = $this->languages->get('french'); $input_var_name = "{$inputfield->name}__{$french->id}"; $french_value = $input->$input_var_name; // ... }); -
@BillH, I can't reproduce the issue. For me the module is working as expected for non-superusers. The list of files is generated in the ajaxResponse() method. To debug you could use Tracy Debugger (best option) or $log to check that the method is firing and is returning JSON for files on the page. Edit: if you updated from an earlier version of the module you might need to do a hard refresh in case the browser is caching the old version of plugin.js - not sure if CKEditor itself does any kind of cachebusting and there is no way to do this within the module for CKEditor plugins.