Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation since 09/19/2022 in Posts

  1. This week my kids are out of school on fall break, meaning I've also been off work this week (in part at least), so it's been a quiet week for development. Nevertheless, an issue report has been resolved (thanks to matjazpotocnik), two feature requests have been added (here and here), and a bunch of minor core code improvements have been added. While there's not much more to report this week, more is on the way next week. Have a great weekend!
    14 points
  2. I am happy to announce that I will release an early beta version of my pagebuilder module PAGEGRID to selected users. The main focus of this testing is to make PAGEGRID production-ready. There is also an official website now. And a small, but growing documentation page. Both are works in progress, so expect some updates coming soon. You can find the initial post here (it's a little outdated). In order to organise this testing, I will need to gather some information via Google Forms. I need your email address in order to inform you how to access PAGEGRID as well as for other necessary communication. I will not use your email address for any other purposes nor pass it on to any third parties. You need to have an account on this forum to apply. Apply here if you want to be part of the free beta test. Please note that there is a limited number of test slots available. This form will close in 10 days.
    9 points
  3. Coming to an IntelliJ IDE (like PHPStorm) near you soon. Live Templates or snippets provide a short way to write repeating code. You enter an abbrevitation and the editor completes the code for you. Here is one example when I want to setup a new module: phpstorm64_aT7Nj2gxSv.mp4 @bernhard Has snippets for VSCode in his great RockMigrations module also, be sure to check them out, if you use VSCode. As I use RockMigrations in every PW installation I also add snippets for migrations: phpstorm64_fAD9MoUJLE.mp4
    7 points
  4. New video is out 🥳 I hope it helps to get started with RockMigrations quickly! Feedback very welcome - it's really not easy to do videos about such complex topics, so if you think something is missing let me know! Happy to hear that @netcarver 🙂
    5 points
  5. In general: Apache servers are case sensitive. A request for /directory/file will be treated as a request for a different file than one for /Directory/File. Search engine’s are case sensitive. They’re going to view /directory/file and /Directory/File as the locations of two different documents In processwire: https://processwire.com/talk/topic/23223-allow-upper-case-in-url/ https://processwire.com/blog/posts/page-name-charset-utf8/
    4 points
  6. I think the statusChanged hook is the right one for this 😉 (or statusChangeReady) Then check if the status is changed to hidden...
    3 points
  7. @nicolant, ProcessWire doesn't allow filenames to include dots, perhaps because Images fields use a dot to separate the variation suffix from the basename and Images and Files fields share some of the same code. If using dots in the filename is essential for some reason and you are willing to use an experimental module you could try this: https://github.com/Toutouwai/FieldtypeFileUnrenamed
    3 points
  8. This week we have ProcessWire 3.0.205 on the dev branch. Relative to 3.0.204, this includes 23 new commits including several refactored classes, issue resolutions, several pull requests and various new features. While there's no single major new feature to write a blog post around, there's still a lot here so for full details see the dev branch commit log. This week there's also a new module released in the ListerPro board called PageActionCrawl. This is a ListerPro PageAction module that crawls all pages sent to it. You can use this to crawl your entire site, some portion of pages within it, or even crawl external URLs referenced in URL fields. This is useful for any number of things such as priming caches, finding errors, quality assurance, doing security testing and more. Features include: Supports crawling with GET, POST or HEAD requests. Supports optional query strings and/or URL segments. Reports the HTTP response code and render time for each URL. Highlights error URLs (http code >= 400) in red. Optionally supports crawling of multiple URL variations per page. Supports inclusion of custom POST variables in POST requests. Supports page URLs or URLs stored in FieldtypeURL fields. Supports success and error hooks for custom behaviors on crawled URLs. Speaking of ListerPro actions, I've moved all of the 9 ListerPro action modules into their own new subforum of the ListerPro support board, so if you subscribe to ListerPro be sure to look for the new ListerPro Page Actions board in there. That's also where this new PageActionCrawl module is posted. Thanks for reading and have a great weekend!
    3 points
  9. I wrote that last post on a Saturday and I needed to have the new site up and running on Monday, so I ended up just using .htaccess to separate traffic into en and pt subdirectories and PHP files to create the pages. Which works, but at some point I'd still like to figure out how to do this using Processwire. Additionally I realized that in some cases the page names were the same for the two languages, whereas in others they were not (e.g., map and mapa). So I would have needed to futz with that detail as well, which didn't seem insurmountable but was another example of "square peg != round hole." Since one of the main reasons that I wanted this site in PW was to allow others to make edits and it turns out that no one else has shown any interest in doing that, I'm putting this on the shelf for a while. Thanks very much for the suggestions and info!
    2 points
  10. Hello everyone. I'm a relatively novice Processwire user so apologies if my query is easily resolved or if there have been previous posts. Can someone tell me why uppercase letters are not allowed in path names? Thanks in advance for your help.
    2 points
  11. Okay here we go 😉 "$grandparent" is NULL... checked it with a bd() And here's the Screenshot:
    2 points
  12. Hi @Nomak. Welcome to the forums. Is this a one-off? If yes, another option is to export the products (in the Products Dashboard in Shopify admin) as CSV and then use that to import the products into ProcessWire. At that point you can use the ProcessWire API + PHP to do the imports or modify the CSV and use a module such as ImportPagesCSV to import to ProcessWire.
    2 points
  13. Hi @Nomak I think you don't need to use these library to access the shopify api. Take a look at the following link: https://gist.github.com/calufa/c575b31291bb000fbf59 Gideon
    2 points
  14. Woah... i love the MagicPages Feature 🙂 (and also all the rest 😄) I'm still using v1 of RockMigrations, but i think it's time to switch to the new version 🙂 Thanks for the great video bernhard!
    2 points
  15. Thx for the feedback @dotnetic I put that into the video for everybody to see (realise) that it's really just one click to start using migrations. No other magic that needs to be done or has been prepared only for the video. Also the migrate.php file is created on install, so I thought that is an important thing for everybody to see who is not familiar with RockMigrations 🙂 Thx, happy to hear that 🙂 IMHO it is not only the best tool for migrations in ProcessWire. I've watched several videos about other migration tools in other CMSs and IMHO what we have in our PW world is much easier to use and sometimes also more powerful! The API based approach turned out to be a very reliable technique and it feels so much more natural to just add migration instructions to - for example - the migrate() of a pageclass than writing single migration files with an upgrade() and downgrade() somewhere and then end up with multiple files where you have no idea what they do (unless you inspect every single file). In RockMigrations you see what it does at first sight. And you get GIT diffs when anything changes. @netcarver do you still want to use file-based migrations or have you already changed your mind? I mean... you can also do that with RockMigrations - it's just not what I'm doing but that does not mean it's not possible or bad 🙂 Maybe there are also good reasons for such an approach, so I'm happy to get input.
    2 points
  16. RockMigrations is the best tool to do migrations with ProcessWire. It saves me so much time when creating new projects or extending older projects. Once you use it and understand it, you don't want to live without it! Thank you very much, @bernhard. Also a good video. I think you explained it very well, hopefully even for beginners. What personally nags me most in every module demonstration video out there (not only from you) is how to install a module. That is annoying to me, but might be useful for others. Gladly I can skip that part and you also added timemarks, sections to the video. Keep up the great work.
    2 points
  17. If you are a designer not a developer, then I would suggest trying to move a site from one CMS to another is a bit of an ask. If you are happy with the structure and just want to modify content, then you should be able to do that in ProcessWire without any particular technical or coding skills. If you want a new look and feel and don’t want to use a developer, then maybe start from scratch in WP, just copy and paste what content you need. That assumes that you are proficient in WP. I gave up on WP because, while it looks simple, the complexity goes up exponentially the more you try to do.
    2 points
  18. This last week my wife and daughter took a trip to NYC and it was my daughter's first time there. I was browsing around online looking at things they could do and so I visited the Guggenheim museum website to look into that option... I've always been a fan of the building, a Frank Lloyd Wright masterpiece. In addition to New York, I learned from the website that Guggenheim also has museums in Abu Dhabi, Bilbao and Venice, so I clicked through to view them as well. I really liked the Venice Guggenheim website, which had a much nicer website than the other locations. It was such a nice site that I was curious what they were running, so I viewed the source and... not WordPress (like the others), but ProcessWire. What a nice surprise. Then I was curious about who made such a nice site and there was a credits link in the bottom right corner that says the site was made by basili.co, nice work! It's always fun to come across a ProcessWire powered website randomly like that, and I thought you all would enjoy this one too. This week there are fairly minor updates on the core dev branch. Though the updates include one I've been meaning to do for a long time: improve the API for processing Inputfield forms. Previously there's been no way to check if a form is submitted, short of checking an $input variable yourself. Today I committed an update that adds a $form->isSubmitted() method that solves that, and more. It can identify which form was submitted, which submit button was used, and it also performs additional checks to make sure it's a valid submission before deciding that it's a form worth processing. It improves reliability, accuracy and security. Next week I'll be updating several of the admin forms to use it, among other updates. A few other useful helper methods were added to the Inputfield forms API as well. I realize that these updates may only be of interest to module authors, but I like keep you up-to-date with the week's updates either way. Thanks for reading and have a great weekend!
    2 points
  19. Thx to @gebeer we now have support for repeater fields in the new version of RockMigrations 😎 If you find any other features that have been implemented in RM1 that are not yet in RM2 please let me know or even better create a PR 🙂 Bumped version to 2.0.0 as I just realised that this version number fits better to how I'm referencing RM1 and RM2!
    1 point
  20. Thx! I'm happy to hear that 🙂 This is a completely recursive multi-level menu using LATTE + RockFrontend magic that should get you started 🙂 <ul class="uk-nav uk-nav-primary uk-margin-top uk-margin-large-bottom"> {* define block that is used for recursion *} {define items, $items, $first} {foreach $items as $item}{* loop all items*} {* define variables for inside the loop *} {var $active = $rockfrontend->isActive($item)} {var $subid = "tm-menu-".$item->id} {var $numc = ($item->numChildren() && $item!==$first) } {* list item markup *} <li n:class="$active ? 'uk-active'"> <a href="{$item->url}" n:attr="rf-toggle: $numc ? '#'.$subid"> {$item->title} <svg n:if="$numc" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--tabler" width="20" height="20" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m6 9l6 6l6-6"></path></svg> </a> {* list for child-items *} <ul id="{$subid}" n:if="$numc" class="uk-nav-sub" {!$active?'hidden'}> {include items, $item->children()->prepend($item), $item} </ul> </li> {/foreach} {/define} {* now include the block for the first level of items *} {include items, $home->children()} </ul>
    1 point
  21. I have a Page Reference field (ASM Select) and I am utilizing the "Custom Format" for the "Label field". However even the custom format itself is a bit limiting for a particular use case I have. Is it possible to hook into it and modify the output cleanly with PHP? I can't seem to find a proper hook. Somewhat related... it's possible to do this for the Tree page labels via ProcessPageListRender::getPageLabel.
    1 point
  22. Hi @alexm, This is now possible in version 006 released today. You can hook into PadloperProcessOrder::getOrderCustomer. Demo code is here including comments in the code and a README. Give us a shout if you need further help with it.
    1 point
  23. Guys, You should try www.findip.net Unlimited free use. Very easy to use. You can thank me later :)
    1 point
  24. Out of curiosity, which version of PW are you using? PW auto-corrects the rotation, and some issues related to this were fixed in version 3.0.197. Just wondering if updating to the latest stable version (3.0.200), for an example, would resolve this problem. My understanding is that PW doesn't remove EXIF data from uploaded image, just resized images — though I could be wrong here! One exception at least is that if you have configured a max image size for your image field, then it will be automatically resized after being uploaded, which means that PW no longer has any version of it with EXIF data in place. Anyway, I'm not sure which one you're talking about here: original uploaded image, or a PW generated size variation of it? If it's the latter, then currently there's no way to retain EXIF data, but the image should still be automatically rotated according to what was in said EXIF data. (There is an open issue about keeping EXIF data, at least in some cases, but no clear solution yet: https://github.com/processwire/processwire-issues/issues/1055.)
    1 point
  25. @Gideon So Thanks for that input, I didn't know that the API can be accessed also by much simpler scripts withou using the library. @kongondo No, it's not one-off. The product import should be each 15 minutes or so via cronjob. I have edited my post to explain it better.
    1 point
  26. Oh yeah, finally 🙂 I just prefer to use PHPStorm than VSCode 😉
    1 point
  27. Just the ProcessWire Code, I have to transform everything manually. Sadly IntelliJ has a weird format for the live templates which are stored in an XML file. Sharing and importing isn't also as easy as copying the files to the root directory. Instead you have to import them as settings for the IDE and restart the IDE afterwards. Live templates are a native function of PHPStorm, I think they were a thing before they existed in VSCode. It is somewhat similar to snippets in VSCode. You have your code and then enter $myvariable$ for inserting user text, or things like $boolean$ or $enum$ and can define values for that.
    1 point
  28. @bernhard This is the function in the module file: <?php /** * Get changed watchfiles * @return array */ public function getChangedFiles() { $changed = []; foreach ($this->watchlist as $file) { // remove the hash from file path // hashes are needed for multiple callbacks living on the same file $path = explode(":", $file->path)[0]; $m = filemtime($path); /////////// LINE 1282 if ($m > $this->lastrun) { $changed[] = $file->path; $file->changed = true; } } return $changed; } It's this Line: $path = explode(":", $file->path)[0]; Explode the Path -> it's just C (should be "'C:/apache2/htdocs/site/migrate.php'") When i remove the explode the "C" Error is gone, but the repeater error remains.
    1 point
  29. Yes, you have to make some test on your side to understand better, but that is not very complicated once you get the "flow". On your example, you can paste my code chunk - if ($config->ajax)... - on your template that refer to the page /all/ and then in the click $.post call, just put the url from $pages->get('/all/')->url, it should work out of the box. PS: If it's a "fun" project, and could be open-source, do not hesitate to export the site-profile to be available to us, it rocks really lol
    1 point
  30. Re leaking: I believe nginx uses the request url as the cache key and that only GET requests are cached (not sure about OPTIONS or HEAD). So if you have caching enabled and a logged in user, Wilma, requests /processwire/user to see their profile, the next user, logged in or not, will also see Wilma's record. Typically it's ok to disable caching for logged in users, and/or you can also disable caching on certain urls (or patterns of url) that you know to be sensitive. Don't know if this is helpful or not, but here's the sort of thing I use for Drupal. map $http_cookie $session_cookie_set { default 0; ~SESS 1; # PHP session cookie } ## Identify ajax requests so we can choose to not cache them map $uri $is_drupal_ajax_request { default 0; /system/ajax 1; } # ... then in your server block ... fastcgi_cache_bypass $session_cookie_set $arg_nocache $is_drupal_ajax_request; fastcgi_no_cache $session_cookie_set $arg_nocache $is_drupal_ajax_request; What this does is: set up a variable `$session_cookie_set` which will be 1 if there is a PHP Session cookie in the request Set up a variable `$is_drupal_ajax_request` if the path is `/system/ajax` (a special path for drupal, but you can add your own var name and url patterns in here for your own use/processwire uses). Tells nginx to bypass and not cache results if any of these, or the `nocache` URL query variable is set. I'm keen to use pw with nginx because .htaccess is ineffficient (from what I've read) and because I get on better with the reasoning of nginx's config; it seems to have fewer quirks than apache!
    1 point
  31. PAGEGRID Preview This is a sneak preview of a side project I've been working on for quite some time now. A lot of work and thought has gone into this, so I will most likely release this as a commercial module at some point in the near future. As a designer (and developer) I get the appeal of a WYSIWYG editor. After playing around with some WYSIWYG page builder tools, I always felt something was wrong about them. So I decided to build my own PW version based on PageTable (it's no longer based on PageTable, but still has some similarities). Here is a small demo (using AdminThemeCanvas, but its working with other admin themes as well) : There is also a complete website that I built for a friend of mine using this module and some custom blocks. Concept This fieldtype shares a lot of features with PageTableExtended: it's also an extension of PageTable and renders the block templates in the backend and frontend (native PW templates and fields). You can also add your own css via module settings. The difference is, this fieldtype also gives you the ability to rearrange and resize elements in a visual way as well as enable inline editing for text, ckeditor and file fields. Similar (and promising) attempts have been made, but I wanted something based on native CSS grid instead of a CSS framework...so I built my own version. Most CSS frameworks are based on flexbox, which is great for layouting elements horizontally. With CSS grid, you can place elements horizontally and vertically, allowing for layouts that were not previously possible with CSS. Similar to webflow, this fieldtype uses javascript (in the backend) to let you manipulate CSS grid in a visual way to design fully responsive websites (or parts of them). It should still be possible to include a CSS framework if you like (just add the classes to your block markup and include the CSS via module settings). The CSS grid layout manipulations are saved in a single field as a JSON array and used to generate a dynamic stylesheet that you simply include in your main template (no inline styles). The styles are saved within the breakpoint you select and cascade down to smaller breakpoints. That means you can specify just the basic breakpoint and adjust other breakpoints if needed. The exception is the mobile breakpoint which will display everything in one column as a default (you can change the layout here too). The fieldtype also comes with an optional style panel to manipulate some additional CSS properties directly on the page. You can customize the panel or disable it completely from the module settings (and just use a CSS file that you include via module settings). The style panel is based on inputfields (nothing is saved to the database). This means that you just have to install the module and all fields are available to all blocks automatically (this can be customized). It also has the benefit that your installation is not flooded with fields; this module only installs one field. Don't want to give your customer all that power? Design features can be disabled for certain roles. The grid editor role can just edit the content and use the inline editing feature to edit content quickly. You can then also grant access individually to the style panel, resize or drag functionality. Features Blocks are just pages Blocks are defined by native PW templates and fields Manipulate CSS grid in a visual way to design fully responsive websites (or parts of them) Design features can be disabled for certain roles Inline editing of text, ckeditor and file fields The layout is 100% CSS grid (very small css file size) Simply drag and resize to manipulate grid items directly inside the backend Manipulate grid columns and rows directly on the page (use any number of columns you want) All style manipulations are saved as JSON and used to generate a dynamic stylesheet that you just include in your main template (no inline styles) Nested groups/grids (child pages of nested blocks are created under group parent) Global blocks work with page reference field (changes on one page, changes all blocks on all pages) Manual and auto placement of grid items Define custom icons for your blocks via native template settings (template -> advanced -> icon) Option to load lazysizes in the backend to enable lazy loading of assets with class lazyload Works with all default and ui-kit based admin themes If you have any questions or feedback, let me know.
    1 point
  32. Hello! First to say, thanks for your great work. I have a mulitlanguage site setup and if I log out as user I have following error message: I can't find a solution for that. Thanks for your help!
    1 point
  33. @MarkE More options/tools are always great. But there might be some overlapping between our modules, I will send you a test version and you can see for yourself. PAGEGRID is no longer limited to CSS grid, it also supports flexbox and most common CSS properties. It's like ProcessWire and webflow had a baby, but that baby is still very young 😛 Maybe this?
    1 point
  34. I was just starting to develop something similar, based on CSS grid, which I think is the right way to go. One thing my design has is “pro-forma” pages - ie pages with pre-defined layout and dummy content that you can use to create similar pages. This is an approach I have taken before for “standard letters” and works well. Not sure if that’s in your module @jploch, but I’m hoping I could easily add it. Anyway, I’ll hold off now and test yours, if I may. I have a project I was going to use which is a WP conversion with a simple theme, which I hope makes a reasonable test bed. I’ll also look into how well my (json-based) DbMigrate module plays with it.
    1 point
  35. Hey @maetmar I'm not sure there is an easy way to add this to the module... The problem is that I need to use the render() method of the module somewhere to make a _main.LATTE file work. But you can easily just use your _main.php file to just render a _main.latte file. I think the module could not make this process any easier, because at least you'd need to adjust the setting of $config->appendTemplateFile which is the same amount of work as just adding "echo $rockfrontend->render('_main.latte')" in _main.php ? Does that make sense?
    1 point
  36. Hi @bilioso You need to set it in the image field setting. You can find the setting in the "Input" tab. Gideon
    1 point
  37. I understand, and my point to suggest you to ask @ryan directly if his pro module can fit your needs, is because ryan is used to give more flexibility instead of locking the user to a finished functionality. I mean, there is maybe some hooks that can be used to link things to an user. Without speaking about that you benefit ryan's code and insight 👍 Anyway, I will might buy it for a project and could give more feedbacks. Stay tuned.
    1 point
  38. That's of course true, but it would still be interesting to hear. For example if the reason is that the ProcessWire page is slow and a WordPress site would be faster, than that would be a wrong assumption and making the ProcessWire site faster would be maybe two hours of work while migrating the site to WordPress would easily be multitude of that... 23.4MB for the homepage is really not a good value and just by optimising your slider images (which should be as easy as using $img->maxSize(...)->url instead of just outputting the image in its original resolution via $img->url what your site is doing) you are able to speed up the site significantly. Then purchase and install ProCache and your site is insanely fast. That might be all you need. Because I think the design is nice and it also looks nice on mobile. So why throw that in the bin? If there are other reasons then these optimisations might be irrelevant of course. So it would be nice to hear your reasons 🙂
    1 point
  39. A few new additions to this old module, available as of version 1.8.0 (session.txt import) and 1.9.0 (new API methods): There's an option in ProcessLoginHistoryHooks module config to import login history from session.txt. This can be useful when adding this module to a site with existing history, since ProcessWire (by default) collects data about successful/unsuccessful login attempts to said log file. This option is intentionally hidden under collapsed "advanced" fieldset. It's not super well tested yet, could result in a very slow request in case there's a lot of data to import, and in case disk timezone is different than the one in database duplicate records may be created on first run. $this->modules->get('ProcessLoginHistoryHooks')->getUserLoginHistory($user, $start, $limit, $login_was_successful) returns login history data for provided ProcessWire User object. Default values are 0 for "start", 2 for "limit", and 1 for "login_was_successful", which means that by default this method will return latest successful login and the one before that. Return value is always an array; in case there are no results, an empty array is returned. $user->getLoginHistory($start, $limit, $login_was_successful) does the same as previous command for a specific User object. All arguments are optional. This method returns a single timestamp (when limit is 1, or an integer value is provided for the "start" argument and "limit" argument is omitted), an array of login history, or null in case there are no results. By default timestamps for last two successful logins are returned.
    1 point
  40. This week on the core dev branch we’ve got some major refactoring in the Page class. Unless I broke anything in the process, it should be more efficient and use less memory than before. But a few of useful new methods for getting page fields were added in the process. (A couple of these were also to answer feature request #453). Dot syntax You may have heard of dot-syntax for getting page fields, such as $pages->get('parent.title') where “parent” can be any field and “title” can be any field that has subfields. This is something that ProcessWire has supported for a long time, but it doesn’t get used much because it was disabled when output formatting was on. So it wasn’t something you could really count on always being there. Now you can — it is enabled all of the time. But it’s also been rewritten to be more powerful. When using dot syntax with a multi-value field (i.e. any kind of WireArray value) you can also specify field_name.first to get just the first value or field_name.last to get just the last value. i.e. $page->get('categories.first'); will take a value that was going to be a PageArray (‘categories’) and return just the first Page from it. Bracket syntax With bracket syntax you can call $page->get('field_name[]') with the (‘[]’ brackets at the end) and it will always return the appropriate array value for the type, whether a PageArray, WireArray, Pagefiles/Pageimages, or regular PHP array, etc. This is useful in cases where you know you’ll want a value you can foreach/iterate. Maybe you’ve got a Page field that set set to contain just 1 page, or maybe you’ve got a File/Image field set to contain just 1 file. But you want some way to treat all of your page or file/image fields the same, just append “[]” to the field name in your $page->get() call and you’ll always get an array-type value, regardless of the field settings. This bracket syntax can also be used for getting 1 value by index number. Let’s say you’ve got a page field named “categories” that contains multiple pages. If you want to get just the first, you can just call $page->get('categories[0]'); If you want to get the second, you can do $page->get('categories[1]'); This works whether the field is set to contain just one value or many values. Using the first index [0] is a good way to ensure you get 1 item when you may not know whether the field is a single-value or multi-value field. Another thing you can do with the bracket syntax is put a selector in it to filter a multi-value field right in the $page->get() call. Let’s say you want all categories that have the word “design” in the name. You can call $page->get('categories[title%=design]'); If you want just the first, then $page->get('categories[title%=design][0]'); What’s useful about using selectors in brackets is that this does a filter at the database-level rather than loading the entire ‘categories’ field in memory and then filtering it. Meaning it's a lot more memory efficient than doing a $page->get('categories')->find('title%=design'); In this way, it’s similar to the already-supported option to use a field name as a method call, for instance ProcessWire supports $page->field_name('selector'); to achieve a similar result. Dot syntax and bracket syntax together You can use all of these features together. Here’s a few examples from the updated $page->get() phpdocs: // get value guaranteed to be iterable (array, WireArray, or derived) $images = $page->get('image[]'); // Pageimages $categories = $page->get('category[]'); // PageArray // get item by position/index, returns 1 item whether field is single or multi value $file = $page->get('files[0]'); // get first file (or null if files is empty) $file = $page->get('files.first'); // same as above $file = $page->get('files.last'); // get last file $file = $page->get('files[1]'); // get 2nd file (or null if there isn't one) // get titles from Page reference field categories in an array $titles = $page->get('categories.title'); // array of titles $title = $page->get('categories[0].title'); // string of just first title // you can also use a selector in [brackets] for a filtered value // example: get categories with titles matching text 'design' $categories = $page->get('categories[title%=design]'); // PageArray $category = $page->get('categories[title%=design][0]'); // Page or null $titles = $page->get('categories[title%=design].title'); // array of strings $title = $page->get('categories[title%=design].title[0]'); // string or null // remember curly brackets? You can use dot syntax in there too… echo $page->get('Page “{title}” has {categories.count} total categories'); I’m not going to bump the version number this week because a lot of code was updated or added and I’d like to test it for another week before bumping the version number (since it triggers the upgrades module to notify people). But if you decide to upgrade now, please let me know how it works for you or if you run into any issues. Thanks for reading, have a great weekend!
    1 point
  41. Are you on the latest version? That looks very similar to the error I mentioned above.
    1 point
  42. Hi @Youbility, yes I did. It's working on production at https://www.brightline.org/ Here's a slightly different version of that one: https://gist.github.com/sjardim/d74fae71b5bfe6a44ab88efc9aaa5279 Hope that helps!
    1 point
  43. Don't know if anything changed since 2017 and just found this post by coincidence but wanted to show how this can be done easily now in 2020 😉 $wire->addHookAfter('ProcessPageEdit::getSubmitActions', function(HookEvent $event) { $actions = $event->return; $actions[] = [ 'value' => 'foo', 'icon' => 'check', 'label' => 'foo', ]; $event->return = $actions; }); The value of the clicked submit action is stored in $input->post->_after_submit_action (you can hook Pages::saved or ProcessPageEdit::processInput)
    1 point
  44. Example with a multidimensional array. RepeaterMatrix fieldname = 'fieldname' first level: page where the repeater field lives in, indexed by ID second level: per page repeater items indexed by ID third level: field inside repeater indexed by name $rp = $pages->find('fieldname.count>0'); $return = []; foreach ($rp as $p) { $return[$p->id] = []; // RepeaterMatrixPageArray foreach ($p->fieldname as $item) { if ($item->type != 'basic') continue; $return[$p->id][$item->id] = []; // RepeaterMatrixPage foreach ($item->template->fields as $repeaterField) { if ($repeaterField == 'repeater_matrix_type') continue; // we do not need this if ($item->$repeaterField === '') continue; // if you want to ignore empty strings $return[$p->id][$item->id]["$repeaterField"] = $item->$repeaterField; } // remove if empty if (empty($return[$p->id][$item->id])) unset($return[$p->id][$item->id]); } // remove if empty if (empty($return[$p->id])) unset($return[$p->id]); } var_dump($return);
    1 point
  45. @Elchin, try: $results = $page->children("date<today, (date_end>today), (date_end=''), sort=-date, limit=12"); You can use "today" in place of your timestamp.
    1 point
  46. That result in a 500 server error. I changed it to the following and now I'm getting the proper time on backend's creation, modification, installation times etc. $config->dbInitCommand = "SET NAMES '{charset}', time_zone = '+02:00' "; Your DatetimeAdvanced module helped me with that 🙂
    1 point
  47. The ID of trash is 7, not 49. Depending on your need, you could do: $untrashedPages = $pages->find("template=some-template, status<" . Page::statusTrash); //$untrashedPages = $pages->find("template=some-template, has_parent!=7"); //$untrashedPages = $pages->find("template=some-template, has_parent!=" . $config->trashPageID); FYI, statusTrash = 8192
    1 point
  48. Adding to @Macrura's suggestion: rather than do the preg_replace and str_replace to remove the unwanted doctype, body, etc, you can avoid those by using an options parameter for loadHTML(): $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
    1 point
×
×
  • Create New...