Jump to content

Raymond Geerts

Members
  • Posts

    365
  • Joined

  • Last visited

  • Days Won

    5

Everything posted by Raymond Geerts

  1. When using the jQuery datepicker in the backend for each Datetime field the following javascript might do the job. I have used this on front-end level, but it should work fine on back-end too. var setDate, todayDate = new Date(); $('input[name=schedule_date_end]').attr('disabled', 'disabled'); $('input[name=schedule_date_start]').change(function() { setDate = $(this).val(); if(setDate!='') { $('input[type=text][name=schedule_date_end]').datepicker( 'option', 'minDate', setDate ).removeAttr('disabled'); } else { $('input[type=text][name=schedule_date_end]').datepicker( 'option', 'minDate', todayDate ).val('').attr('disabled', 'disabled'); } }); $('input[name=schedule_date_end]').change(function() { setDate = $(this).val(); if(setDate!='') { $('input[type=text][name=schedule_date_start]').datepicker( 'option', 'maxDate', setDate ).removeAttr('disabled'); } else { $('input[type=text][name=schedule_date_start]').datepicker( 'option', 'maxDate', null ); } }); To be able to use custom javascript in the back-end you could use Martijn's "Admin Custom Files" module for that.
  2. Both ready.php and init.php are not loaded in 2.2.17 Upgrading is not possible at the moment due to several reasons. 1st) the site is hosted on a dedicated server and upgrading PHP might jeopardise the working of the other sites on the server. 2nd) in version 2.2.17 multi language was not integrated in the core yet, altough the client wanted a multi language site, so its build in manualy. I'm worried that upgrading to a newer version of PW, the manualy build multi-language functionality might stop to work. Thanks all for the suggestions and pointing in the right direction. I came up with a simple module that sets the template folder to /site/templates-dev/ for all superusers. class DevelopmentTemplates extends WireData implements Module { /** * getModuleInfo is a module required by all modules to tell ProcessWire about them * * @return array * */ public static function getModuleInfo() { return array( 'title' => 'Development Templates', 'version' => 001, 'summary' => 'Overrules the config templates folder for development purpouses', 'href' => 'http://www.processwire.com', 'singular' => true, 'autoload' => true, ); } /** * Initialize the module * */ public function init() { if (!$this->user->isSuperuser()) return; $this->addHookBefore('Page::render', $this, 'setDevTpl'); } public function setDevTpl($event) { $page = $event->object; if ($page->template == 'admin') return; $config = wire('config'); $config->urls->templates = 'site/templates-dev/'; $config->paths->templates = $config->paths->root . 'site/templates-dev/'; $config->debug = true; } } Note: only need this on older versions of PW, in my case 2.2.17. For newer PW versions use the following method as described on ProcessWire Recipes where you coudl use if($user->isSuperuser()) https://processwire-recipes.com/recipes/use-different-sets-of-template-files/
  3. Hi Wanze, Thanks for the suggestion, will do it the way you describe and overrule the config values in the module. Proost!
  4. I'm trying to check if the user is a superuser with the following IF statement. if ($user->isSuperuser()) Normaly the works fine, even in the /site/config.php file. The thing is, i'm working on an older site build with PW 2.2.17 which i can not upgrade at the moment. Does anybody know how to get the current user object in to the config file? I also tried $wire->user or wire('user') which seem all to be NULL
  5. I had this kind of issue with cached navigation (one for desktop, one for mobile = mmenu), and wanted to make sure the database cache is removed as soon i save one of the pages displayed in the navigation. I came up with a module that hooks in to page save. It removes the necessary cache items asfollow: - when pages with template settings_socialmedia or settings_textblocks are saved it removes the main.footer cache entry - when pages with template list_agenda or item_agenda are saved it removes the block.agenda cache entry - when any of the pages in $navigationPages are saved it removes both the man.navbar and main.mmenu cache entries <?php /** * ProcessWire Save Actions * * Actions to be run on page save * * @ 2015 Raymond Geerts * * ProcessWire 2.x * Copyright (C) 2014 by Ryan Cramer * Licensed under GNU/GPL v2, see LICENSE.TXT * * http://processwire.com * */ class SaveActions extends WireData implements Module { /** * Return information about this module (required) * */ public static function getModuleInfo() { return array( 'title' => 'Save Actions', 'summary' => 'Actions to be run on page save', 'version' => 1, 'autoload' => "template=admin", 'singular' => true, 'author' => 'Raymond Geerts', 'icon' => 'floppy-o' ); } public function init() { $this->pages->addHookAfter('save', $this, 'actionsAfterSave'); } public function actionsAfterSave($event) { $page = $event->arguments[0]; if ($page->template == 'settings_socialmedia' || $page->template == 'settings_textblocks' ) { $this->cache->delete("main.footer"); $this->message("Cleaned WireCache for front-end footer HTML"); } elseif ($page->template == 'list_agenda' || $page->template == 'item_agenda' ) { $this->cache->delete("block.agenda"); $this->message("Cleaned WireCache for front-end agenda block HTML"); } else { $homepage = $this->pages->get('/'); $navigationPages = $homepage->and($homepage->children); foreach($homepage->and($homepage->children) as $item) { if ($item->template->altFilename == "clickthrough" && $item->hasChildren() ) { $navigationPages->append($item->children); } } if ($navigationPages->has($page)) { $this->cache->delete("main.navbar"); $this->cache->delete("main.mmenu"); $this->message("Cleaned WireCache for front-end navbar HTML"); } } } } It saved some page-loading time when caching navigations. Because they are displayed on every page, its a smart thing to do. A trick to make the current page (and parents) have a selected / active class i did the following: in the head of the _main.php <script> var globalJS = <?php $globalJS = array(); $globalJS['parents'] = $page->parents()->remove($homepage)->append($page)->each('id'); echo json_encode($globalJS, JSON_FORCE_OBJECT); ?> </script> in the navigation i put the page ID in each <li> item like this: echo "<li id='navbar-pageID-{$item->id} role='presentation'>"; (and in mmenu as follow:) echo "<li id='mmenu-pageID-{$item->id}'>"; In my main.js file i have the following: (function() { // set navigation menu items active $.each(globalJS.parents, function(key, value){ $('#navbar-pageID-'+value).addClass('active'); $('#mmenu-pageID-'+value).addClass('current'); }); }());
  6. Let say you have these pages in your tree: Products (1005) |- page 1006 |- page 1058 |- page 1062 You could add a field of the type Page (FieldtypePage) with a name "mobile_sort" or something alike. make sure you can select multiple pages, and it will list the children from the Products (1005) page (or whatever your parent page is named). Then add this field to the Products page template. Next edit the Product page and select all the children and sort them accordingly for mobile. You could then create a navigation for your mobile listing all pages attached to the "mobile_sort" field. Another way i think will work is to use the sorting of the mobile_sort field in your selector. sort=mobile_sort.sort
  7. I can only point you in the direction how i would go about it. I would create a simple module, that only has one function and that is to redirect the user to the home page, once he is logged in to the manager. In the module method getModuleInfo() make sure the module only runs on the backend side by setting 'autoload' => "template=admin" In the module init() function do something like this public function init() { // only company role, else do nothing if(!$this->user->hasRole('company')) return; // redirect to home page or call a 404 here }
  8. From within a template its simply: $thisone = $pages->get('/some/page/'); $pages->delete($thisone); // or $pages->trash($thisone); You might want to do some check ups before if($thisone->deleteable() && wire('config')->demo == false && $thisone->rootParent != wire('pages')->get('/trash/') && $thisone->rootParent != wire('pages')->get($this->config->adminRootPageID)) { // delete or trash } ps. taken from the ProcessPageDelete module https://github.com/NicoKnoll/ProcessPageDelete/blob/master/ProcessPageDelete.module
  9. Looks nice, and search seems incredible fast. Do you use caching for the search queries?
  10. As Teppo mentioned, Nothing beats real pages to work with when creating a new website. For example for setting up (news) lists, with pagination, prev/next buttons on a detail page, front-end search and that kind of features in a site require at least some content to be available. As with dummy i just ment real (temporary) pages to work with. As you point out, these temporary pages should also be able to easily deleted, for example with the module GUI and on uninstalling the module. Altough if this AutoContent module can work with the BatchChildEditor, that might just do the job too and be enough to quickly add and remove some temporary pages.
  11. About a week or so ago i was thinking, it would be nice to have a module that can add dummy content Maybe an early feature request (if its not already in your module). An auto page generator, where one can set: - the amount of pages to create - pick a parent page - pick a template For example: - 15 - /news/ - news-article Then it will create 15 news articles with Lorem ipsum text and dummy images
  12. [update] Seems Google Cloud Platform has now a "one click" launch for a VM with ProcessWire installed. https://cloud.google.com/launcher/solution/bitnami-launchpad/processwire
  13. In general when i have to use a field value more than once i tend to set it to a variable and use that. I like to keep my code as minimal as possible.
  14. anything funky makes we work faster, together with PW its light lightning fast
  15. I do not think the default required checkbox is sufficient for that, since even tho the field becomes a required value, the page will just save. It can be achieved with a simple process autoload module that hooks in to Pages save() method as a before hook. $this->pages->addHookBefore('save', $this, 'yourMethodToCheckTheValue'); Create a method that checks the validity of the value. When the value is invalid you can replace the method you are hooking so that it will not continue and save the page, perhaps throw in a nice error rmessage for the admin to read.
  16. Comonly i create list > item template combinations. Like agenda list containing agenda items as children, or a news list containing news items. Now in most cases the list templates title would be set once (Agenda / News) and after that does not have to be editable (or my wish to be hidden). For that it would be nice to have an extra choice in the field visibility settings: Open when blank, hidden when populated So that while creating the page, the developer can set the title whichafter it wont be shown anymore, thus not being able to modify it. I can do this manualy, create all the list pages and then modify the template setting the title field to hidden for the specific fieldgroup.
  17. Well, show_in_slide= will miss the ones that have value 0 while show_in_slide=0 will miss the ones that have no value but show_in_slide!=1 will fetch all that are empty and those with value 0 (or anything that has not value 1 for that matter) @rooofl i like your avatar, you realy wrapped your head around it
  18. try show_in_slide!=1 If i recall correctly the checkbox has no default value of 0 so it could be empty
  19. Solved, i found the module preventing unpublishing, namely: Custom Page Permissions Seems that it was installed year ago when building the website. I have no clue what the reason for it was. Anyway uninstalling this module solved the issue
  20. I have a role named editor. This role has the following permissions: page-view, page-edit, page-move and page-sort I have a user with this role, which is able to create and publish a page, which is all great. What the user can not do is unpublish the page. But i want to user to be able to do that too. Am i missing something, maybe a module to do this? As far i can see only the superuser can unpublish a page.
  21. You probably discovered a bug or an inconsistancy. With a multilanguage set up the following two fields can each have an unique value per language: - Date Input Format Code - Time Input Format Code Altough the Select boxes are not seperated per language - Date Input Format - Time Input Format While it is expected that it picks the language that is active with the current user. When you are loggedin and have selected German language in your account it will get the values from the corresponding language specific fields. When the field is empty it will use the default language as fallback value. edit: Reported it as a possible issue on github: https://github.com/ryancramerdesign/ProcessWire/issues/1268 - Have to see what Ryan has to say about it. It could be by design and have a logic explination.
  22. Could you check if the field "Time Input Format Code" contains "H:i" after saving when you pick 17:10 at "Time Input Format"
  23. When the user specific data does'nt have to be queryable / searchable on database level, all you might need is a textarea field in which you put a JSON object with all the data. Then JSON encode the data that the user submitted, save it to the textarea, and when fetching the data JSON decode it to have it available in an Array or Object. When you want to be able to query / search / filter directly on database level or have huge amounts of data this aproach might not fit your needs. Although as soon you have a JSON decoded object retreived from the database you can search / filter using the API, but then it is all done in memory instead of the on database level.
  24. I cant wrap my head around it, why a blog tool with a checklist of 100 tasks became so popular as CMS.
  25. This module is merely intended for a visual gui on back-end level to store and output an integer. When you need (star) rating / voting on front-end the following module might fit your needs better: http://modules.processwire.com/modules/page-ratings/
×
×
  • Create New...