Jump to content

Robin S

Members
  • Posts

    4,928
  • Joined

  • Days Won

    321

Everything posted by Robin S

  1. Instead of the hook, wouldn't it be better to set this as the "Alternate template filename" only on the templates you need it for?
  2. If you mean PW in general, then... Add Material Icons: yes Replace FA with Material icons: no While that long list of Material Icons looks nice at first (and I use them often) there is a heap of essential things missing. A couple of random examples: Facebook, external link.
  3. I thought all the bundled actions were enabled for superuser by default on install, but now I see that superuser is preselected for all the actions but this doesn't actually take effect until you save the module config. Maybe that is intentional in Admin Actions, but in general I think that is something it's better to avoid. Users might navigate away without realising they need to save to confirm the settings on screen. And even if they later return to the module config, there is nothing to indicate that the settings they see on screen are not actually live. It can be a problem for the module dev too if you are expecting those default config values that show on screen to actually be available in the module. It's caught me out a few times in my own modules - I've learned now that a better approach is to define the config defaults in the construct() method so that the config that users see is what is actually in effect, right from the moment of install. Anyway, I see where you're coming from regarding the activation of actions, although personally I don't see any downside to having all the actions active and listed on the Admin Actions page (for superusers) so they can be explored. It's the step of adding actions to the menu where I would be limiting it to just regularly-used actions.
  4. Not sure why you are seeing that. What you should see is an exception message that explains things pretty well: IDs are the way to go for that sort of selector, so I would stick to what you have changed to rather than install PagePaths. Edit: it just occurred to me that you may not be seeing the exception if do not have debug mode enabled. In /site/config.php: $config->debug = true; You should enable debug mode while you are developing a site and then disable debug mode when the site goes to production.
  5. Nice. How about some radios for more focused searches? API reference - site:processwire.com/api/ Forums - site:processwire.com/talk/ Blog - site:processwire.com/blog/ I have these as keyword searches in my browser and they get a lot of use. (TBH, it's so easy to Ctrl+L focus the browser address bar and do a keyword search that I'm not likely to give the Tracy feature much use, but maybe some will prefer the Tracy option).
  6. Hi @adrian, a few ideas for tweaks to AdminActions... How about adding a $title option inside the action class? To specify a title rather than deriving it from the camel-case in the action class name. It doesn't look quite right if there is a capitalised acronym in the class name. Maybe new actions should be automatically enabled for the superuser role? To save having to visit the module config and enable each manually. The "Actions" tooltip appears when hovering any part of actions list in the module config (it comes from the title attribute on the inputfield wrapper). This is a bit distracting so maybe remove that?
  7. protected function defineOptions() { return array( array( 'name' => 'csv_upload', 'label' => 'CSV upload', 'description' => 'Upload a CSV file.', 'type' => 'file', 'extensions' => 'csv txt', 'overwrite' => true, 'maxFiles' => 1, 'required' => true, ) ); } protected function executeAction($options) { // If there was a file uploaded (Pagefiles object) if(count($options['csv_upload'])) { // Get the file (Pagefile object) $file = $options['csv_upload']->first(); // Parse the CSV data $handle = fopen($file->filename, 'r'); $count = 0; while(($row = fgetcsv($handle)) !== false) { $count++; // Process each $row // ... } fclose($handle); // Delete the uploaded CSV file (or else you will get an error next time you upload) unlink($file->filename); $this->successMessage = "$count CSV rows were processed."; return true; } else { $this->failureMessage = 'Please upload a CSV file'; return false; } }
  8. This module corrects a few things that I find awkward about the "Add New Template" workflow in the PW admin. I opened a wishlist topic a while back because it would good to resolve some of these things in the core, but this module is a stopgap for now. Originally I was going to share these as a few standalone hooks, but decided to bundle them together in a configurable module instead. Add Template Enhancements A module for ProcessWire CMS/CMF. Adds some efficiency enhancements when adding or cloning templates via admin. Features Derive label from name when new template added: if you like to give each of your templates a label then this feature can save some time. The label can be added automatically when templates are added in admin, in admin/API, or not at all. There are options for underscore/hyphen replacement and capitalisation of the label. Edit template after add: when adding only a single template, the template is automatically opened for editing after it is added. Copy field contexts when cloning: this copies the field contexts (a.k.a. overrides such as column width, label and description) from the source template to the new template when using the "Duplicate/clone this template?" feature on the Advanced tab. Copy field contexts when duplicating fields: this copies the field contexts if you select the "Duplicate fields used by another template" option when adding a new template. Usage Install the Add Template Enhancements module. Configure the module settings according to what suits you. https://github.com/Toutouwai/AddTemplateEnhancements https://modules.processwire.com/modules/add-template-enhancements/
  9. You'd also want to think about memory usage/limits. If someone uploads a 10000-pixel-wide image and you go to resize it for use in your template you could run out of memory. This was one of the reasons for introducing the client-side image resizing which is linked to the max-width/max-height settings.
  10. Cool stuff! But in the example you would definitely want that template check at the top of the hook (or check the current process with $this->process) or you will get an error when creating or editing a user (no Settings tab exists).
  11. I think this default behaviour is totally wrong - $config->adminEmail should not be used as the fallback "from" address by WireMail. I opened a LoginRegister issue and core feature request.
  12. One more option (and to state the obvious): you can simply upload ads.txt to the site root and then access it at www.xxx.com/ads.txt like you would expect.
  13. You need to supply a Page object as an argument to Pageimages(). For example: $page->carouselImages = new \ProcessWire\Pageimages($page); Seems like an unusual way to build a carousel though - are you using some kind of template/view separation? If not, you don't need to add the carousel images as a property of $page - you can just get your carousel pages and build the carousel markup from them directly. $carouselPages = $pages->get("name=categories")->children("headerImage!=''"); foreach($carouselPages as $carouselPage) { // output your carousel markup using $carouselPage->headerImage }
  14. Yeah, but it's a little bit trickier than what you have shown. $pagesList= $pages->get("/"); foreach($pagesList as $page){ } If you do this, $pagesList is just the Home page by itself - it isn't a PageArray you can loop over to get all the pages in your site. For a full listing of pages you actually need to use a recursive function like Ryan's example here: Just wanted to point this out in case a beginner actually tried to use your example.
  15. @monchu, thanks for the reply. It's not quite what I'm asking about - it's the default sort order I'm interested in and why a new page would be inserted in the middle of existing pages. I did manage to figure some stuff out... Firstly, it seems the 404 page, Admin and Trash are always sorted last. There's no changing that, which is fine. Also, looking at the "sort" column of the "pages" table in the DB it looks like there were gaps in the sequence of sort values of pages under Home. Because of those gaps and also the fact that some of the pages that are part of my site profile happened to have high sort values, new pages were being inserted above them in the tree. So I fixed the gaps with... $home = $pages->get('/'); $pages->sort($home, true); // re-build sort values for children of $home, removing duplicates and gaps ...and then I manually gave high sort values to any pages that I want to keep at the bottom of the tree (but still above 404, Admin, etc, as per the above)... $p = $pages(1016); // the Form Builder page $pages->sort($p, 99); // set the sort value to a high number Now new pages are going just where I want them.
  16. @adrian, I'm seeing an error in the back-end AJAX bar after I save a page. Tracy v4.6.4
  17. I have just created a new page "Sponsors" under "Home": My question is, how does PW decide that it is going to place this new page between "Form Builder" and "Page Not Found"? Why not at the top or bottom of the existing pages? When I created "Monitoring" and "Groups" the situation was the same and I sorted them manually. This has been bugging me for a while, and I can't see what the rhyme or reason is. First thought was that "pages with system templates get sorted last", but that doesn't hold up because Form Builder uses a system template and Page Not Found does not. Edit: in case it's relevant, the "Tools", "Instructions" and "Form Builder" pages are pre-existing pages that are included in my custom site profile.
  18. Wow, bumper update! Aside: I wonder which PW module has the highest version number? Tracy must be leading the field in terms of number of releases in any case. The Snippets panel is great - just what I was hoping for. Really handy having the keyboard shortcuts for run, and it's neat how the Run button gets focused after loading a snippet too. One thing though: would it possible to allow a namespace declaration inside snippets? I need that for IDE code completion but when I include it I get... Maybe Tracy could strip out any namespace declaration on the first line when it runs the snippet?
  19. Great post @Sephiroth! But this part... I'm not seeing how that code could be used to create a sitemap.
  20. @jannisl, @formulate, I can't reproduce the issue here (maybe it depends on what you have set in "HTML Options" on the Details tab of the CKEditor field settings), but if you are able to work out the steps for reproducing the problem could you please file a GitHub issue so it can be fixed in the core?
  21. Hi @adrian, Is it possible to include a File field in an action for this module? What I have in mind is uploading a CSV that is then parsed and used as data in the action. I saw that the Create Users action has a textarea field where you can paste data in CSV format so that is one alternative, but sometimes I think it would be easier to upload an existing CSV file. Ryan's ImportPagesCSV module makes use of a File field so I guess there is a way to use files temporarily in a Process module (I haven't looked into how). If Admin Actions doesn't already support this would you consider adding it? Also, I noticed a couple of issues while exploring the module. On install I get a PHP notice: And when I attempt to open the "Ftp Files To Page" action I get an error:
  22. That line that you weren't sure about is preventing the adding or removing of columns from the Users lister. I think you should be able to remove the else{} part because if there are no columns specified in the AOS config then you don't need to do anything to the Lister columns. Also, it would be a little more efficient not to even hook ProcessPageLister::execute when both column AsmSelects are empty in the AOS config... if ( in_array($subModule, $enabledSubmodules) && (!isset($_SERVER['HTTP_REFERER']) || strpos($_SERVER['HTTP_REFERER'], '?bookmark=') === false) && // No need for hook if no tweaks in config (!empty(self::$configData['ListerTweaks_find']) || !empty(self::$configData['ListerTweaks_users'])) ) { // ...
×
×
  • Create New...