Jump to content

Robin S

Members
  • Posts

    5,039
  • Joined

  • Days Won

    340

Everything posted by Robin S

  1. Probably not: I answered my own question in the next post: The situation @Wanze replied to is a little different - not an order of page IDs but an order of values to match a field against.
  2. When exporting web images (assets from design mockups) I follow this guide and it works great: https://www.viget.com/articles/the-mysterious-save-for-web-color-shift Working Space: sRGB Proof Setup: Monitor RGB Proof Colors: On (doesn't affect export - just ensures you see the same colour in Photoshop as you will in the browser) Save For Web Embed Color Profile: unchecked Convert to sRGB: unchecked
  3. Is it possible to use a selector to find fields that have a given textformatter applied? I tried... $flds = $fields->find("textformatters=TextformatterHannaCode"); ...but the textformatters property is an array so I get an array to string conversion error. So a broader question would be: is it possible to use a selector to match inside a property that is an array? For the textformatter, is there a more efficient way than just iterating over $fields? $flds = []; foreach($fields as $field) { if( is_array($field->textformatters) && in_array('TextformatterHannaCode', $field->textformatters) ) $flds[] = $field; }
      • 2
      • Like
  4. I think that's just a coincidence if you add several pages one after the other without reordering them in the field. But because a page that's in a PageTable field can reside anywhere in the page tree there could be other pages added (that have nothing to do with the PageTable field) which would affect the sort property of the page. Intentional, because there are really two sort values - the sort property that belongs to the page itself (the tree sort) and the sort that belongs to the PageTable field. This is in the PT database table but doesn't seem to be passed though as a property of the pages when you get them via the PT field. @alexcapes The order of the field is set according to the order of pages in the PageArray (or array of page IDs) when you save it to the field. For example: $page->setAndSave('my_pagetable', array(1009, 1002, 1007)); // an array of page IDs // or $pa = $pages->find("template=my_template, sort=title"); // create and sort your PageArray however you like $page->setAndSave('my_pagetable', $pa); You could also do things like get the existing PageTable PageArray and then add pages using methods like insertAfter() But are you sure you have to delete and recreate pages? You could keep the existing pages and change just about any property of them without actually deleting them. Maybe explain the whole process of what you're doing and someone may be able to suggest a different approach.
  5. I think "sort" is the sort order of the pages as they appear in the tree, which may be different than the order they appear in the PageTable field.
  6. Nice one! But just a small thing: you set $search to an empty WireArray and then immediately re-set it to an empty array: $search = new WireArray; $search = array(); You only need the latter.
  7. +1 (I hate auto focus... ) Just wanted to add that I find the autofocus of the filter box specifically on the modules listing quite useful. I'd much rather type than scroll.
  8. Did you do this bit...? But in any case if you update to LimitPageTable v0.0.3 linked in my first post above it adds a config option to choose which value you want to match against so no editing of the module is needed now.
  9. It works well, thanks!
  10. I tried it on both Firefox and Chrome and got the same result. But then I discovered it's caused by the LastPass extension that I have installed on both. If I log out of LastPass it works normally, so problem solved. Thanks.
  11. When adding a new module to the directory, after completing the first step where the link to the GitHub repo is entered, on the second step all the module information fields seem to be pre-populated with info from a different module of mine that is already in the modules directory. Is that normal? It's only the second module I have submitted so I'm not sure. I don't want to end up editing the info for the existing module instead of adding the new module.
  12. Thanks for adding the Lister hover action buttons - something I've been wanting for a while. It's working for me in Lister Pro, but I do see some error notices too - not sure if this is what @adrian is referring to above. PHP Notice: Undefined variable: listerType in ...\modules\AdminOnSteroids\AdminOnSteroids.module:759 PHP Notice: Undefined index: in ...\modules\AdminOnSteroids\AdminOnSteroids.module:759 PHP Notice: Undefined variable: listerType in ...\modules\AdminOnSteroids\AdminOnSteroids.module:761 Would it be possible to activate the hover buttons for Lister Pro independently from the other Lister tweaks? The reason being that I'd rather set the columns for the Find and Users lister in Lister Pro and the AOS Lister columns feature interferes with this. Edit: what I mean is could there be checkboxes to activate the AOS Lister columns feature rather than the columns feature being active by default when "ListerTweaks" is checked? Not an AOS problem as it happens when the action buttons show on click too, but the columns jump around as the hovered row changes:
  13. <?php if($tab_size == 'too big') { use \CSS; $to_change->it(); } else { $it_looks = 'stupid'; } ?> When pasting code indented with tabs into the forum the indents are too large. It's simple to fix with a bit of CSS: pre { -moz-tab-size: 4; tab-size: 4; } Could someone with the necessary access add this? The big indent bugs me so much I usually find/replace the tabs with spaces when posting code. And as is universally agreed by all quality coders: tabs are much better than spaces
  14. Updated to v0.0.2. This version simplifies the module somewhat and you no longer need to select templates in the config.
  15. I'm not sure what's the right way to use that. This gives me: syntax error, unexpected '/' $this->pages->addHookAfter('saveReady', function($event) { $page = $event->arguments('page'); /Tracy/Debugger::barDump($page); }); Do you remember which version of Tracy Debugger you introduced the Live dumps? Might be easier for me to roll back to an older version.
  16. Hi @adrian I've been noticing something odd when dumping the $page variable inside a hook. I've noticed it when hooking several different methods, but take this hook for example: $this->pages->addHookAfter('saveReady', function($event) { $page = $event->arguments('page'); bd($page, 'page'); bd($page->name, 'page->name'); }); In this hook $page should be the page that is ready to be saved - let's say I am saving the Home page. But when I save the Home page in the admin, the dumped $page variable is for the "Edit" page (ProcessPageEdit). Which is weird, but what makes it weirder is that the subsequent dump of $page->name shows "home" not "edit". Any ideas on what is going on here?
  17. It looks like you have some filters set in the Users lister. Does the error still occur if you remove the filters? Also, the title of your post is a little unclear - you have added "user-admin-artist" as a permission and not the name of a role, right? Just to confirm, you followed a procedure like this... Installed user-admin permission: Access > Permissions > Add New > Install predefined system permissions > user-admin Installed user-admin-all permission: Access > Permissions > Add New > Install predefined system permissions > user-admin-all Installed user-admin-artist permission: Access > Permissions > Add New > Install predefined system permissions > user-admin-artist Gave user-admin and user-admin-artist permissions to a role: Access > Roles > artist (or whatever) > checked 'user-admin' and 'user-admin-artist' Welcome to the forums BTW
  18. Thanks for the update. In Firefox the jumplinks show the green highlight but aren't triggering a scroll. In IE11 there is no highlight or scroll.
  19. First thing would be to check that those two "if" tests are being passed. You can do this by logging a message after each test. Or it's really easy with Tracy Debugger: $fu->addHookAfter('FrontendUser::save', function($event) use($fu, $input) { if($event->return === true) { bd('test one passed'); if(!empty($input->post->password) && !count($fu->form->getErrors())) { bd('test two passed'); // the rest of your code } } });
  20. @Jennifer Stock, I've been working on a module for this purpose for a while now. Figured it's time to finish it off and release it. Find it here:
  21. ConnectPageFields Allows the connecting of two related Page fields so that changing one updates the other. Purpose of module An example: suppose your website is about movies. You have a template "movie" with Page field "actors". For each movie you add the actors that appear in the movie. All good, but what if you want to find results like... the 10 actors who have appeared in the most movies actors who haven't appeared in any movies since 1990 You cannot retrieve these pages with a single efficient $pages->find() query, and must load a large PageArray into memory in order to iterate or filter it. For the sake of making these types of queries more efficient you could structure your templates/fields so that movies are added to actors instead, but this may be a less comfortable workflow and can run into equivalent problems (e.g. "find the 10 movies with the largest cast"). The solution is to have a two-way relationship so that movie pages have an "actors" Page field and actor pages have a "movies" Page field. This module will keep these two Page fields in sync so that adding "Ryan Gosling" to "Drive" automatically adds "Drive" to "Ryan Gosling". Also, you can select the same Page field in both Page field A and Page field B. For example, create a "Related" Page field for related pages. Choose "Related" for both fields in a pair in the module config. Now when you add "Orange buffoon" to Related for "Donald Trump", "Donald Trump" is automatically added to Related for "Orange buffoon". Usage Install the ConnectPageFields module. If you haven't already done so, create the two Page fields you want to connect and add them to templates. In the module config select the two Page fields in a "Connected field pair" row as Page field A and Page field B. You can add rows as needed using the "Add another row" button. Troubleshooting Make sure you have set the "Selectable Pages" settings for each Page field correctly: The settings for Page field A should allow pages using the template(s) that Page field B has been added to. The settings for Page field B should allow pages using the template(s) that Page field A has been added to. http://modules.processwire.com/modules/connect-page-fields/ https://github.com/Toutouwai/ConnectPageFields Module config: Demo showing how changing one Page field updates the other:
  22. I was wrong about the bug in PageTable - I misinterpreted what the purpose of the 'reloaded' event was. So unfortunately there's no event that's guaranteed to trigger when the inputfield does an AJAX reload. Instead we have to check the PageTable field with every ajaxComplete(). But that's not actually a bad thing because we want the check to fire if the PageTable was inside an AJAX loaded field. If you placed a modified InputfieldPageTable in /site/modules/ please remove this and install LimitPageTable v0.0.2: LimitPageTable.zip 1. This is straightforward - in "Table fields to display in admin" just use template.label instead of template, and change the module to match against tpl_label: return $(this).text() == tpl_label; I considered making this the default for the module but I don't like the header given to the table column when this option is set. 2. Not sure what you mean here - the button is disabled in the PageTable field, isn't it?
  23. I started changing over my default site profile that I use as a base for new projects to use the functions API and region() function. Then I realised that neither of these will suit me because the functions can't be interpolated in strings the way variables can. I much prefer string interpolation over concatenation - I find it more concise and easier to read. The main attraction to me was the IDE code completion. Pasting the following at the top of each template file does the trick and isn't much hassle. namespace ProcessWire; /** * ProcessWire API variables * * @var $page Page * @var $pages Pages * @var $modules Modules * @var $user User * @var $users Users * @var $permissions Permissions * @var $roles Roles * @var $input WireInput * @var $sanitizer Sanitizer * @var $session Session * @var $log WireLog * @var $cache WireCache * @var $datetime WireDateTime * @var $files WireFileTools * @var $mail WireMail * @var $config Config * @var $database WireDatabasePDO * @var $fields Fields * @var $templates Templates * @var $languages Languages * @var $wire ProcessWire * @var $procache \ProCache **/ A similar thing can be done for region variables to avoid IDE 'undefined variable' notices. /** * Template region variables * * @var $headline * @var $content * etc **/ I've set these up as a file template in PhpStorm so they appear automatically for each new PHP file created in the project.
  24. This seemed like a fun challenge so I put together a little proof-of-concept module. For this to work you need to do a couple of things: 1. Correct a bug in InputfieldPageTable.js - hopefully will be fixed in the core soon. In the meantime you can copy the InputfieldPageTable directory to /site/modules/ and change line 18 of InputfieldPageTable.js to: Edit: sorry, I was wrong about this 2. Include "template" or "template.label" in "Table fields to display in admin" for your PageTable field. A screenshot of the module config: Download v0.0.3: LimitPageTable.zip
  25. The docs for MSN do cover this. If your parent page has a particular template you can use the xtemplates and xitem_tpl options. For more advanced targeting you can use a hook, for example: $nav = $modules->get('MarkupSimpleNavigation'); $nav->addHookAfter('getItemString', function($event) { $page = $event->arguments('page'); if($page->children->count()) { $event->return = "<button class='$page->name'>$page->title</button>"; } });
×
×
  • Create New...