Jump to content

Robin S

Members
  • Posts

    4,958
  • Joined

  • Days Won

    323

Everything posted by Robin S

  1. Hi @Macrura, I can't reproduce that here. Could you please help with debugging by doing a couple of Tracy dumps after this line? bd($hanna_tags, "hanna_tags"); bd($tag_name, "tag_name"); For the Tracy bar to appear in the dialog you'll need to allow it in the module config, and maybe make the dialog a bit bigger than the default so it's easier to see the dump results.
  2. Maybe this is safe, but it looks very risky to me. The ID here is coming from the URL, which is a type of user input. You would want to be 100% certain someone can't insert the default superuser ID 41 into the URL and then get logged in without a password and gain full access to the admin.
  3. @ceberlin, thanks for the report, it should be fixed in v0.5.1.
  4. In saveReady the page is just about to be saved and therefore output formatting is off, so all image fields (including single image fields) will be a Pageimages array.
  5. @PWaddict, you would need to use a different hook for this because processInput is too early - it happens before Page Edit decides whether the page should be published so any changes to the published status made there would be overwritten. Something like this should work: $wire->addHookAfter('Pages::saveReady', function(HookEvent $event) { $page = $event->arguments(0); if($page->template == 'test_custom_images') { $unpublish = false; foreach($page->images_custom as $image) { if(!$image->text_1) $unpublish = true; } if($unpublish) $page->addStatus(Page::statusUnpublished); } });
  6. @Charlie W, you can use an SQL query to match a date column by part of the date, e.g. by month. There are different ways you could incorporate this to find the pages you want, but one simple way is to first get the IDs of all matching pages, regardless of template, published status, etc, and then use those IDs as part of a PW selector. Demo: // First get the IDs of all pages where the month of the date value is February $field_name = 'date'; // The name of your date field $table_name = "field_$field_name"; // The table name is the field name prefixed with "field_" $month_number = 2; // i.e. February, or whatever month number you want to search for $stmt = $database->prepare("SELECT pages_id from $table_name WHERE MONTH(data) = :month_number"); $stmt->bindValue(':month_number', $month_number, \PDO::PARAM_INT); $stmt->execute(); $ids = $stmt->fetchAll(\PDO::FETCH_COLUMN); $ids_str = implode('|', $ids); // Then use the IDs in a selector where you are limiting by template, applying a sort, etc. $items = $pages->find("template=event, id=$ids_str, limit=3, sort=-date"); You can also match a date by just a day number or just a year, e.g. WHERE DAY(data) = :day_number WHERE YEAR(data) = :year
  7. @ryan, is there any difference in terms of performance between using conditional hooks and doing the equivalent logic of checking the arguments and/or return value within the hook and returning early when a condition is not met? Personally I've preferred not to use the conditional hook syntax because I find it more readable to have PHP logic in the hook code, but if this was less performant I'd consider changing.
  8. @adrian, the issue is resolved if I change line 111 of ConsolePanel.php to: $snippets[$i]['code'] = str_replace(\TracyDebugger::getDataValue('consoleCodePrefix'), '', file_get_contents($snippetFileName));
  9. @adrian, yes, that's the code prefix I'm using. In the checkIfUnsavedChanges() JS function I logged the two pieces of code that are compared to see if there are unsaved changes: if(snippet && tab) { var snippet_code = snippet.code.replace(/\s+/g, ' ').trim(); var tab_code = tab.code.replace(/\s+/g, ' ').trim(); console.log("snippet_code: " + snippet_code); console.log("tab_code: " + tab_code); } So the snippet code that's loaded from tracyConsoleSnippets in local storage seems to have the prefix included.
  10. In your field settings define "Template" for selectable pages but not "Parent". Check the "Enable link to create new pages?" checkbox that is added by the AdminPageFieldEditLinks module, but don't select anything in the "Parent for new pages created" field. Add the following hook to your /site/ready.php to define the parent dynamically. $wire->addHookBefore('InputfieldPage::render', function(HookEvent $event) { /** @var InputfieldPage $inputfield */ $inputfield = $event->object; $page = $inputfield->hasPage; $field = $inputfield->hasField; if($page && $field && $field->name === 'your_field_name') { $inputfield->parent_id = $page->id; } });
  11. Thanks @adrian. The new light theme is nice. I used that as a starting point and made a few other opinionated changes (that are possibly only to my tastes and nobody else's) which I've added as a "Kiwi" theme and submitted as a pull request. I realise that with these extra changes there's a chance it might need tweaking if you make future updates to the Console panel, so I'm happy to take responsibility for maintaining the theme styles as needed into the future. An issue that I noticed when playing with the tabs: if I open one of my saved snippets that includes the "Code prefix" that is designed to be hidden in the console (in my case it has the PW namespace and PHPDoc comments for the API variables) the code is immediately detected as changed, which causes the alert when I try and close the tab.
  12. @adrian, not sure what others think, but personally I like this style of tabs... ...more than the style in recent updates. In the previous version it's clearer that they are tabs, whereas in the newer version I find it all blends in with the code window. Maybe if the tab bar had a lighter background colour so it's more distinct?
  13. A general approach: The client doesn't do any optimising but just inserts images into TinyMCE. If there are different styles/positioning of images they apply these via classes on the image. You use a textformatter module that finds the images within the field, and if the image corresponds to a Pageimage (as opposed to some external image that you don't have control over) you do whatever resizing and optimising is needed and replace the original <img> markup with the markup you want (srcset or whatever). You can check the class on the original image and output different markup accordingly. A proof of concept module that could be a starting point: https://processwire.com/modules/textformatter-process-images/
  14. Here is the relevant part of the docs for reference: https://processwire.com/docs/modules/hooks/#how-can-i-define-my-own-hookable-methods
  15. I guess it's expected because it's been observed since 2013 at least. Discussion and code snippets in this topic:
  16. It's not included in the core. It's currently part of the ProFields bundle but that might change in future.
  17. I didn't read this thread closely but I see you are calling $this->___renderAsterisk() https://github.com/juergenweb/FrontendForms/blob/9ea92a986528a96e2aeb875482967b81e8a50018/Formelements/Textelements/Label.php#L59 If you want hooks to fire you need to call it without the underscores: $this->renderAsterisk()
  18. @gornycreative, please try v0.1.1 and if the issue isn't fixed let me know.
  19. Sounds good. In the meantime it's easy to do with a little custom CSS and JS. .InputfieldFileData { display:none; } .data-open + .InputfieldFileData { display:block; } $(document).on('click', '.InputfieldFileInfo', function() { $(this).toggleClass('data-open'); });
  20. Hi @adrian, I updated an older site running PHP 7.1 to the latest Tracy Debugger and got this error: Maybe that line needs a check of which Tracy version is in use?
  21. @ryan, the main branch is at 3.0.244 but the dev branch is still at 3.0.243. Does the dev version number need an update?
  22. No, everything is good. A really useful set of features, thanks!
  23. @adrian, thanks, the history is working for me now. I think this is caused by a combination of the button height being in fractional pixels and the scaleX(-1) transform on the right arrow. This causes Chrome to round the two arrow buttons to different numbers of whole pixels. There would be a several different ways to solve this, but perhaps the easiest thing would be to use the FontAwesome right arrow character for second arrow button rather than flipping a left arrow character. You'd also then tweak the margin and border on that button seeing as it would no longer be flipped. Leaving the coloured border on all sides and adjusting to margin-left: -12px looks good to me.
  24. This is awesome, thanks! A few things I noticed when testing: 1. After updating from a previous TracyDebugger version, the console window is only 1 line high and there's an error in the browser console. Probably a browser cache issue because if I do a hard reload the issues are gone. 2. Is it expected that clicking on a snippet that's already open in the console will open another copy of the snippet? Perhaps instead it should focus the already open tab? 3. The "Go Back" arrow never seems to become activated after executions or changes to the code. It's always greyed out for me. 4. Very minor and I think it's not a new thing, but for some reason the right arrow button is 1 pixel higher than the left arrow button.
×
×
  • Create New...