Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/15/2020 in all areas

  1. FYI, there is an open issue on this topic: https://github.com/processwire/processwire-issues/issues/1116 Here is a hook you can try in /site/init.php: $wire->addHookAfter('ProcessPageView::pageNotFound', function(HookEvent $event) { $url = $event->arguments(1); $pages = $event->wire()->pages; // Explode the URL to pieces, with an upper limit of 10 $pieces = explode('/', trim($url, '/'), 10); $redirect_page = $pages->newNullPage(); $segments = []; // Find closest real page, utilising PagePathHistory while($pieces && !$redirect_page->id) { $segments[] = array_pop($pieces); $path = '/' . implode('/', $pieces) . '/'; $redirect_page = $pages->getByPath($path, ['useHistory' => true]); } // If a page is found and the page's template allows URL segments // then redirect to it, adding back the potential URL segments if($redirect_page->id && $redirect_page->template->urlSegments) { $redirect_path = $redirect_page->url . implode('/', $segments) . '/'; $event->wire()->session->redirect($redirect_path); } });
    2 points
  2. @jploch - I have committed those changes to the Tracy repo - let me know if it needs any tweaks.
    2 points
  3. I will send out an expression of interest request nearer the time. I haven't yet decided on a criteria for selection. Current plan is PayPal IPN due to its multi-notifications types. However, I may also do PDT, but not 100% sure at this time. No decisions made yet regarding Stripe's implementation. All frontend implementation is up to the developer. You will have the API at your disposal to do whatever you need to do. In the backend/model, orders can have different status (paid, unpaid, complete, partial, etc). Order line items also have individual status (returned, delayed, refunded, etc). This means you should be able to implement a pre-order feature yourself by, for example, marking an order as unpaid, in progress, etc. Padloper 2 does not render anything in the frontend. It is like ProcessWire. There will be no more in-built Padloper templates. You implement Padloper 2 however you wish using the API. I will, however, as part of the technical documentation, write a tutorial on ajaxifying the frontend. In addition, a separate frontend commercial module (fully functional frontend shop) is in the works. Good question :-). Padloper 2 does not utilise a single ProcessWire field, nor any custom ProcessWire fields, nor any ProcessWire pages (except just the one for the Padloper Process Module). All data is stored in custom Padloper tables. Having said that, it uses ProcessWire selectors just the same way you are used to, offering the same security and ease of use you are used to. You won't have to learn a new syntax. In addition, it is fully multilingual (descriptions, titles, etc). I plan to do a write-up of this when I'm done, a sort of 'the making of Padloper 2', the iterations, decision made, etc. No, you won't be able to do this. Not this way. There are no (ProcessWire) pages in Padloper 2 :-). That said you would still be able to use hooks. You've got some very interesting (albeit very advanced) ideas/thoughts there. Whilst not yet planned, when the dust settles, I'd like to further discuss/explore some of these with you. I cannot make any promises as to the outcome. Yes. There are four types of products (housed under Shipment Type). Physical Products that require shipping. Physical Products that do not require shipping (POS, etc). Digital Products. Products that are Events or Services (e.g., booking system). ---------------------- I hope I have managed to answer all your queries. I decided to just do it inline. I might reference some of the responses in the first post if I need to. Thanks.
    2 points
  4. Here's a small new module that started as a spinoff of a memcache proof-of-concept. Cache your strings and partials in-memory using Redis as a backend. CacheRedis All you need is a running Redis database. The module supports connection through regular TCP, over TLS and via unix domain sockets. Host and port are configurable, and authentication is supported too. Here's a screenshot of the module configuration options: I'll not go into too many details about the usage, you can see everything explained in the README on GitHub, and just highlight the most important points. When the module is active, you'll have a wired $redis variable, which means you can reach the module as $redis, wire("redis") or within Wire classes / modules as $this->redis. CacheRedis is strongly influenced by WireCache, and its usage is (hopefully) straight forward. // Store an entry in the cache under the given key name with the given value: $redis->store("cached_value_number_one", $expire, $value); // Retrieve a value from the cache $value = $redis->fetch($key); // Delete a cache entry $redis->delete("my_other_cached_value"); // Clear the whole cache $redis->flush(); // Retrieve a value from the cache, and if not found, create it through the given function // and store it with a lifetime of 5 minutes (300 seconds) $value = $redis->fetch($key, 300, function() use($page) { return "Page last changed on " . strftime('%m/%d/%Y %H:%M', $page->modified | $page->created); }); // Render a file using wireRenderFile and store it in the cache. // We'll pass a selector as the expiry value so this cache gets // emptied every time a page matching the selector is saved. $news = $redis->renderFile("partials/news.php", 'template=blog-post', ["page" => $page]); The module is still very crude work in progress, but I hope some of you feel daring, try it out and let me know in case anything breaks. Have fun!
    1 point
  5. Ok, I get it now, but it is pretty confusingly worded - either that, or I am just a bit slow ? Anyway, it's easy enough to add, but do you think the icon should be displayed for all users, or just superusers? Also, which icon - the issue is that the key and lock icons are already used in the page tree for other indicators. The other question I have is whether to use the ProcessPageListRender::getPageLabel hook and add the icon as a "PageListStatusIcon" like the lock, exclamation icons are added by the core (at the end of the title in grey), or using the Page::getIcon hook which adds to the front of the page title and the icon is pink. I think the "PageListStatusIcon" option is more correct and looks nicer, but it means that it will be broken on sites that use that ProcessPageListRender::getPageLabel hook to modify the page titles - something I do on a few sites. Of course the other option would be if this wasn't included as part of the module, but rather those who want it can add it themselves with one of those hooks like this: $this->wire()->addHookAfter('ProcessPageListRender::getPageLabel', function($event) { $p = $event->arguments[0]; if($p->protected) { $event->return = $p->title . "<i class='PageListStatusIcon fa fa-fw fa-key'></i>"; } }); OR $this->wire()->addHookAfter('Page::getIcon', function(HookEvent $event) { $page = $event->object; if($page->protected) { $event->return = 'key'; } });
    1 point
  6. @bernhard Can you use $modules->getModule() with the noPermissionCheck option? I haven't tried it yet, but according to the documentation it should bypass permission checks. We had a similar problem with a script that updates the database dump included in the site profile for our base installation. I solved it in the same way as you, by manually setting the current user to the superuser: use Composer\Script\Event; use ProcessWire\ProcessExportProfile; use function \ProcessWire\wire; use function \ProcessWire\fuel; class SchwarzdesignDevTools { /** @var string The path of the webroot. */ public const PUBLIC_WEBROOT_DIR = __DIR__ . '/../../../public/'; /** @var string The name of the site profile. */ public const SITE_PROFILE_NAME = 'site-schwarzdesign'; /** * Script to update the database dump included in the schwarzdesign site profile. * * @param Event|null $event * @return void */ public static function createDatabaseDump(?Event $event = null): void { // bootstrap processwire require_once self::PUBLIC_WEBROOT_DIR . 'index.php'; // set the "current user" to the superuser to enable access to the site profile export module $users = wire('users'); $superuser = $users->get(wire('config')->superUserPageID); $users->setCurrentUser($superuser); // initialize the profile exporter $processExportProfile = wire('modules')->get('ProcessExportProfile'); // dump the database into the site profile $path = self::PUBLIC_WEBROOT_DIR . self::SITE_PROFILE_NAME . '/install/'; $processExportProfile->mysqldump($path); $realpath = \realpath($path); echo "Database successfully dumped to {$realpath}/install.sql!" . \PHP_EOL; } }
    1 point
  7. I am saying you can use the shop itself to manage your featured products. Conversely, you also have the flexibility of pulling anything you want from Padloper into your ProcessWire pages (for GUI edit). In such cases though, you will have to develop the Fieldtype/Inputfield yourself. Padloper will provide the API necessary for the pulling of the data. In a nutshell, I meant, you choose what is convenient for your use case :-).
    1 point
  8. By the way, and I know this was just an example, but in my book, this is something that should be handled from the shop side. Surely, it is a bit much to build a whole custom Fieldtype/Inputfield just to show featured products on the home page ?.
    1 point
  9. 9 years later I hit the same wall ? I have a kickstart script that installs several modules. I got this error: ERROR: application encountered an error and can not continue. Error was logged. Then I found this log in /site/assets/logs/tracy/exception.log: [2020-12-14 20-17-00] ProcessWire\WirePermissionException: You do not have permission to execute this module - ProcessDatabaseBackups in \wire\core\Modules.php:1337 @ CLI (PID: 15532): site/modules/RockBuilder/kickstart.php @@ exception--2020-12-14--20-15--dd5f3e67ab.html When setting the user to the superuser everything works: <?php namespace ProcessWire; /** @var Wire $wire */ include("index.php"); $users->setCurrentUser($users->get(41));
    1 point
  10. Thanks @kongondo. It works both ways, but it's better to use your way, because then I can load the PDF module only when I need it.
    1 point
  11. In programming, it is called variable scope. This throws an error because you are using the variable $modules inside the anonymous function and that function does not know what $modules is :-). This should work: <?php $forms->addHook('FormBuilderProcessor::emailFormReady', function($e) { //$pdf = $modules->get('RockPdf'); <= DOES NOT WORK. function does not know 'modules' $pdf = wire('modules')->get('RockPdf');// <= WORKS. function knows GLOBAL FUNCTION wire() $pdf->write('TEST'); $pdf->save('./generated_pdfs/' . date('yy-m-d_H_i') . '.pdf'); } ); PHP variable scope https://www.php.net/manual/en/language.variables.scope.php wire() Function https://processwire.com/api/ref/functions/wire/
    1 point
  12. @jploch - can you try the attached version please. Sounds strange, but it's actually a bit more complicated than expected just because there are a few ways that the bar can be enabled / disabled / hidden. I think I might have them all taken care of, but would be good if you could help test. Thanks. BTW, the class I added to body is: has-tracy-debugbar TracyDebugger.module.php
    1 point
  13. A couple of hooks that I have found useful in some situations... In the admin menus the icon associated with each page is normally determined by the "icon" item in the Process module config (e.g. as set in the getModuleInfo() method). But sometimes you might want to change that icon. For example, the Lister Pro module uses the "search-plus" icon, but this is not so good when you have multiple Lister Pro instances because it makes each instance less distinct. With the hook below I can use a custom icon for the extra Lister Pro instances I have added: // Add custom icons to Lister Pro menu items $wire->addHookAfter('Page::getUnknown(page_icon)', function(HookEvent $event) { $page = $event->object; if($page->process == 'ProcessPageListerPro') { if($page->title === 'Flora species') { $event->return = 'leaf'; } elseif($page->title === 'Flora images') { $event->return = 'picture-o'; } } }); If you change an icon in the admin menus like this you can do a Modules > Refresh to clear the menu cache and see the updated icon. And for Page List you probably know that you can assign an icon to all pages that use a template in the template's "Advanced" tab. But with the hook below you can assign icons to pages more dynamically based on any properties of the page. So, for example, you could assign a warning icon to a page to alert site editors if some important field was left empty. // Add warning icon to news items without a date $wire->addHookAfter('Page::getIcon', function(HookEvent $event) { $page = $event->object; if($page->template == 'news_item' && !$page->date_1) { $event->return = 'exclamation-triangle'; } });
    1 point
  14. Thanks @SamC, I understand. I kind-of did it in a test environment, let me explain the full case scenario: A local (and really small) movie theater in my area was looking for a web designer to help them out with their website and primarily their ticket management integration. They absolutely need to sell their tickets on-line. I quickly jumped in to start the negotiations around budget, best solution, how to manage the whole thing, ecc. During our chats I found that there was a widely used ticket management service in Italy called Wintic/Webtic, it is used in around 70% of cinemas in Italy and I knew that very probably I would have to integrate that sooner or later. So I started calling the software house regarding their ways to integrate the whole "thing" in an existing portal. They told me that they made available a webservice with the cinema schedule and send me a link to the JSON I was frightened! Being this the first time I've found myself in a situation (that I was actively avoiding) where I just needed to step out of my relatively comfy zone of CMSs and tackle the issue as best as I could and in a budget friendly way. (The integration with Wordpress is just a headache to think about compared with Processwire) Then I started to read (many times) all the threads regarding JSON import and this one really helped me out understanding the whole process. From that thread and a couple of others I modified the script and now it looks like this: https://gist.github.com/protorob/e6050c78b4bee2dbce59c38234afa0de In the end I came out with a functional mockup that you can find here: http://webtic.artomultiplo.net/ and accepted the job. Full of courage. Now I have a whole lot of new questions regarding the best way to wrap it out, so expect to see me around a little more this time. I'm planing to document the whole process in a very long blog post Now my main "concerns" are regarding: - Automate the create/modify/delete of the schedule comparing differences between the current JSON and a New one - Adding extra information to the events and not losing them when the schedule re-synchronize - Working with AJAX Load more for some parts of the website - Handling the blog I know I'll need a little bit of help specially with the importing script. I'll let you know how it goes
    1 point
  15. "today" is something you could use within a ProcessWire selector, like below (so long as you are querying a datetime field): $garagesales = $pages->find("town_select=$town, Date>today, sort=-Date"); …but it's not a PHP language construct, so you couldn't do this: if($c->Date>today) { Like maba mentioned, you'd want to use the time() function instead, which returns the current unix timestamp. You'd also want to retrieve the "unformatted" version of "Date", as you may have it configured to output a date string rather than a unix timestamp. And you'd nee the unix timestamp (which is an integer) in order to properly compare it with time(): if($c->getUnformatted('Date') > time()) {
    1 point
×
×
  • Create New...