Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/14/2020 in all areas

  1. Or in this case you could just use Tracy's Admin Tools panel which has a one-click "delete field" button when viewing a field's setting in the admin ? PS - not meaning to be a downer on your module in general, it's just not necessary for this use case.
    2 points
  2. It sounds like output formatting is OFF when the data of the image is requested, therefore pw treats the data of the field as PageImagesARRAY. That's why you have to get the first item manually. This step is done automatically when output formatting is ON and your field is set to single image.
    2 points
  3. Process Cache Control This module provides a simple solution to clearing all your cache layers at once, and an extensible interface to perform various cache-related actions. The simple motivation behind this module was that I was tired of manually clearing caches in several places after deploying a change on a live site. The basic purpose of this module is a simple Clear all caches link in the Setup menu which clears out all caches, no matter where they hide. You can customize what exactly the module does through it's configuration menu: Expire or delete all cache entries in the database, or selectively clear caches by namespace ($cache API) Clear the the template render cache. Clear out specific folders inside your site's cache directory (/site/assets/cache) Clear the ProCache page render cache (if your site is using ProCache) Refresh version strings for static assets to bust client-side browser caches (this requires some setup, see the full documentation for details). This is the basic function of the module. However, you can also add different cache management action through the API and execute them through the module's interface. For this advanced usage, the module provides: An interface to see all available cache actions and execute them. A system log and logging output on the module page to see verify what the module is doing. A CacheControlTools class with utility functions to clear out different caches. An API to add cache actions, execute them programmatically and even modify the default action. Permission management, allowing you granular control over which user roles can execute which actions. The complete documentation can be found in the module's README. Plans for improvements If there is some interest in this, I plan to expand this to a more general cache management solution. I particular, I would like to add additional cache actions. Some ideas that came to mind: Warming up the template render cache for publicly accessible pages. Removing all active user sessions. Let me know if you have more suggestions! Links https://github.com/MoritzLost/ProcessCacheControl ProcessCacheControl in the Module directory CHANGELOG in the repository Screenshots
    1 point
  4. I'm currently building a Fieldtype/Inputfield for selecting date and time ranges (eg for events). There was quite some interest in this thread, so I thought I start a dedicated discussion... Background: I guess everybody of us knows the problem: You want to present events on your website and you start with a new template and a title and body field... For events you'll also need a date, so you add a datetime field called "eventdate". Maybe the event does not take place on a specific day but on multiple days, so you need a second field... Ok, you rename the first field to "date_from" and add a second field called "date_to". So far, so good. Then you want to list your events on the frontend. Simple thanks to the pw API, you might think. But you realize that it's not THAT simple... Which events take place on a specific day? What would the selector be? Yeah, it's not that complicated... it would be something like: $from = strtotime("2020-01-01"); $to = strtotime("2020-02-01"); $events = $pages->find("template=event, date_from<$to, date_to>$from"); Why? See this example, where the first vertical line represents the $to variable and the second is $from: The start of the event must be left of $to and the end must be right of $from ? Ok, not that complicated... but wait... what if the date range of the event (or whatever) was not from 2020-01-18 to 2020-02-25 but from 18 TO 25 (backwards)? The selector would be wrong in that case. And did you realize the wrong operator in the selector? We used date_to>$from, which would mean that an event starting on 2020-01-01 would NOT be found! The correct selector would be >=$from. That's just an example of how many little problems can arise in those szenarios and you quickly realize that the more you get into it, the more complicated it gets... Next, you might want to have full day events. What to do? Adding a checkbox for that could be a solution, but at the latest now the problems really begin: If the checkbox is checked, the user should not input times, but only dates! That's not possible with the internal datetime field - or at least you would have to do quite some javascript coding. So you add 2 other fields: time_from and time_to. You configure your date fields to only hold the date portion of the timestamp and show the time inputfields only if the "fullday" checkbox is not checked. We now have 5 fields to handle a seemingly simple task of storing an event date. That's not only taking up a lot of space in the page editor, you'll also have to refactor all your selectors that you might already have had in place until now! Idea So the idea of this module is to make all that tedious task of adding fields, thinking about the correct selectors etc. obsolete and have one single field that takes care of it and makes it easy to query for events in a given timeframe. The GUI is Google-Calendar inspired (I'm acutally right now liking the detail that the second time input comes in front of the date input). I went ahead and just adopted that: Next steps I'm now starting to build the FINDING part of the module and I'm not sure what is the best way yet. Options I'm thinking of are: // timestamps $from = strtotime("2020-01-01"); $to = strtotime("2020-02-01")+1; // last second of january // option 1 $pages->find("template=event, eventdate.isInRange=$from|$to"); $pages->find("template=event, eventdate.isOnDay=$from"); $pages->find("template=event, eventdate.isInMonth=$from"); $pages->find("template=event, eventdate.isInYear=$from"); // option 2 $finder = $modules->get("RockDaterangeFinder"); $finder->findInRange("eventdate", $from, $to, "template=event"); $finder->findOnDay("eventdate", $from, "template=event"); ... I think option 1 is cleaner and easier to use and develop, so I'll continue with this option ? Future As @gebeer already asked here I'm of course already thinking of how this could be extended to support recurring events (date ranges) in the future... I'm not sure how to do that yet, but I think it could make a lot of sense to build this feature into this module. I'm not sure if/how/when I can realease this module. I'm building it now for one project and want to see how it works first. Nevertheless I wanted to share the status with you to get some feedback and maybe also get your experiences in working with dates and times or maybe working with recurring events (or the abandoned recurme field). For recurring events the finding process would be a lot more complicated though, so there it might be better to use an approach similar to option 2 in the example above.
    1 point
  5. OMG... wish I knew that some such shortcut existed before.
    1 point
  6. Nice! Didn't know that! Always happy to hear about other options that I might not know, thx! ?
    1 point
  7. @wesp Well, that ain't so easy. If you wanted to make it behave like that - and make sure you don't break user's back-button in the process, and make sure people actually scroll to the section if they share/bookmark such a pseudo-link - you should use an SPA framework like Vue instead, where you have such custom routing functionality already built-in. otoh, it's quite easy to hide / remove the #section1 completely from the location bar - but that's not what you're after.
    1 point
  8. @wesp You don't need the Functions API for the functionality you asked for - it's just the syntax Zeka used that requires it, e.g. pages() instead of $pages etc. I have tried this combination here, and it works fine: // at the very top of home.php if ($input->urlSegment1) { $pagename = $input->urlSegment1; $match = $pages->findOne("template=article, name=$pagename"); if (!$match->id) { throw new Wire404Exception(); } echo $match->render(); return $this->halt(); } // site/ready.php // taken from this great case study: https://processwire.com/talk/topic/3987-cmscritic-development-case-study/ wire()->addHookBefore('Page::path', function($event) { $page = $event->object; if($page->template == 'article') { $event->replace = true; $event->return = "/$page->name/"; } }); If you copy-and-paste, pls note that my template is called 'article', not 'article-page' ? Attached also the home template URL segment settings.
    1 point
  9. Sounds like your test_image field is configured to return an array of results - hence access via the first accessor fixing things for you.
    1 point
  10. Thanks, I appreciate the help! I was thinking it was with ProcessWire and not with the module (thought it was best to keep this under the thread in one place). I wont pretend like I understand my "fix", but I did get it working by using "img" => $offer->test_image->first->httpUrl,
    1 point
  11. Brilliant, thx for this module! ? The sort order must be specified on the PARENT page, then all children get sorted. My setup: news (template "news") - news1 (template "newsitem") - news2 (template "newsitem") ... Then i set the sort to the "range" field (a timestamp of the first second of this day) and also created, so that pages that where created later are listed on top: news: -range, -created
    1 point
  12. Wouldn’t it be cool to have whole repeater items (or even repeater matrix items) language-specific. Some of my clients do have pages that are 90% identical in German and English, but there are some sections that should not appear in one or another language. I attached a concept screenshot. Would something like this be possible with some simple backend hooks and "hidden checkbox fields"? Or is it way more complicated?
    1 point
  13. One simple way to do this client side with normal fields would be to add an "Active languages" field to each Repeater Matrix type, and use that as a language activation switch. For example: Create a Page Reference field "active_languages" with the template "language" as selectable pages and the input field type set to checkboxes. Then add that field to each repeater matrix type. Finally, in the code that renders the matrix item, use something like this (code untested): // assuming the matrix field name is "sections" foreach ($page->sections as $section) { $if ($section->matches("active_language={$user->language->id}") { // render the field } } Now the editor can check which languages they want the section to be displayed in. Obviously you can also invert the logic and use the checkboxes to hide the section in a specific language. Of course, having this built in would simplify things a lot ?
    1 point
  14. Hi guys and girls! And thanks for Processwire! Just to give some help with Google account settings for WireMailSMTP. They are pretty well known... but Google appears to reject SMTP authentication from "non-trusted apps". There's however a solution which doesn't make Processwire "more secure" (from Google point of view) but unlocks the possibility of sending mails by WireMailSMTP using a Google account. You need to enable 2-factor authentication for Gmail account which You want to use with WireMailSMTP. You need to generate an "app password" different from Gmail account password. This "app password" should be used as SMTP password while setting WireMailSMTP up. Bingo! No more blocking. P.S. In my case, that Google blocking was occuring even if i tried to send a single letter per day. I'm not sending spam, just notifications for website owner/manager.
    1 point
×
×
  • Create New...