Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/25/2016 in all areas

  1. Hello, everyone. I had a tiny bit of spare time and decided to play a bit with PW. Opening up the page to see if everything so far is working fine, I noticed that the logo is appearing OK on the main (Home) page but on the inner pages it shows a missing image. I remembered that I changed the $page->image->url call that was suggested earlier and did not check if the logo appears. The problem with the logo on the inner pages was caused by the fact that a simple $page->logo-url call would not work on templates where the logo is not added as a field. Considering the fact that in every template I am including the header.inc where the header logo is, I started to think how on Earth the trick is working. A bit of digging and brainstorming and the solution is in place. I added to _init.php the logo variable and changed the call in header.php: $logoURL = $pages->get('/')->logo->url(); As far as my idea is at the end to move most of the settings to a specific "Settings" page, then I will have to change the page where the logo will be kept, however this won't be a problem when I have the reminder of what was done and how in here. Happy holidays and Merry Christmas lovely and super supportive people. All the best and tons of productive ideas in 2017 (that would make our life even easier and nicer using PW )
    2 points
  2. Another great year with the great PW community!! This year was the year I got tons of projects in PW, and they were just like ProcessWire is wants things to be: fast, simple and fun!!! All the learning paid up, thanks everyones, couldn't have done it without your help and buried posts!
    2 points
  3. Small Website for German Food Magazine Subscriptions - according to design guidelines from the client. https://rezeptemitherz.de/ It's more of a web application than just a website. Lots of code under the hood. Has a flip-book catalogue (see "Magazin") Collecting subscriptions and individual orders and forwarding them condensed in daily reports to the distributor as csv files according to their guidelines. Timed drawings with automatic selection of the winners, and more... Heavily relies on/and extends the FormBuilder PRO module.
    2 points
  4. Hey, The Form API has CSRF protection build in, but if you for some reason don't want to use the API you can however use the CSRF protection. Its very simple but it took some time for me to find out, so i figured i share my findings with the rest. What is CSRF? First you need to create a token and a token name you do that as following: $tokenName = $this->session->CSRF->getTokenName(); $tokenValue = $this->session->CSRF->getTokenValue(); Very simple. Now what you want to do is create a hidden input field like this: $html .= '<input type="hidden" id="_post_token" name="' . $tokenName . '" value="' . $tokenValue . '"/>'; Now this will generate something that will look like this: You are done on the form side. You can now go to the part where you are receiving the post. Then use: $session->CSRF->validate(); This will return true (1) on a valid request and an exception on a bad request. You can test this out to open up your Firebug/Chrome debug console and change the value of the textbox to something else. Basicly what this does is set a session variable with a name (getTokenName) and gives it a hashed value. If a request has a token in it it has to have the same value or it is not send from the correct form. Well I hope I helped someone.
    1 point
  5. Just stopping by to wish all the other members a happy Christmas. Or if you don't celebrate Christmas, then a happy holidays! And if you don't have a holiday, maybe you'll get one next year :-p Been working on two websites concurrently with PW so pretty busy! Not been able to stop by here as much as I would have liked. On a plus note, both are now at the demo stage. I actually need to find some work in the new year as I'm kicking off my self employment again, so anyone wants to see the demo sites to see the kind of stuff I'm doing, then I'm happy to share in a PM. TBH, they're not highly technical, still more brochure style at the moment, but looking to move onto bigger and better things. Maybe a meetup in Surrey or something would help kickstart things a little. Have a good one people Sam.
    1 point
  6. Small Website (in German) for Holiday Apartment Rentals at the German Coast (Island of Sylt). https://www.hanseaticaufsylt.de/ Main target group: German Seniors Website is fully responsive, uses UIKIT and the PRO modules, Table, ProCache, FormBuilder... and, yes, I admit: the good ol' tacky snowfall animation during Christmas. Images are provided by the client, not by us. They will be replaced with new ones with higher resolutions during this Summer season.
    1 point
  7. Fixed by: https://github.com/processwire/processwire/commit/622896e028aba214a5431b34606f94518b35953d
    1 point
  8. Christmas stockings are where you find the small gifts, while the big stuff goes wrapped up under the tree. Yet, looking back, it often seems like some of the most useful stuff ends up in those stockings… Swiss army knifes, digital tire gauges, flash drives, and so on. This week, the big stuff is between you and Santa, but what we do have are lots of useful stocking stuffers for you to enjoy in ProcessWire 3.0.46! https://processwire.com/blog/posts/pw-3.0.46-stocking-stuffers/
    1 point
  9. My problem has been solved from another post. Anyway, thank you @Can
    1 point
  10. $event->object and $this refer to the same object. The difference is that hooks are not "inside" the class, so you can only access public methods/properties, while the core class can access all of it's own methods/properties. http://php.net/manual/en/language.oop5.visibility.php http://php.net/manual/en/language.oop5.inheritance.php
    1 point
  11. I freaked out hearing the sound of the seagull so unexpectedly, but otherwise I like it
    1 point
  12. I highly recommend reading the second post, too before implementing anything, as it might simplify a lot, depending on your setup.. Because I just updated all MarkupCaches with newer WireCache, couple of weeks ago, and really like it, I thought why not share it. So I got _init.php as prependTemplateFile, and _out.php as appendTemplateFile. But let's check out the interesting part, for example an article.php template. but for some pages, for example blog, it makes sense to include all children ;-) You can include any page you like, or define a time or a template as expiration rule. Here my defaults from the _init.php $cacheNamespace = "hg"; $cacheTitle = "$page->template-" . $sanitizer->pageName($page->getLanguageValue($en, "title")) . "-$page->id-{$user->language->name}"; $cacheTitle .= $pageNum ? "-$pageNum": ''; $cacheExpire = $page; I'm not exactly sure if there is any benefit in using a namespace, you can omit the namespace part and if needed just prefix the cache title. Works both. You'll see why I added the namespace/prefix a little later ;-) For the title I'm getting, the template, english page title (you can of course use the language title and omit the language name part, but I liked it better to have the caches grouped.. After language name I'm adding the page number if present. If you need you can of course create a different, more or less specific cache title. Add get parameters or url segments for example. Then I have $cacheExpire already set to $page as default value, so I don't need to set it in every template So my markup (only the important parts) looks like this: //You can have anything you like or need uncached above this $cacheExpire = $page->chilren(); $cacheExpire->add($page); $cache->getFor($cacheNamespace, $cacheTitle, "id=$cacheExpire", function($pages, $page, $users, $user) use($headline) { // as you can see, within the function() brackets we can pass any Processwire variable we need within our cached output. // If you don't need any you can of course leave the brackets empty // and if you need any other variable wich you had to define outside this function you can pass them via use() // so here goes all your markup you want to have cached // for example huge lists, or whatever }); // Then I have some more uncached parts, a subscription form for example. // After this comes another cached part, which gets -pagination appended to the title. Otherwise it would override the previous one. // It's not only caching the pagination, I just needed a name for differentiation. $cache->getFor($cacheNamespace, $cacheTitle.'-pagination', "id=$cacheExpire", function($pages, $page, $users, $user) use($headline) { // so here comes more cached stuff }); After this your template could end or you can have more uncached and cached parts, just remember to append something to the cache title ;-) Now comes, at least for me, the fun part haha In my prepended _init.php template file I have the following code under the cache vars: if($user->isSuperuser() && $input->get->cache == 'del') { if($input->get->clearAllCaches == "true") { $allCaches = $cache->get("hg__*"); foreach($allCaches as $k => $v) $cache->delete($k); $session->alert .= "<div class='alert alert-success closable expire'>All (".count($allCaches).") caches have been deleted. <i class='fa fa-close'></i></div>"; } else { $currentPageCaches = $cache->get("hg__$page->template-" . $sanitizer->pageName($page->getLanguageValue($en, "title")) . "-$page->id*"); foreach($currentPageCaches as $k => $v) { $cache->delete($k); $session->alert .= "<div class='alert alert-success closable expire'>Cache: $k has been deleted. <i class='fa fa-close'></i></div>"; } } $session->redirect($page->url); } So when I append the parameter "?cache=del" to any URL all cache files within my namespace and beginning with the predefined $cacheTitle will be removed. Means all language variations and the "-pagination & -comments" caches will be deleted, too. This is the else part. But if I append "&clearAllCaches=true", to the first parameter, it will get all caches within my namespace and clear them. Without the namespace it would clear Processwires caches (like the module cache), too. I'm storing a little success message in a session called "alert" which is closable by the FontAwesome icon via jQuery and expires after some seconds, means it will remove itself, so I don't have to click ;-) Maybe it makes more sense to change the cache title and have the page->id first, so you could select all related caches with $cache->get("hg__{$page->id}*"); I liked them grouped by template in the database, but maybe I change my mind soon because of this For not having to type those params manually I have two buttons in my _out.php template file. I have a little, fixed to the left bottom corner admin menu with buttons for backend, edit (current page), and now clear cache button which unveils the clear all caches button on hover, so it's harder to click it by mistake. When someone writes a comment, I added similar lines as above, after saving the comment, to clear comment caches. Ah, the comment caches look like "-pagination" just with "-comments" appended instead. I don't know if there is an easy way to expire a cache when a new children (especially backend created) is created, other than building a little hook module. With MarkupCache it could be a pain to delete all those folders and files in /assets/ folder, especially with slow connection. The database driven WireCache makes it much faster, and easier when set up those few lines of code to make it for you. more about WireCache http://processwire.com/blog/posts/processwire-core-updates-2.5.28/#wirecache-upgrades https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/core/WireCache.php Hope it helps someone and is okay for Tutorial section, if you have any questions, suggestions or ideas feel free to share. Hasta luego Can
    1 point
  13. This is covered on the documentation in the API > Selectors section, but wasn't previously at the level of detail you requested. The possible values depend on what fields you've created (they are the values). But I didn't cover the "sort=sort" before, so that's taken care of now. Here is what I added: How results are sorted if you don't specify a "sort" in your selector In $page->children() and $page->siblings() the results are automatically sorted by the page's default sort field that you specify in the admin. If not specified in the admin, the pages will be sorted by the order they are placed in the admin. This behavior can be overridden by specifying your own "sort=[property]". With $pages->find() and $page->find(), if you don't specify your own "sort=[property]", the results are sorted according to MySQL's text searching relevance. If no text searches are performed in your find(), the results are unsorted. As a result, it is generally a good idea to include a "sort=[property]" when using $pages->find(), especially if you care about the order and your find() operation is not text/relevance related. How to force pages to sort by their admin order with $pages->find() Unlike $page->children(), the $pages->find() function does not automatically sort by the order they appear in the site tree. This is because $pages->find() is not limited to finding pages specific to one parent, so it may be pulling pages from multiple places (according to your selector). If your parent page(s) are not already sorting by a specific field, you may still tell the $pages->find() to sort by the parent's order by specifying "sort=sort" in your selector. This is the same as saying "sort by whatever order I dragged the pages to in the admin." But note that if the results have multiple parents, the resulting order isn't likely to be useful.
    1 point
  14. Good points. The "sort=sort" is assumed when you use the children() or siblings() functions. But for find() operations, a relevancy sort is introduced. Of course, if your find() doesn't involve some kind of keyword, then that relevancy doesn't really come into play. I think what may be appropriate is for me to automatically add a "sort=sort" to any find() operations that include a "parent=" portion of the selector. What do you think?
    1 point
×
×
  • Create New...