Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/10/2021 in all areas

  1. Great to see those core things evolving. Someone has to look after them. And we all know who that is))
    3 points
  2. This week I kept working on what's been in progress the last couple of weeks. That wasn't really the plan, as I was hoping to move on to other parts of the core. But I found it a took a lot of time to adjust everything to the new code and classes, and to refactor and remove other chunks of code that could either be simplified or removed. So these last few weeks of updates took a lot more time than I expected, and it's one of those things where once I got into it I felt I had to keep working until it was done as well as it could be. That meant getting pretty deep into some core logic. So in hindsight I'm slightly regretting refactoring so much code without major short-term benefits that can make more interesting reading here. And there are perhaps some short-term drawbacks in potentially introducing new bugs, as goes with any new code. But that's how it is sometimes. The good news is that it's a definite improvement in quality and I have no doubt there will be long term benefits especially in terms of improved performance and maintainability. But in any case, I'm glad to be wrapping up these particular updates so that I can move on to other parts of the core and Pro modules, and hopefully I'll have more interesting stuff to write about next time. One small addition you might find useful in these updates is that you can now identify the closest matching page when a 404 occurs. Maybe you want to provide a hint to users that land on a 404 as to what page they might have been looking for. Now you can do this in your 404 page template file: $p = $pages->request()->getClosestPage(); if($p->id > 1) { echo "<p>Were you looking for <a href='$p->url'>$p->title</a>?</p>"; } Like last week I'm not bumping the dev branch core version just yet because I don't want to trigger any upgrade alerts that might prompt people to upgrade immediately. I'd rather focus more on testing and leave these updates to those that are interested in that testing, helping to track down any issues. Thanks in advance for your help with testing these updates. Likewise, thanks for reading, I hope you have a great weekend!
    2 points
  3. I was talking about Ryan. He is the one looking after the core (and everything really). Just wrote that post to let him know I am thankful he does.
    2 points
  4. Repeater Easy Sort Adds a compact "easy-sort" mode to Repeater and Repeater Matrix, making those fields easier to sort when there are a large number of items. The module also enhances Repeater Matrix by allowing a colour to be set for each matrix type. This colour is used in the item headers and in the "add new" links, to help visually distinguish different matrix types in the inputfield. Screencasts A Repeater field A Repeater Matrix field with custom header colours Easy-sort mode There are two ways to enter easy-sort mode. 1. Click the double-arrow in a Repeater item header. This activates easy-sort mode and also highlights the item with a black background so it's easier to find it in easy-sort mode. 2. Click the horizontal ellipsis icon in the Repeater field header to activate easy-sort mode. To return to normal mode click the vertical ellipsis icon. While in easy-sort mode: The items will reduce in width so that more items can be shown on the screen at once. The minimum width is configurable in the field settings. Any items that were in an open state are collapsed, but when you exit easy-sort mode the previously open items will be reopened. You can drag an item left/right/up/down to sort it within the items. You can click an item header to open the item. An "Exit easy-sort mode" button appears at the bottom of the inputfield. Configuration In the field settings for Repeater and Repeater Matrix fields you can define a minimum width in pixels for items in easy-sort mode. While in easy-sort mode the items will be sized to neatly fill the available width on any screen size but will never be narrower than the width you set here. If desired you can enable easy-sort mode for a field by default. Since easy-sort is then the default mode for the field no "Exit easy-sort mode" button is shown. Use the mode buttons in the field header to change between easy-sort and normal mode when needed. In the field settings for Repeater Matrix you can define a custom header colour for each matrix type using an HTML "color" type input. The default colour for this type of input is black, so when black is selected in the input it means that no custom colour will be applied to the header. Exclusions The easy-sort mode is only possible on Repeater/Matrix fields that do not use the "item depth" option. https://github.com/Toutouwai/RepeaterEasySort https://processwire.com/modules/repeater-easy-sort/
    1 point
  5. Added some useful functions to FieldtypeColor class: /** * Find the "naive" difference between two colors. * @param int[] $color_a Three-element array with R,G,B color values 0-255. * @param int[] $color_b Three-element array with R,G,B color values 0-255. * @return int */ public function getColorDistance(array $color_a, array $color_b) /** * Find the difference between two colors' luminance values. * @param int[] $color_a Three-element array with R,G,B color values 0-255. * @param int[] $color_b Three-element array with R,G,B color values 0-255. * @return int */ public function getLuminanceDistance(array $color_a, array $color_b) /** * Find the closest named color * @param hexcolor 6 or 8 digits, with or without leading '#' * @return string */ public function getClosestColorName(string $color) Usage example: $fc = $modules->get('FieldtypeColor'); $colorname = $fc->getClosestColorName('#01fb99'); var_dump($colorname); // string(17) "MediumSpringGreen" I needed this for the COLOR property in .ics file type. According to the specifications, the value must be a valid CSS3 color name. https://icalendar.org/New-Properties-for-iCalendar-RFC-7986/5-9-color-property.html
    1 point
  6. Thank you @ukyo and @elabx this is exactly what I needed. I really tried to read through the API before asking, mainly because I didn't understand the relationship / order between everything. You guys are great!
    1 point
  7. Ooh. Than I've thought to complicated. ?
    1 point
  8. Basically <?php namespace ProcessWire; // create field $field = new Field(); $field->name = 'my_field'; $field->label = 'My Field'; $field->type = 'FieldtypeText'; // save field wire('fields')->save($field); // get field $field = wire('fields')->get('my_field'); // Create fieldgroup $fieldgroup = new Fieldgroup(); // if you want to edit fields in this field group via admin panel, name need to be same with template name $fieldgroup->name = 'my_template'; $fieldgroup->add('title'); $fieldgroup->add('body'); $fieldgroup->add($field); // save fieldgroup wire('fieldgroups')->save($fieldgroup); // get fieldgroup $fieldgroup = wire('fieldgroups')->get('my_template'); // Create template $template = new Template(); $template->name = 'my_template'; $template->label = 'My Template'; $template->fieldgroup = $fieldgroup; // save template wire('templates')->save($template); // get template $template = wire('templates')->get('my_template');
    1 point
  9. @Clarity @Jonathan Lahijani I pushed a fix, can u update next branch and try ? Entering language based data, Exporting and importing Mystique field data Video result Ekran Kaydı 2021-10-08 22.46.51.mov
    1 point
  10. Depending on what you are doing with the pages, you could do a $pages->findRaw($selector,$fields); instead.
    1 point
  11. Right - as part of my efforts to show off more of the work we've done recently, here's a site we launched earlier this year. On The Record are a not-for-profit that specialise in oral histories and creative media. We've done a few nice projects with them ( A Hackney Autobiography was a lovely project we did with them in our pre PW days). A creative design was very important to them as well as being accessible and usable. There's not too much bespoke backend coding going on. We needed to provide them with a way of easily adding audio and video files but that was mostly done using normal fields and a modified version of Ryan's TextformatterVideoEmbed module adapted for use on plain text fields. Apart from that, it's just the usual supects for extra modules: ProCache LoginPersist and Macrura's ProcessDocumention module which we normally use for provide help pages in the admin area. The front end is pretty much bespoke but with a few components lifted from various places; looks like we used Bootstrap grid for one. It's another site where we used CSS filter properties to apply a consistent look and feel to images the client uploads. I think it looks nice anyway and the client is very happy with it and took to using the PW admin with no problems.
    1 point
  12. See the attachment for the job posting. Contact information is in the posting. 2021-10 Lead Web Programmer.pdf
    1 point
  13. Thunder Client — lightweight alternative to Postman Thunder Client is a lightweight Rest API Client Extension for Visual Studio Code (it is not open-source). Launch article Quick demo
    1 point
  14. knowing page categories and child pages - or the usage of templates and pages as contentcontainers for everthing you ned - is essestiel!! this is a great startpoint for learn this very very important thing - processwire manage the content you need - with simple PHP solutions you get get the content in your templates...i created a complete blog logic without a special module or something else - but you have to know to use pages and fields and learn this things.
    1 point
  15. Hi, depending on why and/or where those pieces of code are displayed or not, it could be easy to do this with php for example, if one of these piece of code is displayed when/if the page is a child of some page or template, easy to have a php if based on the parent template or id another way to do this, safe if it is your website, meaning some education if it is a client's one... would be to use toggles for the template "display this... yes/no", once more a simple check on the toggle value with php, job done (i've used this solution for a client who wanted some pages to be published, not hidden => in the sitemap but not always in the menu pw and php are great friends ? have a nice day
    1 point
  16. @rsi you can use $pages->sort() to set the sort value of the new page to zero after it is added, and that will make it appear at the top of its siblings but still be manually sortable. In /site/ready.php: $pages->addHookAfter('added', function(HookEvent $event) { $pages = $event->object; // The page that is being added $page = $event->arguments(0); // If the page passes some kind of test if($page->template == 'news_item') { // Set the sort value for the new page to zero (sibling sort will be automatically adjusted) $pages->sort($page, 0); } });
    1 point
×
×
  • Create New...