Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/26/2015 in all areas

  1. This module was already introduced in another thread yesterday, but since each module should have a thread of its own, here we go. Login Scheduler adds a couple of new fields to user template(s) and provides support for disabling login for non-superuser accounts either instantly (with a checkbox, "Login disabled") or by specifying a time range ("Login allowed starting from", "Login allowed until"). If a user is already logged in when login access is disabled, logout should be triggered during next session validity check (usually next page load). Starting from version 1.1.0, superuser accounts are not affected by this module at all. This is a safety mechanism and prevents you from locking yourself out of the whole system. You can grab this module from GitHub: https://github.com/teppokoivula/LoginScheduler.
    9 points
  2. Quick overview of some updates I'll be sending to Ryan tomorrow. New Features: Sidebar saves open/closed state. Sidebar opens/closes with arrow keys. Sidebar toggle icon moved. Search input is now a masthead overlay. It's takes the same number of clicks as before (one) since the input is focused on click. The overlay can be closed with the (x) icon, or the up arrow key. User information is now customizable to any text fields associated with the user template. So you can use fields like a first_name last_name. Custom color schemes can be set in /site/modules/AdminTheme/AdminThemeReno/styles/. These files survive PW updates, so you can easily create custom variations on the theme without having to reinstall it after an update. (Thanks Pete!) Top navigation items are now hookable, so you can add additional single or nested items. Top navigation has quicklinks to ProcessWire resources for Superusers. (forums, docs, github, cheat sheet, etc..) There are other tweaks and fixes here and there, but these are all I can think of right now... Changes to masthead and top navigation Superuser Quicklinks User Information Search Overlay
    7 points
  3. I'll have to get my Reno colour schemes sorted on Sunday when I'm back off holiday. Tom - can you send me a copy of the theme when you send it to Ryan so I can make sure they're 100% compatible before the updated theme is released - shouldn't take me long.
    4 points
  4. One more solution: https://github.com/teppokoivula/LoginScheduler. This has been on my todo list for a while, this topic just gave me a reason to put it together. Should work, but not 100% guaranteed
    4 points
  5. Did you try to write "return " ahead of the above command like this: return $pages->find('parent=/tags/' . $page->parent->name . '/'); ?
    2 points
  6. It should make a difference, as files and images fields are always multi value fields only the output formatting does provide the necessary shortcuts when accessing single image/file fields. As of() is false when saving things you need to handle the field as multi value field.
    2 points
  7. OH NO, this is just so awesome. Please how can i get this, Reno you're the man, this is awesome my clients are gonna love this.
    2 points
  8. I exported a CSV file from freebase.com that contained all the skyscraper fields I wanted to use. Then I created a simple shell script to import it from the CSV. Note that I only used a shell script for convenience, you could just as easily do this from a ProcessWire template file if you preferred it or needed to do this from Windows, etc. Below is a simplified example of how to do this. The example is fictional and doesn't line up with the actual structure of the skyscrapers site, nor does it attempt to create page relations or import images. If you are interested in how to do that, let me know and I'll keep expanding on the example in this thread. But I wanted to keep it fairly simple to start. First, here is the contents of a CSV file with each line having a skyscraper building name, city, and height. /skyscrapers/skyscrapers.csv (Building, City, Height): Sears Tower, Chicago, 1400 John Hancock Tower, Chicago, 1210 Empire State Building, New York City, 1100 IBM Building, Atlanta, 860 Westin Peachtree, Atlanta, 790 Next, create a new template in ProcessWire and call it "skyscraper". Create a text field for "city", and an integer field for "height" and add them to the skyscraper template. Create a page called "/skyscrapers/" in ProcessWire, that will serve as the parent page for the skyscrapers we'll be adding. Here is the command-line script to load the ProcessWire API, read the CSV data, and create the pages. As I mentioned above, this could just as easily be done from a template, where the only difference would be that you wouldn't need the shebang (#!/usr/local/bin/php -q) at the beginning, nor would you need to include ProcessWire's index.php file. /skyscrapers/import_skyscrapers.sh: #!/usr/local/bin/php -q <?php // include ProcessWire's index file for API access // (this isn't necessary if you are doing this from a template file) include("./index.php"); $fp = fopen("./skyscrapers.csv", "r"); $template = wire('templates')->get("skyscraper"); $parent = wire('pages')->get("/skyscrapers/"); while(($data = fgetcsv($fp)) !== FALSE) { // create the page and set template and parent $skyscraper = new Page(); $skyscraper->template = $template; $skyscraper->parent = $parent; // set the skyscraper fields from the CSV list($building, $city, $height) = $data; $skyscraper->title = $building; $skyscraper->city = $city; $skyscraper->height = $height; // set the URL name, i.e. Sears Tower becomes "sears-tower" automatically $skyscraper->name = $building; // save the skyscraper $skyscraper->save(); echo "Created skyscraper: {$skyscraper->url}\n"; } To do the import, make the script executable and then run it from the command line: chmod +x .import_skyscrapers.sh ./import_skyscrapers.sh OR, if you are doing this from a template file, then load the page (that is using this template) in your web browser, and that will execute it. The output should be: Created skyscraper: /skyscrapers/sears-tower/ Created skyscraper: /skyscrapers/john-hancock-tower/ Created skyscraper: /skyscrapers/empire-state-building/ Created skyscraper: /skyscrapers/ibm-building/ Created skyscraper: /skyscrapers/westin-peachtree/ If you go into the ProcessWire admin, you should see your skyscrapers. I used an example of CSV file for simplicity, but the same method applies regardless of where you are pulling the data from (web service feeds, etc). For the actual skyscrapers demo site, I used Freebase's web services feed to pull the data and images, etc.
    1 point
  9. As of 2.6.5dev there are these neat extra action buttons 'unpub', 'hide' etc in the page tree. In ListerPro we can define our own actions as modules that extend the new PageAction class. Ryan mentions in the ListerPro forum that the page actions are a new feature of PW and that they are independent from ListerPro. It would be great if we could define our own page actions and attach them to the page tree or to lister results. Looking at the code I am not quite sure how we can achieve that through a hook or the like. So for all not so code savvy PW "hookers" (pun intended) it would be great to get some documentation on this new feature.
    1 point
  10. You should use Fieldtypeoptions now which is built into the 2.6 branch - it is a core module that does the same and more
    1 point
  11. I've not used any of the modules around the forums for this but would recommend trying something like Soma's solution about halfway down in this topic: https://processwire.com/talk/topic/1071-page-fieldtype-two-way-relation/ You'll need to hardcode the two fields you want to "sync" but this also explains the problem actually - you can't just have the same field at the other template automatically as you might want to put it in certain place and label it differently etc (makes sense since its doing the reverse in the other template). I'm not sure there's a more sensible way than Soma's module as otherwise it has to make too many assumptions whereas his is basically a case of creating two page fields to lookup the relevant pages in each template and syncing them with the module when a page using either template is saved. Hope that makes sense?
    1 point
  12. @BernhardB Oh wow, I did not know about $maxlevel. Thank you! I am very happy to try out this code and see how it works. That makes three solutions I have to try now! Feeling lucky to be part of such a helpful dev community.
    1 point
  13. Thanks all. I've got one issue to work out with mobile safari, after that it should be ready. @Pete, I have local copies of your colors that are compatible. I'll send everything to you later today - you can make any additional changes - shouldn't take long at all.
    1 point
  14. you could limit the child-levels like that: $items = your_selector_including_all_levels; $maxlevel = $page->parents->count() + 2; foreach($items as $item) { if($item->parents->count() <= $maxlevel) { // echo your markup } } that may be not the cleanest solution as you select more data than necessary and remove the unwanted items afterwards, but if performance is not an issue i think that would be an easy solution? ps: didn't check the code! just wanted to show the idea...
    1 point
  15. Or call it like this: $input->post("first-name");
    1 point
  16. @Peter Rename your field to "first_name". PHP does not support variables with dashes. else if(!$input->post->first-name) echo "First name exists, but is blank"; From the code above you can't say if it's empty or does exist, because NULL or EMPTY are casted implicitly to false by PHP. You'd need the following distinction: if ($input->post->first_name === null) { echo 'First name does not exist'; else if ($input->post->first_name === '') { echo 'First name exists but it\'s empty'; }
    1 point
  17. Tom, I believe you have the ability to read my mind. How did you do that? Can't wait for these updates, simply superb!
    1 point
  18. I've been using the checkbox method and a simple hook for a while. Works quite well.
    1 point
  19. Another approach: You could add a checkbox "inactive" to the users template. Then hook after login and if this checkbox is checked, return false.
    1 point
  20. Not tested, but should be a sufficient blueprint. <?php /** * Add own PageList actions * * ProcessWire 2.x * Copyright (C) 2014 by Ryan Cramer * Licensed under GNU/GPL v2, see LICENSE.TXT * * http://processwire.com * */ class AddPageActionsToPageList extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Page Actions to Page List', 'version' => 1, 'summary' => 'Adds PageActions to Page List actions', 'singular' => true, // Limit the module to a single instance 'autoload' => true, // Load the module with every call to ProcessWire ); } public function init() { $this->addHookAfter('ProcessPageListActions::getExtraActions', $this, 'addActions'); $this->addHookBefore('ProcessPageListActions::processAction', $this, 'exeActions'); } /** * Add the new actions */ public function addActions($event) { $page = $event->arguments[0]; $actions = $event->return; // We do not overwrite existing core actions $actions = array_merge($this->createActions($page), $actions); // $event->return = $actions // Shouldn't be needed } /** * Create the actions */ protected function createActions($page){ $actions = array(); if($page->id == 1 || $page->template == 'admin') return $actions; if($page->template->noSettings || !$page->editable('status', false)) return $actions; $adminUrl = $this->wire('config')->urls->admin . 'page/'; if($this->wire('user')->hasPermission('action-email', $page) && !$page->isTrash()) { $actions['action-email'] = array( 'cn' => 'Email', 'name' => 'Email', 'url' => "$adminUrl?action=PageActionEmail&id=$page->id", 'ajax' => true, ); } return $actions; } /** * This is run when an action is initiated * * This can only been called if a page is editable. */ public function exeActions($event) { list($page, $action) = $event->arguments; $actions = $this->createActions($page); // This way checking for roles or other access rules is not duplicated. // If the action is still created, it's also actionable. if(!isset($actions[$action]) || !$page->editable()) return; $success = false; $needSave = true; $message = ''; $remove = false; $refreshChildren = 0; // If $action is the name of the module if(strpos($action, "PageAction") === 0){ $module = $this->modules->get($action); if($module){ $module->action($page); $success = true; $message = $this->_("Email sent"); } } // If no module was supplied select manually if(!$success){ switch($action){ case "SomeOtherAction" // Do stuff break; } } // Return if success, otherwise move on to the hook function if(!$success) return; else $event->replace = true; // Return information $event->return = array( 'action' => $action, 'success' => true, // Fails are managed later by hooked function 'message' => $message, 'updateItem' => $page->id, // id of page to update in output 'remove' => $remove, 'refreshChildren' => $refreshChildren, // also available: 'appendItem' => $page->id, which adds a new item below the existing ); } }
    1 point
  21. 1 point
  22. I was actually thinking of converting all feature request/enhancement issues to something in the PW website (powered by PW pages). Something like the sites directory, with the ability to "like" requests, so that the most requested ones could rise to the top and get more focus. This would also get them out of GitHub, so the focus there can be on issue reports. Though I think it's good to still submit feature requests at GitHub, but I would just move them to the more dedicated system and close them out there once that's done.
    1 point
  23. @Craig: first of all thanks for this module! I did run into a small issue while using it on a SSL server. Mandrill gave me a "Unable to get local issuer SSL certificate" error and did not want to send any e-mails. It was a relatively easy fix but it does require changes in the Mandrill.php. I don't know if it should be changed in the module, but I'm posting it here for anybody else who runs headfirst into this error. 1) I downloaded the following file, renamed it to carcert.pem and placed it in the Mandrill directory. 2) I added the following code after line 72 of Mandrill.php curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, TRUE); curl_setopt($this->ch, CURLOPT_CAINFO, __DIR__ . "/cacert.pem"); And boom! It works (well for me at least). I hope this helps somebody.
    1 point
  24. I share the same need as Can and icietla: the hability to disable the main language of any given page in order to exclude it from listings and access. For the time being, it is only possible to disable for non-default languages.
    1 point
  25. Valid point apeisa, though the BCP47 does already contain this, with the x- extension which is dedicated to private use. I think this would be even more powerful, because it could use the base language as a fall back. For example fr-x-myclient > fr > default/en. That way you wouldn't have to maintain the whole translation strings, just the part you need to specify. I don't know if this would be overkill/technically feasible, but it's an option. Of course free-form could work too, but I would propose like you do that each language be set using a dropdown list of predefined ones (to make support easier), and have a "Custom" entry where an input field would appear to set it as required.
    1 point
  26. I think it's a good idea too. ProcessWire currently has one of the best multi language support I've seen, but there is room for improvement that I'd like to see too. For example: I've submit a feature request/proposition to support UTF8MB4 in the database by default (would add support for emoticons). There is already some support for this, but by default the SQL loaded to create the basic pages needs to be changed manually. One other thing that might be nice, is instead of letting language name be free-form, we could stick to BCP47 (validator — registry). As an added bonus, we could package language packs for modules or else in a /lang/xx[-xx] format, instead of having to constantly install them manually. It would also make it possible for PW to set setlocale() by itself, without having to add it manually. Default could have a way to set an alias, so that at runtime the language functions would recognize "en" and "default" as the same, for example. This would also be necessary for the second proposition. What are your thoughts on this guys/gals? I think Ryan would probably be glad to receive a patch for this if it's of good enough quality, this could be a community effort. Should we open a new topic to discuss all that?
    1 point
×
×
  • Create New...