Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/24/2023 in all areas

  1. Instead of the nested foreach you could do foreach ($tags as $tag) { $usage = $matches->find("tax_tag={$tag}")->count; $label = "{$tag->get('title')} {$usage}"; … } As for optimizing speed, how many pages are there potentially in $matches and in $tags, hundreds or thousands? To speed up queries, you can use $pages->findRaw() and only get the properties that you need for output and then work with those arrays in memory. Example: // find all pages with template document that have a tax_tag assigned // returns associative array indexed by page id with fields title, body and tax_tag where tax_tag is an associative array indexed by tax tag id with fields id and title // [ // 1234 => [ // 'title' => 'Page title', // 'body' => 'Page body content', // 'tax_tag' => [ // 4567 => [ // 'id' => 4567, // 'title' => 'Tax tag title', // ], // ... // ], // ], // ... // ] $matches = $pages->findRaw("template=document, tax_tag!=''", ['title', 'body', 'tax_tag' => ['id', 'title']]); Now you can use the resulting associative array $matches and do operations on it in memory without further DB calls. If you want to get a unique array of tags with usage count that are inside $matches, you could do something like this: // loop through matches to construct available tags array $tagsAvailable = array(); foreach($matches as $m) { // loop through tax_tags of each item foreach($m['tax_tag'] as $key => $tag) { // if key found in $tagsAvailable, tag is already there and we continue if(array_key_exists($key, $tagsAvailable)) continue; // get count of occurences of tax_tag id inside $matches items // and assign count as field 'usage' to the tag $tag['usage'] = count(array_filter(array_column($matches, 'tax_tag'), function($arr) use($key) { return in_array($key, array_keys($arr)); })); // add tag to available $tags $tagsAvailable[$key] = $tag; } } $tagsAvailable will look somewhat like this [ 1137 => [ 'id' => 1137, 'title' => 'Tag Title 1', 'usage' => 4, ], 1140 => [ 'id' => 1140, 'title' => 'Tag Title 2', 'usage' => 7, ], ] Now you can use $tagsAvailable to render your tags and $matches to render your result list. EDIT: I did this with $matches only containing 22 items and $tagsAvilable resulting in 5 items and the whole operation took 0.01ms and used 2.6kB of memory. So this should scale to hundreds or even thousands of matches. Though if you have that many matches you might consider chunk processing and paginating them.
    5 points
  2. This is a reissue of a module of mine called "PublishingOptions", that I wrote a while ago. The big difference is that this module is written in PHP 8 and has some nice additional features. The old module could only publish and unpublish pages depending on date and time settings, but the new version goes much further. So you can decide what should happen after the publication end date has been reached. You have the following options: Unpublish the page - this is what the old version did Move the page to trash - new Delete the page permanently- new Move the page to a new position in the page tree - new The last option will be interesting if you want to move the page fe to an archive after a certain date. You can select the new parent page and after the publication end date has been reached, the page will be moved under the new parent page. You will find a more detailed instruction and download possibility at https://github.com/juergenweb/JkPublishPages This module is Alpha stage and should be tested carefully before using it on live sites. I have planned to add this module to the PW module download section, so everyone is invited to test it out and to report issues directly at GitHub. Thanx
    4 points
  3. Thanks @Robin S for the report and fix. It's in the latest version.
    2 points
  4. Thanks guys, I've added a config setting for the z-index of the topbar and changed the default from 99 to 999 πŸ™‚
    2 points
  5. Good morning @gebeer, that looks promising – so far I didn't make the step to use the findRaw() but I will – looks like a huge potential to get my search run better. Thank you so much for your detailed examples. I will definitely dive into that and try to use it further up in my data collecting process. Btw. its about 650 documents and 430 tags. For now I just tried your 1-liner… Result: 1:4! The nested if takes avg 0.28s, your version 0.07s – now found 423 matches takes 30s instead of 120s for building the cache file (on my slow local machine). Looks like a good start for today – thank you @gebeer!
    2 points
  6. This week we've got ProcessWire 3.0.211 on the dev branch. Relative to the current main/master version (3.0.210), this version is 20 commits ahead. Many of the additions are user-submitted pull requests, and there are also several minor issue fixes too. Full details can be found in the dev branch commit log. I'd been planning on merging InputfieldTinyMCE into the core on the dev branch almost right away, but with so many minor fixes and improvements being added (that don't need much testing) we may put out another main/master version first in the short term, and then merge in InputfieldTinyMCE. Thanks for reading and have a great weekend!
    2 points
  7. Gone! The best spam is the one that starts nice discussions πŸ˜‰
    1 point
  8. No, it should work with 8.0, but not below. I have not checked it directly on my local server, but PHP-Storm does not complain after changing the version. I have changed the version on GitHub too, but you do not need to download it again. Please let me know, if something unexpected occurs, but I guess it will not.... BTW: In the module configuration settings set the CronJob interval to 1 minute for testing purposes, so you can check the functionality immediately. Later on, setting the value to 1 hour again, will be enough. Best regards
    1 point
  9. Glad to hear that! πŸ˜€ Let me know, if you discover any issues. I will add this as soon as possible to the ProcessWire module directory, but as written, it needs to be tested first by several people.
    1 point
  10. Hi @Stefanowitsch it should show this: I'm not sure about the logo there and am open to feedback.
    1 point
  11. Cool! I've been searching for a module like this. This comes in handy when users are preparing blog/news articles and want them to be published automatically on a specific date. I will definitely try it out.
    1 point
  12. Hi @adrian, The "Delete Unused Templates" action is throwing an error for me in recent PW versions: Maybe related to this change mentioned in the 3.0.210 release blog post? Update: adding an if($fieldgroup) test to the action seems to resolve it... if($fieldgroup) $this->wire('fieldgroups')->delete($fieldgroup);
    1 point
  13. Ahoy! Turns out Dreamhost updated my VPN and changed my hostname and dedicated IP, and I didn't get the email where they let me know those facts πŸ™‚ Still took some figuring out to get things working with Cloudflare again, but it's all working again, and as usual, none of the issues were Processwire's fault! Thanks @elabx for jumping in!
    1 point
  14. Hello ProcessWire Community, It is with great pleasure that I share with you the new site for our company Strangeloop Studios, a visual design lab and animation studio based in Los Angeles. We specialize in content for musical artists but have branched into VR, Broadcast, and Music Video projects as well. This is my first site using ProcessWire. I went from complete PW beginner (October 2022) to this re-design and catalog of our various projects in the space of several months. Lurking here on the forums and visiting all of the stellar work that gets shared on the Showcases has taught me a lot. Many thanks to @bernhard for the Rockfrontend module, and @flydev for their Duplicator module. I probably wouldn't have been able to get this far without those … so, many thanks for your contributions! I also appreciate the feedback to my questions in the forums from several users who have improved my understanding of PW with detailed explanations. Things I would like to improve: optimizations for image delivery Multi-language support Looking forward to building more with ProcessWire! Cheers,
    1 point
  15. Last week we released ProcessWire 3.0.210 main/master and it's been a very smooth launch. No new issues have appeared and all upgrade reports have been good so far. If you haven't yet upgraded I'd encourage you to. Last week's post covered a lot of what's new, in case you haven't seen it yet. Also be sure to check out the ProcessWire Weekly coverage of this new version. This week I've been focused on getting caught up with some client work but there have also been a few minor commits on the dev branch, with more on the way. I hope that you have a great weekend!
    1 point
  16. Just wanted to share the simplest language switcher possible if you only have two languages: <a href="<?= $page->localUrl($languages->findOther()->first()) ?>">DE/EN</a> 😎🀘
    1 point
  17. I think it's probably too rare of a need to add to BatchChildEditor, but happy to have it in AdminActions. Just committed it to the latest version.
    1 point
  18. I'm in the web design since 1998, and I remember when the war against inline styles began, you put a little style="margin-bottom:10px" in a unique element in the project and you are a renegade man from the old days, you need to create a new css class for it ... after decades learning to avoid them at all cost.. now in 2017 the new trend that coder influencers propose as good modern practices (because of React, etc) is using it! you get this and is OK.. Whaaat? !! ..hahaha.. the previous was a joke.. but seriously.. the best practice is to be practical, logic and simple always as @BitPoet said
    1 point
  19. I'm very interested why foremost it's age is a good reason to turn away from jQuery. It's no new cool kid on the block, but it is matured, very well documented and wide spread. It was no "dead end" like some of the other "cool" JS frameworks have been. It feels like a good ol' companion. It's not the right tool for every job nor a holy grail, but in pretty much use cases it works well and affordable in a sense that there is no steep learning curve.
    1 point
Γ—
Γ—
  • Create New...