Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/01/2016 in all areas

  1. This week we've got major upgrades to ProcessWire's selector engine, a great new version of Form Builder, and a few other core updates as well! https://processwire.com/blog/posts/processwire-3.0.13-selector-upgrades-and-new-form-builder-version/
    9 points
  2. A couple of requests to make working with templates in Admin more streamlined: 1. Display the "Label" field in the "New Template" screen - I always like to label my templates and currently this requires you to re-open the template you have just created. Also, I'd rather have the template screen remain open after adding a template rather than be sent back to the Templates overview. These changes would make the "New Template" process more consistent with the "New Field" process. But of course the likely reason for no Label field and the closing of the template screen is because it's actually "New Templates" plural not "New Template" singular. Myself, I've never felt the need to add multiple templates at once but I expect others do. Maybe "New Template" and "New Templates" could be separate commands? 2. When duplicating a template (Add New Templates > Duplicate fields used by another template) it would be nice if field overrides (widths, descriptions, etc) were included in the new template(s). It can be quite time-consuming to set these up, and if you are duplicating fields of an existing template I think you also want to duplicate the overrides more often than not.
    7 points
  3. Perfmon Debug Toolbar is a Processwire module used in performance monitoring and optimization. This module has been kicking around for some time, but I finally got around to publishing it. The user interface is heavilly influenced by django-debug-toolbar if anyone is familiar with that project. During install, $config->debug must be set to true for the toolbar to run, the module is not intended to be enabled on production. The primary goal of the module is to identify bottlenecks and help tune up code. More information is here: https://github.com/KeeneState/DebugPerfmon Please let me know if you have any difficulty installing or running it. It's intended to be run on a development instance, though it can exist in a dormant state in production. Collapsed presentation (top right of screen): Expanded Presentation:
    7 points
  4. +1 3. It would be great if we could enter the new template name directly before duplicating. So the template and field duplication process are equal.
    6 points
  5. Where do i get? From here: https://github.com/IDT-media/IntegerAutoIncrement What does this do? Adds additional option to Fieldtype Integer to make it auto increment. How to use? Simply install this module, Create / Modify Field that is Integer, set auto increment on/off. Enjoy!
    3 points
  6. Just for the record, you could also wrap the function declaration with function_exists(): if (!function_exists("listDefinitions")) { function listDefinitions(PageArray $children) { // etc. } } echo listDefinitions($page->children);
    3 points
  7. This module provides a very simple interface to a set of named counters. You simply call a single function, next('name'), to pull the next value out of a counter - or to set it up if it does not yet exist. Next() takes a few extra parameters to allow you to increment by values other than 1 or to start at a certain number. This provides some similar functionality to the built-in page naming feature of PW, and to this module recently posted by Stikki but I think it offers a little more flexibility than either. Having said that, I do like the simplicity of Stikki's new auto-increment module. Module Availability Here is my module on Github. Here it is in the module repository. Example Usage Here's how this module can be used to title and name a new page by adding a couple of simple hooks to site/ready.php. This example applies to new pages using a template called 'invoice' that can be quick-added to the page tree. In order to get the following to work, you must edit the template that will be the parent of the 'invoice' template and setup the template for children to "invoice" and set the "Name Format for Children" field to something other than the default blank value (I use title as my value.) <?php /** * Function to recognise our special template. */ function isInvoiceTemplate($template) { return ($template == 'invoice'); } /** * Pre-load the page title for invoice pages with a unique value * which includes a counter component. */ $pages->addHookBefore("Pages::setupNew", function($event) { $page = $event->arguments(0); $is_invoice = isInvoiceTemplate($page->template); $no_inv_num = $page->title == ''; if ($is_invoice && $no_inv_num) { $counter_name = 'WR-' . date('Y'); $number = $this->modules->get('DatabaseCounters')->next($counter_name, 10, 5000); $page->title = $counter_name . '-' . sprintf("%06u", $number); } }); /** * Prevent ProcessPageEdit from forcing an edit of the name if we got here * through a quickAdd from ProcessPageAdd. We can do this because we * preset the title field in the Pages::setupNew hook. */ $pages->addHookAfter("ProcessPageEdit::loadPage", function($event) { $page = $event->return; $is_invoice = isInvoiceTemplate($page->template); $is_temp = $page->hasStatus(Page::statusTemp); if ($is_invoice && $is_temp) { $page->removeStatus(Page::statusTemp); $event->return = $page; } }); Note, the above code + module is one direct solution to the problem posted here by RyanJ. Version History 1.0.0 The initial release.
    2 points
  8. So a while ago I started a thread about using an existing processwire as the back end for a mobile app. There was some discussion about how viable it was, but i've been working with another developer and we've started to get somewhere. This iOS app https://appsto.re/gb/mtaH_.i uses http://www.dudmc.com/ as the back end. It's not perfect but we're pretty pleased so far.
    2 points
  9. Not suggesting that we need to replace CkEditor - I think the integration with PW is working quite nicely, but I just stumbled across this and thought I'd throw it out there as another future possibility: http://quilljs.com/
    2 points
  10. I've solve the problem by setting the setlocale(LC_ALL, 'xx_XX.utf8') in every case with the right locale code. SOLVED: The endsolution looks like this: foreach ($languages->find("name!=en") as $language) { $user->language = $languages->get($language->name); switch ($language->name) { case 'default': setlocale(LC_ALL, 'fr_FR.utf8'); $date = strftime("%d. %B %G", $page->getUnformatted('date')); break; case 'de': setlocale(LC_ALL, 'de_DE.utf8'); $date = strftime("%d. %B %G", $page->getUnformatted('date')); break; case 'it': setlocale(LC_ALL, 'it_IT.utf8'); $date = strftime("%d. %B %G", $page->getUnformatted('date')); break; } echo $date."<br />"; } I thought, that when I would change the user language on every loop, it would also change the LC_ALL but somehow it doesn't do that. So I set the setlocale manuallay on every loop. When you need other locale-codes here is a list of all languages(or probably the most of it): http://www.red-route.org/code/php-international-language-and-locale-codes-demonstration And also thank you to @LostKobrakai, he pointed me to the right direction!
    2 points
  11. Some of you may have read about it: there are a new core images field in the works for the PW 3 branch. I want to wait until this is released and then update the Croppableimages to sit upon that. I think it will become a new version for PW 3+ only, as there is the current version available for the PW 2 branch. Besides some PW 3 namespace issues there should be implemented changes to work with the new images field in that way, that it only enhances this with the cropbuttons but leave the other UI as is (reuse it). I'm not very good with this UI stuff, so, if I will not be able to do this myself, I will ask here for help on that. If this will be the case, I will provide an intermediate version that works with the PW3 and new image field first. Everyone who can't wait until then should use the slightly hacky upgrade procedure provided by @KentBrockmann and @noodles, two posts above this one.
    2 points
  12. Hello everyone, I always wanted to try out an ajax autocomplete search function, but never knew where to start. Of course there is the Ajax Page Search module by soma, but it seems that it was build around the basic site profile. In my case I wanted something more custom and I discovered in this thread the jQuery Plugin Typeahead by RunningCoder, which seemed to be nice. After many hours figuring out, how to combine this Plugin with ProcessWire, I finally got it implemented and want to share my solution with anyone, who also struggles with this topic. 1. Set-Up Typeahead Download the Typeahead-Plugin from the website (I prefer via Bower) and include the following scripts and stylesheets in your templates: <html> <head> ... <!-- Optional CSS --> <link rel="stylesheet" href="/vendor/jquery-typeahead/dist/jquery.typeahead.min.css"> <!-- Required JavaScript --> <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script> <script src="/vendor/jquery-typeahead/dist/jquery.typeahead.min.js"></script> ... </head> As next step we need the JSON data. 2. Install Pages to JSON To get the necessary data of all pages as JSON, I use the module Pages to JSON, which provides an easy way to output pages as JSON objects. Of course you can achieve this without this module, but I am not very experienced with JSON, so this module was really helpful. After you downloaded and installed the module, you can configure in the module settings page, which fields you want to output. You can select between own and system fields. For my purpose I selected only title and url to be outputted. 3. Output JSON Now, that we have the module configured, we have to output our search suggestions as JSON. I did it in my template file search.php like this: <?php namespace ProcessWire; // Check if ajax request if($config->ajax) { $results = $pages->find("has_parent!=2"); // Find all published pages and save as $results header("Content-type: application/json"); // Set header to JSON echo $results->toJSON(); // Output the results as JSON via the toJSON function } else { // Your own front-end template } To sum up, we search the pages we want as search suggestions and save them in a variable. Then we output them with the toJSON-Function by the Pages to JSON-Module. All of this happens in a Ajax-Request, that is the reason why we check first, if the page is called via an Ajax request. 4. Insert Form We can now embed the HTML form anywhere you want. Either in an header-include or a specific template. Also you can use your own classes, for this example I used the Typeahead-demo-mark-up and extended it a little. <form id="searchform" method="get" action="<?= $pages->get("template=search")->url ?>"> <div class="typeahead__container"> <div class="typeahead__field"> <span class="typeahead__query"> <input id="q" name="q" type="search" placeholder="Search" autocomplete="off"> </span> <span class="typeahead__button"> <button type="submit"> <span class="typeahead__search-icon"></span> </button> </span> </div> </div> </form> The action-attribute in the form-tag is the url of your search-site. This attribute is of course necessary to know where the form redirects you and where the JSON data is located. 5. Initialize Typeahead As last step we have to initialize the Typeahead-plugin jQuery like this: $(document).ready(function() { var actionURL = $('#searchform').attr('action'); // Save form action url in variable $.typeahead({ input: '#q', hint: true, display: ["title"], // Search objects by the title-key source: { url: actionURL // Ajax request to get JSON from the action url }, callback: { // Redirect to url after clicking or pressing enter onClickAfter: function (node, a, item, event) { window.location.href = item.url; // Set window location to site url } } }); }); We save the action url of the form in a variable, then we initialize Typeahead by selecting the input-field inside the form. As the source we can pass the action url and I included the callback, to link the search results with the site urls. Now you should have a nice ajax autocomplete search form, which of course you can further style and configure. I hope I didn't forget anything, but if so, please let me know. Regards, Andreas
    1 point
  13. As promised, here's a link to my module that RyanJ's been helping to test out.
    1 point
  14. Hi @zyON, I just submitted a pull request: --- Now when a image is resized via API, upload this size variation too to S3. I also changed line 21 to make it run on PW 3+ --- Could you kindly review it?
    1 point
  15. meanwhile i have found out, that if i set the cloning permission directly at role level (Access -> Role -> editor) and disable the cloning permission on template access level, the page tree cloning works, but now the cloning functionality is assigned to all editable templates. I think for now i can llive with that, although i'd be happier if i would have been able to configure cloning per template...
    1 point
  16. It seems like the setlocale part is only evaluated once on startup, whereas changing the user language like you're doing it probably only affects multi language fields and nothing else.
    1 point
  17. Could you add this and see if the locales are actually all correctly set: echo setlocale(LC_TIME, 0); Also are you sure these locales are actually available on your system? @Klenkes strtotime does not necessarily work correctly with all possible date/time formats, which processwire does provide therefore it's better to go this way: $timestamp = $page->getUnformatted('date'); // instead of strtotime($page->date)
    1 point
  18. @Filkaboy Thanks for reporting. I fixed this.
    1 point
  19. Problem solved. For anyone that runs into this problem here is what I found. Since /arrests/ has other data holder templates you can't pass the name of any of the children or you will get a 404 since those templates don't have a page. Work around is call, as in my example, instead of /arrests/february-2016/, since february-2016 is only a template without a page this generates an error. Instead, enable url segments on /arrests/, then call /arrests/s/february-2016/ Since there is no possibility of their being a data template named "s", it will load without a name collision. You can replace "s" with anything, as long as you know that none of your data templates will have that same name.
    1 point
  20. Sorry about that - you must be running PHP 5.3.x. I had some code in there that was 5.4+ only. I have made a fix so that it will work on 5.3. Please try again with the latest version on Github.
    1 point
  21. Hey @horst - you have created a beautiful lady! Thanks for giving me her number !
    1 point
  22. Nope. This module uses the built-in WireCache functionality which defines the following caching periods: const expireNow = 0; const expireHourly = 3600; const expireDaily = 86400; const expireWeekly = 604800; const expireMonthly = 2419200; This isn't possible, this module just uses the existing instagram endpoints.
    1 point
  23. I'm happy you find this tutorial useful. But since this topic is specific for the front-end and uses one of many plugins, I don't think this should be covered in the documentation. Because after all, ProcessWire doesn't dictate you how you should do things in the front-end.
    1 point
  24. for help with the native resizing methods, there is also PIA available
    1 point
  25. Thanks for educating me, teppo! I have never used GitHub (apart from downloading ZIP files and simple browsing) nor noticed the "forked from" line. Sooner or later I need to find the time to familiarize myself with GitHub, I suppose. And again, sorry for the off-topic question.
    1 point
  26. Check the name of the repository at GitHub. In this case there's this line right below it: That's a pretty good indication that this particular repository might be a fork In the GitHub workflow if you fork another repository you can send a pull request containing all your changes to the original repository / author. If you've changed the README in the fork, those changes will also be included in the PR. That's one reason not to include indication about this being a fork or anything like that. Of course you can get over this limitation by creating a separate branch for the changes intended for the PR, but that's extra work and most developers are just plain lazy
    1 point
  27. If it's single page than use "$page->category->id == $child->id"
    1 point
  28. Hi, ​ I have install this module on PW 3.0.12 and when I try to edit a template, this error popup..​ Fatal error: Using $this when not in object context in /site/modules/ProcessSetupPageName-master/ProcessSetupPageName.module on line 68 Do you have any idea why I have this error? Thank you
    1 point
  29. Thank you. I'll have a look when I get to it.
    1 point
  30. Here's some more info: https://github.com/ryancramerdesign/ProcessWire/issues/1613 ryancramerdesign commented Language fields fallback to default when a localized version isn't available. This is one case where you may want to retrieve the localized value programatically. $value = $page->get('mytablefield' . ($user->language->isDefault() ? '' : '_' . $user->language->name));
    1 point
  31. You can be sure that 99.99% of your issues in near future are between your chair and your computer and not ProcessWire.
    1 point
  32. Hey Marty - sorry for taking so long to get back to you - busy day So you could do this with Ajax calls to a PHP script like the following. It would be called whenever someone clicks on a property. This would be a toggle approach, which may or may not be appropriate depending on how the site is set up. In this case, the cookie would store an array of the property IDs. $pid = $page->id; if (!in_array($pid, $favs)) { //add to the array if not already in it $favs[] = $pid; } else { $key = array_search($pid, $favs); unset ($favs[$key]); //remove from array if already in it } $data = base64_encode(serialize($favs)); setcookie('property_favs', $data, time() + 86400 * 100, '/'); Then to read the cookie back in, something like this: $favs = unserialize(base64_decode($_COOKIE['property_favs'])); That will give you an array of page ids that you can use to populate the user's favourites. If you want to go with a combination of javascript and PHP, you can do that also. Firstly, I recommend taking a look at this jquery helper: https://github.com/carhartl/jquery-cookie You can add the property/page id to the cookie using that and then retrieve on page load using PHP. Instead of storing an encoded array, you can also store a separated list of IDs. This example is using raw javascript: if(readCookie('property_favs')){ document.cookie = 'property_favs=' + readCookie('property_favs') + escape('|' + pid) + '; path=/'; } else{ document.cookie = 'property_favs=' + escape('|' + pid) + '; path=/'; } So if the cookie exists, then read it and add on a new pid after a pipe character and escape it so it can be stored in the cookie. If the cookie doesn't exist, create it with the current pid. The jquery cookie plugin will make this cleaner. Remember to use your developer console as it will show you the current cookie contents. In Chrome it is one of the options under Resources. In Firefox I seem to remember installing a plugin for Firebug to analyze cookies. It's really pretty easy once you play around with it. Let us know if you have any specific questions.
    1 point
×
×
  • Create New...