Jump to content

bernhard

Members
  • Posts

    6,268
  • Joined

  • Last visited

  • Days Won

    314

Everything posted by bernhard

  1. https://www.kaumberg.gv.at/ Hello everybody! Today I want to share a project that I've been working on for a year or so: The new website for municipal Kaumberg - a beautiful village near Vienna. To be honest, this project was way more work than I initially expected. The site has tons of content and the client came with lots of good ideas during the process of building this site. For example after we launched the site several organisations of the village realized that the system works great and is easy to use, so they wanted their own section with their own color scheme... Right now the system is maintained by several user accounts that populate content to the site. Some of them only in the news-section, others are allowed to publish to the sub-sites (eg for the fire department). Recently we won the 2nd price out of 190 cities in lower austria - where Kaumberg was by far the smallest one also having the smallest budget of the top rated cities! ### NOTE ### This system was built with scalability in mind. If you know any other municipals (preferable in a german speaking country) that could possibly need a new website using my setup write me a PM. If you are a marketing guru and know how we can sell this product to 100s of municipals, let me know. I know how to do that from the technical point of view ? ### HIGHLIGHTS ### CONTENT Custom multi-level menu for managing loads of content pages that also works well with keyboard navigation ? --- EVENT MANAGEMENT Events are managed via the PW backend and presented as calendar on the website plus can be downloaded as PDF calendar in A3 format for printing: --- CONTENT BLOCKS I've developed a new (private) module called RockMatrix for versatile, easy and fool-proof content creation for this project. This setup ensures that even non-tech-savvy users can create content that looks nice and works on all devices from desktop to mobile: --- SITE SEARCH Another new module that was developed for this project is RockSearch. I hate site searches that do work on the first sight but do not on the second. For example if they show older results on top of newer ones. Or if they do not index content that is not stored within a regular text field but for example as image description. On the other hand I did not want to use ElasticSearch because it seemed to be overhead to send data to another service that is already stored in the database of my PW installation... RockSearch shows results based on different weighing mechanisms, for exampe a search for the garbage collection schedule first shows results that are nearer to the current date than others (both future and past). That means that a date two days in the future will be shown above one that is 10 days in the past. Also results get different score based on where the term was found - matches in the site title get higher scores than matches in the body or in image descriptions or the like. Each content block is a RockMatrix block that has a render() method to define the output on the website and - for RockSearch - has a method called "searchIndex()" that defines the content that is written to the search index that is queried for every search request: This setup makes it super easy to add new content elements and to add them to the search index ? --- SUB-SITES The client can create sub-sites for different organisations of the village having custom color schemes and managing user access: News can be tagged to show up on different areas of the website: --- OTHER The site uses no cookies and can therefore be used without an annoying cookie banner. Page hit statistics are gathered by PageHitCounter and shown by RockHitCounter Some other little features are short-links for social media (eg https://www.kaumberg.gv.at/goto-1027 ) or the possibility for creating custom subdomains for sub-sites like http://araburg.kaumberg.at/ I'm quite sure I forgot lots of great stuff, but I hope you enjoyed reading this article nevertheless ? Looking forward to your feedback!
  2. I guess because you are in a module you have output formatting OFF which means that $page->image is an array of images and not a single PageImage object. Using $page->image->first()->size should work. PS: To make everything clear and reduce chances for errors you can be more verbose and use $page->getUnformatted('image')->first()... PPS: Better check if an image was uploaded before using ->size(...) $img = $page->getUnformatted('image'); if($img AND $img->count()) { $img = $img->first(); $img->size(...)->... }
  3. I can just say that I'm still having this issue as well...
  4. @dotnetic does your module still work? Or do we have any better options in late 2021? ?
  5. And not to forget URL hooks: https://processwire.com/blog/posts/pw-3.0.173/#making-short-urls-of-all-blog-posts
  6. Ah, I think I understand now! You want to hide the input for page title and name and want to auto-generate those? Should the user be able to edit them later on page edit?
  7. Can you please describe the exact use case? What is the user expected to do? What page title or name should be generated when and why?
  8. What is your plan to make the page name unique? Do you want to add the page id or such?
  9. Mine was also ? This helped me and may also help others: https://youtu.be/EeCNlB7v08I?t=161
  10. I've never done that myself but you could also do a get request to that page automatically on save: <?php $wire->addHookAfter("Pages::saved(template=yourtemplate)", function($event) { $page = $event->arguments(0); (new WireHttp())->get($page->httpUrl); }); This might slow down saving the page for the client, but it would create all image variations for website visitors and you'd not need to define all the image variations in the hook or keep your template and the hook in sync... Happy to hear how that worked!
  11. $rm = $modules->get('RockMigrations'); $rm->createField('demo_page', 'page', [ ... ]) $rm->createField('demo_repeater', 'repeater', [ 'repeaterFields' => [ 'demo_page', ], ]); Something like that?
  12. No hurry as long as the next update will have this change in place so nothing breaks on my end ?
  13. @David Karich could you please modify the js script a little so that we can set the page id of the tracked page manually as function parameter? The example of the docs can then be simplified a lot from this: $(function(){ if($('a.news_tag').length > 0) { $('a.news_tag').each(function(){ var tPID = $(this).data("pid"); if(tPID) { $(this).on("click", function(){ $.post(location.pathname.replace(/\/?$/, '/') + 'phcv1', {pid: tPID}); }); } }); } }); To something like that (untested): $(document).on('click', 'a[data-pid]', function(e) { let pid = $(e.target).data('pid'); if(pid) PHC.track(pid); }); PS: The reason why I need this is I'm using barba.js for page transitions so I need to send page tracking manually after each transition and the <body> tag is not updated from one page to the other meaning that automatic tracking via body[data-phc] does not work...
  14. ok then $page->getUnformatted('file_field')->addFromUrl(...) would also work ?
  15. Wouldn't it be better to do the $page->of(...) inside the addFromUrl method?
  16. From a conversation with ryan I think to remember that /site/assets is supposed to be writable while /site/templates is not. https://processwire.com/docs/start/structure/files/ does not state the latter one but it confirms my first point.
  17. My opinion: Great work. I was impressed ? Only thing was after I clicked skip intro I got a strange sound and was not able to turn that off. No mute button or the like... a page refresh made the annoying sound go away.
  18. Jep, thx ? Yeah, I'm using that often, thx. Just needed to test a little new module that handles API requests and I was totally confused that things where all NULL in my console code whereas values where obviously saved in the config (as fields where filled). Thx for the fix!
  19. hey @adrian hope you are fine ? today I noticed a very strange issue with this little and simple module: When I do this: $m = $modules->get('Demo'); db($m); db($m->url); ...in the Tracy Console it does NOT show any data when I'm in the module's config screen. When I'm on any other page it shows data as it should. Note that the issue does only occur on a non-autoload module. Making the module autoload fixes the issue (that might help for debugging). Any ideas why this could happen? --- On module's config page: On any other page:
  20. @Jonathan Lahijani how/where do you define the markup for all those elements? For example the image... Does it use some kind of $img->maxSize(x, y)->url or does it show the originally uploaded image, which might be several MB in filesize?
  21. bernhard

    Wireframe

    I'm not sure what I was talking about back then, but you can simply do something like this: <?php namespace ProcessWire; class MyPage extends Page { public function init() { $this->addHookAfter("ProcessPageEdit::buildForm", $this, "buildForm"); } public function buildForm(HookEvent $event) { $page = $event->process->getPage(); if(!$page instanceof self) return; // $page is a MyPage object now $form = $event->return; // get the title field and add a note if we find it if($f = $form->get('title')) { // note that we use $page->foo() and not $this->foo() $f->notes = "I am a MyPage object and my foo() method says: ".$page->foo(); } } public function foo() { return 'MyPage-Foo!'; } } Note that the hook in this example never gets executed! You'd need to trigger it once. Where you do that is up to you - I'm usually doing that via RockMigrations (https://github.com/BernhardBaumrock/RockMigrations/blob/5cafb3c6c0f2004b8d4087ca243cc0d5f771dd11/RockMigrations.module.php#L377) but you could also add it in init.php <?php $tmp = new MyPage(); $tmp->init(); This adds a little overhead since we load an additional instance of MyPage on every request but I do much more prefer that over getting more and more of a hook hell on larger projects. The way I showed above is much cleaner and keeps everything where it belongs: To the MyPage class. Now once you open a MyPage in the PW backend you get the note on the title field and you know where to look for that hook: In MyPage.php - not in ready.php, or init.php, or another module, or wherever else...
  22. I don't know much about datetime libraries, just know that tabulator.info recently replaced momentjs by luxon. http://tabulator.info/docs/5.0/release#dependencies https://github.com/you-dont-need/You-Dont-Need-Momentjs https://www.htmlgoodies.com/javascript/luxon-vs-moment-javascript/ Good luck with your new challenge ??
  23. What happens if you use the show() method? https://github.com/BernhardBaumrock/RockPdf#different-output-types
×
×
  • Create New...