Leaderboard
Popular Content
Showing content with the highest reputation on 03/10/2021 in all areas
-
Am I the only one seeing the page id indicator on all ProcessPageEdit pages since 3.0.173 ? I guess no, since it happens on the second instance I upgraded just now as well...3 points
-
Maybe there's nothing wrong with it that needs maintaining. Alternatively you could use an ordinary text field and use a hook to validate the inputfield value: $wire->addHookAfter('InputfieldText::processInput', function(HookEvent $event) { $inputfield = $event->object; $field = $inputfield->hasField; if($field && $field->name === 'text_unique') { // Look for existing page with the field value $value = $event->wire()->sanitizer->selectorValue($inputfield->value); $existing_page = $event->wire()->pages->get("text_unique=$value, template=news_item"); if($existing_page->id) { // Show an error message $inputfield->error("Value '{$inputfield->value}' already in use on page '{$existing_page->title}'."); // Clear value $inputfield->value = ''; } } });2 points
-
Here's a somewhat versatile, albeit not overly beautiful to look at (in the backend) approach using Hanna Code. It's not really wysiwyg in the backend, but it's easier to maintain than hardcoding stuff in the template. A short step-by-step instructions (looks more complicated than it really is): Download and install Textformatter Hanna Code module Download and install Hanna Code Dialog module Go to "Setup" -> "Hanna Code" and create a new Hanna code, let's name it "languagelink", with type "PHP" and the two arguments "targetlink" and "linktext". In the "Code" tab, add the following PHP code: <?php if(! empty($targetpage)) $tgt = $pages->get($sanitizer->pagePathName($targetpage)); else $tgt = $page; $url = $tgt->localUrl($user->language); echo "<a href='{$url}'>{$linktext}</a>"; Go into the configuration of your CKEditor field. On the "Details" tab, add the Hanna Code Textformatter, which will then be applied to the field content each time it is rendered: On the Input tab, go to the CKEditor Toolbar settings and add HannaDropdown on its own line, which will add the menu entry for CKEditor: Now you have everything set up and can start inserting your languagelinks. Edit the page in question. You'll now find the menu entry "Insert Hanna tag". Click that and select "languagelink". Enter the path to the target page and the text for the link there. Your Hanna Code is now in the CKEditor field. Save the page and view it in the frontend. Page viewed in the default language: Page viewed in language "en":2 points
-
JL2 uses FastRoute to do what's being done here, although it obviously needs to hook into the 404 process in order to work. The reason I picked FastRoute was because, at the time, I simply didn't like the approach in current v1, and wanted something a little more robust, feature reach, and fast. JL2 could use this new feature (which is a great addition to PW), though some additional work would need to be done to make the URIs transform to the regex approach being used here, which is quite different. That aside, I'm afraid JL2 on hold, once again. Simply don't have the time to take it on right now, and doubtful that I will any time soon. In all honesty, I would be much happier if someone were to take the project over and give it new life. It's been in the pipeline for a long time now, and it's really come down to me making promises I uninentionally couldn't keep, much as I wanted to be able to. So, if anyone is able and willing to take it over, please feel free to pop me a DM.2 points
-
https://github.com/processwire/processwire-issues/issues/13452 points
-
ProcessWire 3.0.173 adds several new requested features and this post focuses on one of my favorites: the ability to hook into and handle ProcessWire URLs, independent of pages— https://processwire.com/blog/posts/pw-3.0.173/1 point
-
1 point
-
I had a different setup where I wanted my files served from a sub-domain (even though in the end it was from /site/assets/files), but it's somehow related. What I did was to point the sub-domain to /site/assets/files, and then add this hook in ready.php : $wire->addHookAfter("Pagefile::url", function($event) { static $n = 0; if(++$n === 1) { $file = $event->object; $url = $file->httpUrl; $host = wire("config")->httpHost; $url = str_replace("$host/site/assets/files", "sub.domain.com", $url); $event->return = $url; } $n--; }); You could replace "sub.domain.com" to "domainB.com/site/assets/files" (or even clear the "site/assets/files" part in your case). Hope it helps !1 point
-
I always use this approach: $this->wire("siteSettings", $modules->get('SettingsFactory')->getSettings('settings')); and it sets it just fine. I put it in init.php1 point
-
v0.0.35 adds the file-on-demand feature. RockMigrations is now an autoload module, which makes it available as $wire->rockmigrations and makes it possible to attach hooks for several tasks. For example we could add hooks for GIT webhooks that trigger migrations after a push to a git repository... Load files on demand from remote to local development This idea comes from a blog-post of Ryan when he introduced the multiple hooks feature in 3.0.137: https://processwire.com/blog/posts/pw-3.0.137/#on-demand-mirroring-of-remote-web-server-files-to-your-dev-environment This feature is now part of RockMigrations and setup is as easy as setting a config variable: $config->filesOnDemand = "https://www.example.com";1 point
-
I think you'll want to hook Page::editable in /site/init.php and set the event return to false if the user should not be able to edit the page.1 point
-
There's a small but important difference between wire() and $anything->wire(). The first is the wire() function defined in Functions.php and documented here. The other is the Wire::wire() method you linked to. The first one just retrieves values but can't set them. So it's more of an inconsistency between those two than a bug.1 point
-
I'm very much with @Jan Romero there. Create reservations and expire them after a while (making sure that any shopping cart entries client side are invalidated as well in that case). I'm not so sure if anything needs to be pre-created, as you'll have a race condition anyway between availability check and actual reservation. There's realy only one solution to that race condition, and that's using database transactions. Thankfully, you can just wrap your relevant PW code in $database->beginTransaction() and $database->commit() as explained here.1 point
-
This is a classical distributed systems problem: Your options are idempotency, reserving limited resources early and implementing compensation actions (e.g. compensating for missed payments by freeing the resource again). At some point it might even be useful to involve humans instead of trying to cater for each error case in code. The other part as @Jan Romero pointed out: Give whatever you sell identities. Instead of decrementing number of event tickets available create 100 tickets upfront and link them to orders. A ticket not linked is a ticket available. This is a more natural and easy to understand way of dealing with the domain. In the real world you also first print X tickets before they can be sold in retail. Same should apply to your spaces. Take that from someone having build a system similar to like you intended in a not so critical space (a handful of tickets more are not critical) and while not having completely regretted it I could soon see the problems of it.1 point
-
Ticket vendors often temporarily reserve the space as soon as it’s added to the cart. You could use that to count towards the occupied spaces and remove the reservation if the transaction isn’t finalized in time. For example you could store the time of the reservation and to calculate availabilty subtract completed bookings as well as reservations younger than 15 minutes or so.1 point
-
@adrian @bernhard I've added support for getting 'url' and 'path' from $pages->findRaw() in the latest commit, but it requires the PagePaths module be installed. Now just need multi-language URL support for that module.1 point
-
For years, as a personal project, I've been documenting my little corner of the globe via my personal website www.marlboroughonline.co.nz, which also gets used as my testbed for new ideas with ProcessWire, SEO and other stuff, as I'm not going to have some client on the phone if I break something, but if I do it well, I can earn a few dollars from Google adsense. I've always had a bit of a passion for natural history, being introduced to David Attenborough documentaries when I was a teenager, and actually studying life sciences at university, so it's only natural if you'll excuse the pun, that a part of my site would be dedicated to documenting local plant and animal species in my part of the world. For many years, one of go to reference websites for information about native plants has been New Zealand Plant Conservation Network, and I often include a link from my site to details on a species on the site as an authoritative reference, and I use the site to help identify plants I've photographed. It was only recently that for some reason I decided to have a look at the source code of the site, and it looked suspiciously like it was made with ProcessWire. After a bit more detective work, I found out that it was made by @Robin S and is indeed built with ProcessWire. To get away from the computer, I also teach kids edible gardens at my daughter's school a couple of hours a week. It's part of a wider Enviroschools programme here in NZ, and among other things it covers is teaching kids to recognise noxious weeds. There's a really useful website Weedbusters that's supported by councils and used as a reference for many invasive plant species, and it turns out it's more of Robin's handiwork. I think it's a bit funny that even when I'm supposedly away from ProcessWire engaging in other activities, it seems to follow me around. ?1 point
-
Are you sure your hook gets triggered? Always proceed step by step. I usually start with a hook that only outputs "triggered" via tracy: bd("triggered!"); If you don't see the dump in the tracy bar, your hook does not fire and you have something else wrong (and that's the case here). Try this one and then update the inner code: $wire->addHookAfter('Pages::saveReady(template=product)', function($event) { $page = $event->arguments(0); // your logic here bd("hook fired!"); }); To update your field you don't need "setAndSave", just set your field's value like this: $page->yourfield = 'yourvalue'; That's it ?1 point