Jump to content

Robin S

Members
  • Posts

    4,791
  • Joined

  • Days Won

    303

Everything posted by Robin S

  1. I think you want <img src="<?php echo $config->urls->templates ?>images/b1.jpeg"> or with short syntax <img src="<?= $config->urls->templates ?>images/b1.jpeg"> And to be honest, I usually hard code the paths to my template images. <img src="/site/templates/images/b1.jpeg">
  2. That would be a nice feature. I'm a strong believer in the benefits of minimising mouse usage. In the meantime... I'm not sure if this is a Windows or a Firefox thing, but if I click the select box and then start typing the highlight moves accordingly. So it's almost like an autocomplete. One catch is that you can't see the highlight on disabled items (i.e. those fields that are already added to the template) but you can type a letter or two and then use the arrow keys to complete the selection.
  3. This seems to me to be pretty comprehensive: https://processwire.com/api/ref/module/ Also useful: https://processwire.com/blog/posts/new-module-configuration-options/ And there's good stuff in the Helloworld.module I'm learning development myself and so I understand how it can be challenging to tackle something more advanced like module development. But I think you also need to bear in mind that many of the things that need to be understood in order to build a module are not PW-specific but are actually require knowledge of PHP and object-oriented programming. We can't expect the PW docs to give us all of this on a plate.
  4. mod_security blocks processing based on regex rules: exactly what rules are implemented is up to the host or the person configuring the module. Perhaps your page contains a string that matches some overly-broad regex rule. The intention behind mod_security is good but my experience has been that running the module results in many false-positives and the resulting problems are difficult to debug. On many hosts you can't even tell when mod_security has been triggered. My shared hosting enables it by default on every new account but I always disable it to avoid headaches.
  5. If your host is running mod_security that might be the culprit. I've struck odd issues like this before that were resolved by disabling mod_security.
  6. Great job on the new forum @Pete. Is there an account setting I can apply so replies in a Q&A thread are sorted by date by default? I find it hard to follow the conversation when they are sorted by rating and don't want to have to change the sort order manually for every thread.
  7. A like is not enough! This is just awesome and opens up so many possibilities for page inputfield UI. :)
  8. If you don't want to upgrade to ProCache v3 there are some htaccess settings shared by WillyC here.
  9. It works okay for me with PW 3.0.21. Not sure why it's not working for you but as an alternative you could use: $users->get($page->settings->created_users_id)->name $users->get($page->settings->modified_users_id)->name
  10. Echoing a comment above... In the image field 'list' view the size difference between landscape-format and portrait-format images can be extreme. In the screenshot below the two images have the same aspect ratio but the portrait-format is rendered much larger. Wouldn't it be better to define the thumbnail container as a square with the thumbnail centered and fitted to the container? Then each image row is an equal height.
  11. I solved this - it was due to a module of mine in which I use the admin image thumbnails. I just needed to adjust the module code to account for the new default thumbnail height of 260px.
  12. The module(s) is a helper for working with images in rich text fields. So part of the functionality is about inserting and applying attributes to images in the RTE and part is sizing the images and and generating markup based on those attributes via a textformatter. Currently I'm splitting this functionality into two modules, but I would rather do it in a single module with a single configuration page. Not sure why it should be forbidden to autoload a textformatter module. To work around this, if my module extends WireData instead of Textformatter is there a way to manually apply a textformatter method via a hook? Edit: thinking some more, the textformatter side really does need to be separate so it can be applied selectively to fields. So two modules it is.
  13. I just needed to fiddle around some more to find my answer. $image_fields = $fields->find("type=FieldtypeImage"); Looking at the data for a field I guess you can also find fields by id, flags, name and label. Nice!
  14. What kinds of things can go inside a $fields->find() selector? Can I use a selector to find fields of a given type? For instance, find all fields that are instances of FieldtypeImage?
  15. Is it possible to have a module that autoloads so admin methods can be hooked and also works as a textformatter? Or is creating two modules the only way? Setting an autoload value in getModuleInfo() seems to have no effect if the module extends the Textformatter class. Two modules would be okay for installation as one can auto-install the other, but needing two module config pages is bit of a pain. And the only other solution I can see is having one module store config data for the other, and that seems wrong.
  16. I am finally getting around to exploring PW3.x (3.0.20 to be exact) but the new images field is always showing 'older/low quality' thumbnails. When I first upload the images and have not yet saved the page the thumbnail quality is good. But as soon as I save the page I get low-quality thumbnails and the low-quality notice. Ticking the checkbox to recreate thumbnails and saving has no effect on the thumbnail quality and the message remains. Any ideas how to fix this? PW is running on XAMPP with PHP 5.5.33
  17. included_file.php <?php $fruit = 'banana'; echo "<p>My fruit is a $fruit</p>"; main.php <?php $fruit = 'watermelon'; call_user_func( function() { return include func_get_arg(0); }, 'included_file.php' ); echo "<p>My fruit is a $fruit</p>"; Output: <p>My fruit is a banana</p> <p>My fruit is a watermelon</p> Credit
  18. This works... $module_config = new MyModuleConfig(); $defaults = $module_config->getDefaults(); Does that look okay?? I'm an OOP noob.
  19. This should be saveModuleConfigData() not setModuleConfigData() - thanks kongondo Yes, that's what we mean. Or clicking "Save" on the module config screen. Most modules that I have looked at don't do saveModuleConfigData() on install. Random example: TextformatterVideoEmbed This doesn't work - getDefaults() is a method of the ModuleConfig class, or MyModuleConfig class which extends ModuleConfig. It's not a method in the module class.
  20. I don't see how Table can help here, because it doesn't allow for dependent selects (i.e. selects that change options/pages based on the value of another select in the same row). And it doesn't include SelectMultipleTransfer as one of the available inputfields. Did you investigate to see if a PageTable (hereafter 'PT') could work for you? Dependent selects work here, you can use "show if" settings to control field visibility, and you can choose the PT template fields you want to see in the table. So it seems like it would be a good solution. If you define a parent page for the PT pages and set a dedicated template for that parent page you can then use the "Name format for children" option to skip the page name step when adding new PT items. See the Setup Page Name module for more name format options. As the for the title field for the PT items: either set it non-global and remove it from the PT template, or use an 'added' hook to set the title automatically and optionally a 'saveReady' hook if you want to form the title from field values in the PT page. I can elaborate on this if needed.
  21. This would work, and it would be a solution if the module you want the config data for is one that you have created yourself. But most modules, whether they use the old or new way of setting config defaults, do not do this. The old and new way of setting module config perform the same as far as I can tell, in that both do not make the defaults available to getModuleConfigData() unless the module specifically saves them with setModuleConfigData(), which is what horst is suggesting. But it's not common for a module to actually do that. Modules do not need to force a manual save for either method, so long as you only care about making the default values available within the module itself. I agree that it's desirable for getModuleConfigData() and getConfig() to return the config regardless of whether the config consists of the defaults or a manually saved variation to the defaults. It's not really an edge case because it's quite common to leave a module config at the defaults I think. For modules using the newer ModuleConfig class it seems like this should be possible because there is a standardised way of setting defaults. For modules using the older config I suspect this wouldn't be possible because of the variety of different ways defaults are stored and used inside those modules. Back to my immediate problem: assuming the module I want the config defaults for uses the ModuleConfig class, how can I use the getDefaults() method to return the array of defaults? I can get the individual values by name like this... $modules->getModule('MyModule')->my_value ...but I want the array of all values so I don't need to know and specify each by name. The getDefaults() method is in the MyModuleConfig class, but that isn't a module itself so I can't do something like... $modules->getModule('MyModuleConfig')->getDefaults() But there must be some other way to access that method, right?
  22. Thanks. I was wrong about defining config with getModuleConfigInputfields() - I can't get the default config data with getModuleConfigData() unless the config page has been saved, and that applies to either method of setting the default config. So if getModuleConfigData() only works if the module config page has been saved, how do I get the default config data if the module just been installed and the config had not been changed or saved? Any defaults set for the config work in the module exactly the same as if they had been manually set, so it's frustrating to need a different method for getting the default config. I guess we have to check to see if getModuleConfigInputfields() returns an empty array and if so check something else to get the default config. The new way for setting module config extends a core ModuleConfig class, and contains a method getDefaults() that returns the config defaults in an array - this sounds like exactly what I need, but how do I call this method to get the defaults array? My objective is get the config data for one module inside another module.
  23. If I set my module config data the old-fashioned way, in the main module file with public static function getModuleConfigInputfields(array $data) { ... then I can get the config info successfully with $modules->getModuleConfigData('myModule'); Edit: I was wrong about that - it only works if the config has been manually saved. But if I set the module config in a separate file using the ModuleConfig class then getModuleConfigData() returns an empty array. Any idea what I'm doing wrong? Update: I have got it working but it's still a bit strange. I can't get the config data if the module config page has never been saved (i.e. it is in its default state after install). Once I save the module config page I can get the data with getModuleConfigData(), even if I haven't changed anything from the default settings. A bug maybe?
  24. Good news: you can have dependent selects Bad news: it has been said that dependent selects do not work inside repeater fields I've never tried them inside repeaters myself. I say give it a go, particularly if you are using PW 3.x because repeaters have had some upgrades there. If it's still a no-go maybe a PageTable could substitute?
  25. That JS for inserting images into the CKEditor field is really cool! For setting the width with the "small" command, try: element.setAttribute('width', 100); For anyone trying out Can's code, note that the JS that adds the HappyImageSelector is for PW3.x image field markup. Not hard to adapt to PW2.x though.
×
×
  • Create New...