Jump to content

Robin S

Members
  • Posts

    4,928
  • Joined

  • Days Won

    321

Everything posted by Robin S

  1. I have my doubts about how effective that strategy will be, but you have a few options: 1. Create a PW template and page that outputs the CSS. Use a "text/css" content-type header, either using the "Content-Type" select on the Files tab of the template, or by using header(). header('content-type: text/css; charset: UTF-8'); Add this page to your markup in a <link> tag: <link rel="stylesheet" type="text/css" href="/path/to/page/"> 2. Similar to the above, but rather than create a template and page instead create a PHP file in the site root (PHP files are blocked inside /site/) that bootstraps ProcessWire. 3. Use $files->filePutContents() to actually write a CSS file that you load in your markup. In all of these cases you will probably want to use a cache-busting query string based on the time the CSS was last modified.
  2. A new module that hasn't had a lot of testing yet. Please do your own testing before deploying on any production website. Custom Paths Allows any page to have a custom path/URL. Note: Custom Paths is incompatible with the core LanguageSupportPageNames module. I have no experience working with LanguageSupportPageNames or multi-language sites in general so I'm not in a position to work out if a fix is possible. If anyone with multi-language experience can contribute a fix it would be much appreciated! Screenshot Usage The module creates a field named custom_path on install. Add the custom_path field to the template of any page you want to set a custom path for. Whatever path is entered into this field determines the path and URL of the page ($page->path and $page->url). Page numbers and URL segments are supported if these are enabled for the template, and previous custom paths are managed by PagePathHistory if that module is installed. The custom_path field appears on the Settings tab in Page Edit by default but there is an option in the module configuration to disable this if you want to position the field among the other template fields. If the custom_path field is populated for a page it should be a path that is relative to the site root and that starts with a forward slash. The module prevents the same custom path being set for more than one page. The custom_path value takes precedence over any ProcessWire path. You can even override the Home page by setting a custom path of "/" for a page. It is highly recommended to set access controls on the custom_path field so that only privileged roles can edit it: superuser-only is recommended. It is up to the user to set and maintain suitable custom paths for any pages where the module is in use. Make sure your custom paths are compatible with ProcessWire's $config and .htaccess settings, and if you are basing the custom path on the names of parent pages you will probably want to have a strategy for updating custom paths if parent pages are renamed or moved. Example hooks to Pages::saveReady You might want to use a Pages::saveReady hook to automatically set the custom path for some pages. Below are a couple of examples. 1. In this example the start of the custom path is fixed but the end of the path will update dynamically according to the name of the page: $pages->addHookAfter('saveReady', function(HookEvent $event) { $page = $event->arguments(0); if($page->template == 'my_template') { $page->custom_path = "/some-custom/path-segments/$page->name/"; } }); 2. The Custom Paths module adds a new Page::realPath method/property that can be used to get the "real" ProcessWire path to a page that might have a custom path set. In this example the custom path for news items is derived from the real ProcessWire path but a parent named "news-items" is removed: $pages->addHookAfter('saveReady', function(HookEvent $event) { $page = $event->arguments(0); if($page->template == 'news_item') { $page->custom_path = str_replace('/news-items/', '/', $page->realPath); } }); Caveats The custom paths will be used automatically for links created in CKEditor fields, but if you have the "link abstraction" option enabled for CKEditor fields (Details > Markup/HTML (Content Type) > HTML Options) then you will see notices from MarkupQA warning you that it is unable to resolve the links. Installation Install the Custom Paths module. Uninstallation The custom_path field is not automatically deleted when the module is uninstalled. You can delete it manually if the field is no longer needed. https://github.com/Toutouwai/CustomPaths https://modules.processwire.com/modules/custom-paths/
  3. Release date: 7 October 2016 https://processwire.com/blog/posts/processwire-3.0.36-and-looking-forward/ This warning started in PHP 7.2, release date: 30 November 2017 https://en.wikipedia.org/wiki/PHP#Release_history PHP is adding and deprecating features all the time. Not just a ProcessWire thing, but in general you don't want to run PHP software on a PHP version that didn't exist when that software was released.
  4. Yes, good tip - thanks. Also note that if unpublished pages are to be included then the Page Reference fields in question would need to be configured to allow them, because by default they are not.
  5. A couple of issues I can see there. You need to set the $event->return instead of returning a value. And if you are hooking before and replacing a method with your own code then you need $event->replace = true. See Ryan's example in the topic I linked to. But in your case a simpler approach could be this (note that this is hooking after because it is modifying the $event->return): $wire->addHookAfter('Page::path', function(HookEvent $event) { $page = $event->object; if($page->rootParent->template != '_site') return; $event->return = str_replace('/' . $page->rootParent->name, '', $event->return); });
  6. @jonatan, what you're describing doesn't relate to the Connect Page Fields module - this module doesn't get involved with whatever inputfield you have chosen to select pages with. Maybe take a look at the Inputfield Selectize module - it shows an example with thumbnails in the readme.
  7. You hook Page::path - see Ryan's case study example: You might be reinventing the wheel... https://processwire.com/docs/more/multi-site-support/ https://github.com/somatonic/Multisite/
  8. Sweet! How about integrating lite-vimeo-embed too? Then the module could be a drop-in replacement for TextformatterVideoEmbed. ?
  9. I actually ended up writing my own backup script because I wanted the backup to run by cron job at a fixed time rather than have the unpredictability inherent in LazyCron. But in terms of this module my vote would go for having CronjobDatabaseBackup identify the backups that it creates either by filename prefix or something distinctive in the Description as per @horst's suggestion. Then the backups can be safely stored in /site/assets/backups/database/ where they can be viewed and restored via ProcessDatabaseBackups and there is no requirement to use a "file protection string" to protect backups not created by CronjobDatabaseBackup.
  10. FYI, the core has built-in support for relative time strings: https://processwire.com/api/ref/wire-date-time/relative-time-str/
  11. Just what is shown in the Implementation field: echo $page->comments->renderAll(); I suggest testing a Comments field on a clean installation of PW so you can determine that it does indeed work and then you can focus in on what might be different on your other site.
  12. @kixe, I feel that the settings "Maximum number of backups" and "Remove backups older than" should only apply to backups created by CronjobDatabaseBackup. If the user has made manual backups, or backups have been made by a different module, then CronjobDatabaseBackup should never delete those backups. What do you think?
  13. I think custom database tables and SQL queries would be the way to go. This is a good read on working with hierarchies in MySQL: http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/
  14. You are posting in the support thread for the third-party Image Extra module. This is already reported in the GitHub issues repo: https://github.com/processwire/processwire-issues/issues/1070
  15. To reproduce, put an input element in your template that is not within a form. <input type="text" value="someone@domain.com"> It's valid to use inputs, textareas, etc outside of a form element.
  16. Thanks for the reminder - I just tried this for the first time and it works well. I still think it would be a nice feature to add to Duplicator because it's more efficient time-wise to download all the images you need in one hit while you have a coffee rather than page by page as you edit. Plus I reckon people will find other use cases for selectively including page files in a backup.
  17. Big, big thanks @adrian for all your ongoing work on Tracy Debugger - it just gets better and better!
  18. Hi @flydev ??, A feature request... It would be awesome if there was a feature to enter a selector string that determined the pages whose files will be included in the backup. So that if the selector string was "template=basic-page" then in the backup the only directories inside /site/assets/files/ would be those belonging to a basic-page. My use case is that I sometimes need to copy a site to my local machine to do some work, but that work only involves one part of the site. My connection speed is not great where I live (particularly upload speed) so it would be a big help if I only needed to download/upload the related files and not all the site files. Thanks for considering. ?
  19. If you don't need to do anything with the existing page then you can avoid loading it: if($pages->count($selector)) continue;
  20. Yes, it's the styling CKEditor applies to all dropdowns - the Format and Style dropdowns are the same. I don't want to override the CKEditor defaults because the desired width for the dropdown will probably vary from person to person, but Adrian's solution is a good one. If you want to style the items (font size, etc) within any of the CKEditor dropdowns you can add custom CSS to /site/modules/InputfieldCKEditor/contents.css. For example, I don't like the "preview" styling added to items in the Format and Styles dropdown so I have this custom CSS: .cke_panel_list .cke_panel_listItem a * { font-family:sans-serif, Arial, Verdana, "Trebuchet MS"; color:#333; font-weight:normal; font-style:normal; text-transform:none; letter-spacing:0; font-size:14px; padding:0; margin:0; }
  21. @Roope, a feature request: it would be great if it was possible to avoid the email replacement within elements that are given a particular HTML class, e.g. "no-emo". My current issue is that if I show an email address as the value of a text input or textarea then EMO replaces those strings, which create invalid markup. Probably EMO shouldn't touch emails that are the values of form elements, but it would also be handy to be able to disable EMO inside other elements so I thought I'd request that class option.
  22. I think you should open an issue for this at GitHub. In WireShutdown the combination of... // use text-only output if an http request that is ajax if($useHTML && $config->ajax) $useHTML = false; ...and... } else if(!$useHTML) { $why = $this->labels['cli-mode']; } ...means that every AJAX request is wrongly treated as being CLI mode.
  23. It works out of the box for me. Are you including the CSS and JS as per the implementation notes?
  24. I was surprised to discover recently that a datetime inputfield using the jQuery UI datepicker will accept any old nonsense that an editor might put into it, allowing the page to be saved and often converting the input into strange unwanted values without warning. More info: https://github.com/processwire/processwire-issues/issues/1138 I think the core should be validating the input, but in the meantime here is some code that will check the input against the configured format (date only - I haven't tried time settings) and alert the user if the value is invalid. In the case of invalid input the previous value is restored. In /site/ready.php: // Datetime fields: load Vex to use for invalid date alerts $wire->addHookAfter("InputfieldDatetime::renderReadyHook", function(HookEvent $event) { $this->wire('modules')->get('JqueryUI')->use('vex'); }); In custom admin JS (loaded however you like - I use AdminOnSteroids) // Validate datetime inputfields $(document).on('focus', '.InputfieldDatetime input', function() { $(this).data('prev-value', $(this).val()); }); $(document).on('blur', '.InputfieldDatetime input', function() { var format = $(this).data('dateformat'); try { $.datepicker.parseDate(format, $(this).val()); } catch(e) { $(this).val($(this).data('prev-value')); var example_date = $.datepicker.formatDate(format, new Date('23 Oct 2014')); vex.dialog.alert('The date you entered is not in the valid format. Example of format: ' + example_date); } }); Result:
  25. It works fine here: pageQueryJson() is not a core method. If that method is the cause of your issue best to ask in the module's support thread.
×
×
  • Create New...