Jump to content

All Activity

This stream auto-updates

  1. Past hour
  2. Fun fact. Creating a local backup of a live Wordpress site was easier with DDEV too. MySQL and PHP versions can easily be set in .ddev/config.yml to match the LIVE versions. Adding a POST import-db hook automatically replaces the hardcoded site URLs in the database.sql dump to match the URL on my localhost when running ddev import-db —file=database.sql.
  3. Today
  4. Hello Flo, thanks for reporting this issue! You are right - the automatic population of the "from" field should not happen if a page is unpublished at the moment of saving. I will not add a quick fix inside the Hook function only, which is responsible for this behaviour. Instead I will test the module functionality more intense before offering a new update. I guess (hope) I will offer a new update solving this issue til the end of this week. For the moment, please overwrite the "from" date with a far date in the future to prevent the page from beeing published. Best reagards Jürgen
  5. Hey @Andi thx for your open eyes! I've just pushed a "fix" for this on the dev branch. The thing is that this JS markup is needed sometimes and therefore will be rendered as soon as RockFrontend has some variables set. This was the case for isDDEV and therefore you saw the output. I don't see anything bad with having that markup on my sites. If anyone has good reasons to remove it let me know. The idea is to have a central place to send settings from the backend to the frontend. Some of them are only necessary when logged in, but there might also be situations where a module wants to set something that the frontend consumes. For example the root url of the site, that is unfortunately not always "/" but could also be a subfolder like "/myproject". On the backend that's easy via $config->urls->root, but on the frontend there is no standard and so I added this global RockFrontend variable/object that can hold these kind of things. The order in which you call ->styles() or ->scripts() does not define the order of the output. This method defines it: private function injectAssets(string &$html): void { $assets = ''; foreach ($this->autoloadScripts as $script) $assets .= $script->render(); foreach ($this->autoloadStyles as $style) $assets .= $style->render(); $html = str_replace("</head>", "$assets</head>", $html); } That means scripts will always be rendered first, then styles. I can change that if anyone has good reasons, though I think it does not make a difference. The more important thing is that you can or probably should add "defer" to your scripts, which makes the script load at a later point when the dom is ready. With UIkit this can lead to problems though as it might cause FOUC, because uikit adds custom classes like "uk-grid" when using <div uk-grid> for example. If you are not using defer, then it will work without issues. If using defer, you'd had to add the class manually: <div class="uk-grid" uk-grid> I'm simply loading these 47.8kB upfront to make my life easier.
  6. Hi @Juergen, unfortunately I have a problem again or maybe I am just really confused on how the module should work or might have worked in my case before. I have JkPublishPages enabled for one template only. This is an article page (news_article). Editors should be able to schedule publication of articles by selecting a date and saving (as unpublished). I would expect that JkPublishPages works in the following way: If no date (jk_publish_from or jk_publish_until) is given, the page status stays completely untouched (unpublished in my case) If jk_publish_from is given, JkPublishPages changes the page status to published on the first execution of LazyCron (after the selected date) If jk_publish_until is given, JkPublishPages changes the page status to unpublished on the first execution of LazyCron (after the selected date) Please correct me, if this is not the intended behavior. In my case whenever I create a new page or change an existing page, the jk_publish_from field gets populated automatically on page save with the current time, although I save the page as unpublished and keep the field empty. This in turn results in an (unwanted!) publishing on the page on the next execution of LazyCron. I think that the problem is in the following part of the code (lines 412ff): protected function setPageStatusManually(HookEvent $event): void { $page = $event->arguments(0); // check if jk_publish_from field is present on the given page if(!is_null($page->jk_publish_from)){ $from = true; bd($page->jk_publish_from); if ($page->jk_publish_from) { $from = $page->jk_publish_from < time(); bd($from); } else { $page->jk_publish_from = time(); bd($page->jk_publish_from); } $to = true; if ($page->jk_publish_until) { $to = ($page->jk_publish_until > time()); } if (!$from || !$to) { $page->addStatus(Page::statusUnpublished); } } } If jk_publish_from is empty on page save, it gets populated automatically. Is this intended? Shouldn't the module only act if a value has been (explicitly) added by the user? The editors brought up this issue because they often draft new articles without knowing the puplication date in advance. The drafts shall of course stay unpublished until they are ready to publish and explicitly scheduled or published manually. Your clarification is highly appreciated! Best Flo
  7. Hi @poljpocket, sort (-iname ... ) does not work, because iname_* contain different criteria to sort the images. To have an impression of the site, here's the link: (The new sorting function is not yet implemented completely) http://www.malabu.de But ->reverse(); was the right way, it works! Thanks to you all Günter
  8. Can you post your exact code lines where the sort "doesn't work"?
  9. hi @ShaunaB1 and @Gideon So, Thanks for your efforts to help to my problem. Unfortunately a simple "-" does not solve my challenge. I also tried a "sort(1/iname_3)", where iname_3 contains a timestamp - no success. @Gideon SoI did a dump on $images in line 32 and it throws a long list of all parts of the image-field. Sorting itself works as desired, but not with an option "image_created descending". Greetings Günter
  10. @Gideon So I beg to differ on that assumption. Pageimages is a WireArray and thus will have a sort() function. See here: Pageimages class - ProcessWire API. @biber You can find the API for sort() here: WireArray::sort() method - ProcessWire API. There is no rsort() function, but sort() can still reverse the order like so: $images = $page->images->sort("-iname_".$order, SORT_NATURAL |SORT_FLAG_CASE); note the "-" (minus) in front of the field name. Here is another approach: $images = $page->images->sort("iname_".$order, SORT_NATURAL |SORT_FLAG_CASE)->reverse(); This is using the reverse() function of WireArray, whose docs you can find here: WireArray::reverse() method - ProcessWire API
  11. OMG. So easy. Although not quite self-explanatory… Thank you! 🙂
  12. You need to expand the parent select and navigate to the assigned parent. When you hover on that, you should see the "unselect" button.
  13. Hi @biber I don't think the sort() function is available to pageimages because pageimages is not WireArray. The result of the below line returns nothing. $images = $page->images->sort("iname_".$order, SORT_NATURAL |SORT_FLAG_CASE); Then foreach($images as $image) Give error because the variable $images is empty. Gideon
  14. I'm using the pagefield to select pages inside multiple parent pages. I want to use the TEMPLATE as a mean of finding pages. Unfortunately, I selected a PARENT as well, and once this is done there is no coming back: I can't have no parent anymore, I would have to create a new field. Is it a bug (concept issue) or am I doing something wrong? Thanks!
  15. @Gadgetto I am struggling with webhooks :-) In the docs it says: * All hookable event handler methods will return an array containing payload Snipcart sent to your endpoint. * In addition, the following class properties will be set: * * $this->payload (The payload Snipcart sent to your endpoint) * $this->responseStatus (The response status your endpoint sent to Snipcart) * $this->responseBody (The response body your endpoint sent to Snipcart) * * (Use the appropriate getter methods to receive these values!) * * How to use the hookable event handler methods (sample): * ~~~~~ * $webhooks->addHookAfter('handleOrderCompleted', function($event) { * $payload = $event->return; * //... your code here ... * }); * ~~~~~ * * PLEASE NOTE: those hooks will currently only work when placed in init.php or init() or ready() module methods! * I have setup a hook for order.completed in the init method of a custom autoload module public function init() { ... // SnipWire Webhooks $this->wire->webhooks->addHookAfter('handleOrderCompleted', $this, 'handleOrderCompleted'); } Issueing post requests to the endpoint returns an empty response body While in the docs it says: when I var_dump($event->object->getResponseBody()) in my handler method, it gives an empty string which explains why the response body is empty. How can I set responseBody from within my hook handler method? There is no setter for that and Webhooks::responseBody is private, so I have no way to set it in my handler. To solve this, I introduced a setter method to the Webhooks class /** * Setter for responseBody. * * @param string $responseBody * @return void * */ public function setResponseBody(string $responseBody) { $this->responseBody = $responseBody; } Now in my handler method I can do $event->object->setResponseBody('{"test": "test"}'); Which results in While I was at it, I also added a setter for responseStatus. Not sure if you still maintain this module, so I will add this to my fork just in case anyone still needs it.
  16. @bernhard: Thanks to your forum thread, I finally did the switch from my previously used XAMPP development stack to WSL2/DDEV on my Windows 11 machine. Now I do all my Python, PHP and Node/Html projects within the Linux subsystem on Windows 11 using VS Code as my editor of choice. Only Windows Desktop C# projects (WinForms, WPF) are still done on the Windows side using Visual Studio 2022. Always wanted SSL certificates on my localhost. Installation was easy and my first project was set up within minutes by simply cloning and importing my MySQL dump into my ddev container. Thanks for the inspiration.
  17. Yesterday
  18. OK, here's my slightly revised `router.php` script: <?php if (PHP_SAPI !== 'cli-server') { die('Expected cli-server'); } if (file_exists($_SERVER['DOCUMENT_ROOT'] . $_SERVER['SCRIPT_NAME'])) { return false; } $_SERVER['SCRIPT_NAME'] = '/index.php'; $_SERVER['SCRIPT_FILENAME'] = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['SCRIPT_NAME']; require $_SERVER['SCRIPT_FILENAME']; The main change is that `$_SERVER['SCRIPT_FILENAME']` is now an absolute path. Not critical, but more correct.
  19. OK, got it. I'm using PHP's built-in web server for development. You can often use it directly, like this: php -S localhost:8080 But occasionally you run into situations that require a router script, like this: php -S localhost:8080 router.php I generally use something like this: <?php if (PHP_SAPI !== 'cli-server') { die('Expected cli-server'); } if (file_exists($_SERVER['DOCUMENT_ROOT'] . $_SERVER['SCRIPT_NAME'])) { return false; } $_SERVER['SCRIPT_NAME'] = '/index.php'; require __DIR__ . '/index.php'; ProcessWire required one additional line: <?php if (PHP_SAPI !== 'cli-server') { die('Expected cli-server'); } if (file_exists($_SERVER['DOCUMENT_ROOT'] . $_SERVER['SCRIPT_NAME'])) { return false; } $_SERVER['SCRIPT_FILENAME'] = 'index.php'; // <== Added! $_SERVER['SCRIPT_NAME'] = '/index.php'; require __DIR__ . '/index.php'; That's because of some assumptions in ProcessWire.php. With that added line url path hooks with extensions now work. (I'm going to hunt around a bit to see if I should make any other changes...)
  20. OK, thank you! It helps a lot to know that it *should* work. I'll keep trying to figure out what I'm doing wrong.
  21. I'm doing exactly that in RockFrontend: https://github.com/baumrock/RockFrontend/blob/e2b0beb70427c39ade99dc36547a370dd091f59f/RockFrontend.module.php#L2338
  22. Ryan has always done this (I really don't know why), but the tag on GH is added for the previous master version when the next master version is released and made available from the PW site's download page.
  23. This works: $wire->addHook('/hello', function($event) { return "Hello"; }); This doesn't: $wire->addHook('/hello.txt', function($event) { return "Hello"; }); (Note the `.txt` extension.) I see that in `WireHooks.php`, here, the extension will be removed, because "." will fail the `ctype_alnum` test. But the hook doesn't work even if I comment that block of code out, so that isn't the only issue. This is all rather curious because the original post that introduced url path hooks specifically called out `/sitemap.xml` as a possible use case. Am I doing something wrong? (Btw, curiously, when adding a `/hello.txt` hook, a `/hello.txt` URL doesn't work, but it doesn't produce a 404 either; it produces a blank page.)
  24. Hi, I have built a site with some galleries, which can be ordered by different criteria, like place, name or date_created. This works fine, iname_1,2 or 3 can be chosen by user. Now I want to have the option to sort the images "latest image first". Setting "rsort" instead of "sort" in line 31 comes up with this error: Where is my mistake? Any idea? Here is my template: 1 <?php include(\ProcessWire\wire('files')->compile(\ProcessWire\wire("config")->paths-> root . 'site/templates/_head.php',array('includes'=>true,'namespace'=>true,'modules'=> true,'skipIfNamespace'=>true))); // include header markup ?> 2 3 <div id='haupt'> 4 5 <?php 6 7 // output 'headline' if available, otherwise 'title' 8 echo '<h1>' . $page->get('headline|title') . '</h1>'; 9 10 //get all segments and clean segments! 11 $seg1 = $sanitizer->pageName($input->urlSegment1); 12 $seg2 = $sanitizer->pageName($input->urlSegment2); 13 $seg3 = $sanitizer->pageName($input->urlSegment3); 14 15 //check for the second urlsegment not needed 16 if ($seg2) { 17 // unknown URL segment, send a 404 18 throw new \ProcessWire\Wire404Exception(); 19 } 20 21 //check for the third urlsegment not needed 22 if ($seg3) { 23 // unknown URL segment, send a 404 24 throw new \ProcessWire\Wire404Exception(); 25 } 26 // Sortierung übernehmen: 27 $order = $input->get->order; 28 29 // sortiere nach name_: 30 if ($order >0) { 31 $images = $page->images->sort("iname_".$order, SORT_NATURAL | SORT_FLAG_CASE); 32 $session->set($order, $order); 33 } 34 35 // ohne Sortierung: 36 else { 37 $images = $page->images; 38 } 39 40 //normal content without first url segment! 41 if (!$seg1) { 42 43 echo $page->body; 44 if (!empty ($page->name_1|$page->name_2|$page->name_3)) echo '<p>Sortierung nach '; 45 if (!empty($page->name_1)) 46 echo '<a class="tab" href="'.$page->url.'?order=1">'. $page->get('name_1'). '</a>&nbsp;'; 47 if (!empty($page->name_2)) 48 echo '<a class="tab " href="'.$page->url.'?order=2">'. $page->get('name_2'). '</a>&nbsp;'; 49 if (!empty($page->name_3)) 50 echo '<a class="tab " href="'.$page->url.'?order=3">'. $page->get('name_3'). '</a></p>'; 51 52 // output images 53 foreach($images as $image) { 54 $iname_3 = $image->created; 55 $thumbnail = $image->height(100); 56 echo '<div class="rahmen"><a href="'.$page->url . $image.'?order='.$session-> get($order).'"><img class="shadow" src="'.$thumbnail->url.'" alt="'.$image-> kopf.'" title="'.$image->kopf.'" loading="lazy"></a></div>'; 57 } 58 59 } 60 61 //special view output with an url segment... 62 if ($seg1) { 63 // get the image in the correspondent position: 64 $index = $input->$seg1; 65 $image = $page->images->index($index); 66 67 // Link zum vorigen Bild: 68 echo '<a href="'.$images->getPrev($images->$seg1).'?order='.$session->get($order). '"><img src="'.$config->urls->site.'templates/styles/links.gif" alt="voriges Bild" title="voriges Bild"></a>&nbsp;'; 69 70 // Link zur Thumbnail-Seite: 71 echo '<a href="'.$page->url.'?order='.$session->get($order).'"><img src="'.$config ->urls->site.'templates/styles/index.gif" alt="zurück zur Übersicht" title="zurück zur Übersicht"></a>&nbsp;'; 72 73 // Link zum nächsten Bild: 74 echo '<a href="'.$images->getNext($images->$seg1).'?order='.$session->get($order). '"><img src="'.$config->urls->site.'templates/styles/rechts.gif" alt="nächstes Bild" title="nächstes Bild"></a><br />'; 75 76 // Bild zeigen: 77 echo '<img class="shadow" src="'.$images->url . $seg1.'" alt="'.$images->$seg1-> get('kopf|name_1').'" title="'.$images->$seg1->get('kopf|name_1').'">'; 78 79 //echo '<img class="shadow" src="'.$images->url. $seg1.'" alt="'.$images->$seg1->kopf.'" title="'.$images->$seg1->get('name_1|kopf').'">'; 80 81 82 // Textfelder zu den Bildern anzeigen: 83 echo '<h2>'.$images->$seg1->caption.'</h2>'; 84 echo '<h2>'.$images->$seg1->get('kopf|name_1').'</h2>'; 85 //var_dump($images->$seg1->filedata['_109']); 86 //var_dump($images->$seg1->caption); 87 echo '<p>'.$images->$seg1->bildtext.'</p>'; 88 echo '<p>| '.$images->$seg1->iname_1.'&nbsp; &nbsp;| '.$images->$seg1->iname_2. '&nbsp; &nbsp; | '.date("d.m.Y",($images->$seg1->created)).' |</p>'; 89 } 90 ?> 91 </div><!-- end content --> 92 <?php include(\ProcessWire\wire('files')->compile(\ProcessWire\wire("config")->paths-> root . 'site/templates/_foot.php',array('includes'=>true,'namespace'=>true,'modules'=> true,'skipIfNamespace'=>true))); // include footer markup ?>
  25. Me too! This is now default in all my installations for all the reasons you mention. But I feel this sort of update would be a PW4 thing?
  26. Hi @Christophe Unfortunately we don't have Code Intellisense or autocomplete in latte files at the moment 😞 See https://github.com/smuuf/vscode-latte-lang/issues/5 You are adding the method "listchildren()" to your ParentPagePage, nowhere else. That means you can all this method only on pages that have the template "parent-page". Why should it do that? You are calling a method of an object. If that does not exist it is expected to throw an error. You CAN do what you describe though. Sometimes it is useful and I'm doing that as well. You could add that method to your DefaultPage.php and there return an empty sting. That would make $page->listchildren() return "" by default, which means it does not throw an error. For some page types you can then implement a different logic: DefaultPage.php --> listchildren() { return ""; } FooPage.php extends DefaultPage --> listchildren() { return "foo!"; } BarPage.php extends DefaultPage --> listchildren() { return "BAR"; } // in any template echo $page->listchildren(); That it totally up to you. Same with regular ProcessWire templates. It's up to us devs how we organise things and everybody does it differently. I can only say what I came up with and what works great for all kings of projects (from very simple to very complex ones): layout.latte for main markup /site/templates/sections/... for all sections /site/templates/partials/... for all partials Details: layout.latte --> holds the html markup skeleton of the page, eg: <html> <head>...</head> <body> <header>...</header> <main>...</main> <footer>...</footer> </body> </html> Then all my template files are usually empty (like home.php, basic-page.php, foo.php, bar.php). Next, I divide my design into sections. A section is a portion of the page that goes from the very left to the very right and has an undefined height/content. You can then add those sections to your main markup file like this: <html> <head>...</head> <body> <header> {include "sections/topbar.latte"} {include "sections/navbar.latte"} </header> <main> {include "sections/breadcrumbs.latte"} {include "sections/content.latte"} {include "sections/content-footer.latte"} </main> <footer> {include "sections/footer.latte"} </footer> </body> </html> This is often all I need, because I build all the available sections in RockPageBuilder and then I can simply add them to the pages as I need them. But it works without RockPageBuilder as well. You then just need to code all your page layouts depending on the page template. If all those pages share the same breadcrumbs and content-footer it could look like this: <html> <head>...</head> <body> <header> {include "sections/topbar.latte"} {include "sections/navbar.latte"} </header> <main> {include "sections/breadcrumbs.latte"} {if $page->template == 'foo'} {include "sections/content-foo.latte"} {elseif $page->template == 'bar'} {include "sections/content-bar.latte"} {else} {include "sections/content.latte"} {/if} {include "sections/content-footer.latte"} </main> <footer> {include "sections/footer.latte"} </footer> </body> </html> You could also use a dynamic approach: <html> <head>...</head> <body> <header> {include "sections/topbar.latte"} {include "sections/navbar.latte"} </header> <main> {include "sections/breadcrumbs.latte"} {include "content/" . $page->template . ".latte"} {include "sections/content-footer.latte"} </main> <footer> {include "sections/footer.latte"} </footer> </body> </html> It's just regular PHP inside the latte tags, so you could also do is_file() checks etc: <html> <head>...</head> <body> <header> {include "sections/topbar.latte"} {include "sections/navbar.latte"} </header> <main> {include "sections/breadcrumbs.latte"} {var $file = "content/" . $page->template . ".latte"} {if is_file($file)}{include $file}{/if} {include "sections/content-footer.latte"} </main> <footer> {include "sections/footer.latte"} </footer> </body> </html> Obviously you'd need to create those files. Here I'm placing them into a new folder called "content", which would be /site/templates/content/foo.latte for example. Next, partials: If you have repeating markup inside your sections you can outsource them into the partials folder. For example let's say you want to show a blog overview page that shows all single blog items as cards. You'd have a section like "blog-overview.latte" like this: // blog-overview.latte <div uk-grid> <div n:foreach="$page->children() as $item"> <div class="uk-card"> <h3>{$item->title}</h3> <p>{$item->teaser()}</p> </div> </div> </div> This example is very simple and if you only use your cards here, then it's easier to leave them here. If you are using the exact same cards on two or three places then you can create partials for them: // blog-overview.latte <div uk-grid> {foreach $page->children() as $item} {include "partials/card.latte", item: $item} {/foreach} </div> // /site/templates/partials/card.latte <div> <div class="uk-card"> <h3>{$item->title}</h3> <p>{$item->teaser()}</p> </div> </div>
  1. Load more activity
×
×
  • Create New...