Jump to content

adrian

PW-Moderators
  • Posts

    11,182
  • Joined

  • Last visited

  • Days Won

    372

Everything posted by adrian

  1. There is this module: http://modules.processwire.com/modules/download-guard/ You might also find some useful info in these posts: https://processwire.com/talk/topic/5820-protected-downloads/ https://processwire.com/talk/topic/5292-proctecting-files-from-non-logged-in-users/ https://processwire.com/talk/topic/6463-website-with-protected-download-area/ https://processwire.com/talk/topic/869-protected-files/
  2. Or you can go even shorter with: $fields->yourField->icon
  3. No problem! "start" is hidden - try turning on Advanced Mode on the API Cheatsheet and you'll see it under the selectors section.
  4. I think you need to override the "start" selector that is being added from PagerNav. Setting it to 0 should fix things. $grandChildren = $child->children("limit=5, start=0");
  5. OK, I think they need to be treated as separate translatable strings, like this: $fieldEnabledTemplates->description = __('The batch editing option will only be available for the selected templates . '. "\n" . __('NB Leave blank to allow all templates.', __FILE__); Or using $this->_() it would look like: $fieldEnabledTemplates->description = $this->_('The batch editing option will only be available for the selected templates . '. "\n" . $this->_('NB Leave blank to allow all templates.', __FILE__); Seems a shame to have multiple strings to translate though just because there is a line break, but as far as I can tell there is no other way. Or maybe it actually makes more sense so the translator can't accidentally remove the line break?
  6. Thanks for testing. I'd probably be OK without the line breaks in those spots in your screenshot, but what about this line for example: https://github.com/adrianbj/BatchChildEditor/blob/master/BatchChildEditor.module#L1198 - this definitely needs the line breaks. It seems like this should work. Could you please confirm? $fieldEnabledTemplates->description = __('The batch editing option will only be available for the selected templates.'."\n".'NB Leave blank to allow all templates.', __FILE__); I probably should switch them all over to: $this->_() for the speed advantage since they are all inside a class, but that can wait for now.
  7. Thanks @Manfre62 for testing. I don't think the double quotes is the issue because in @mr-fan's screenshot he has translated the "Configurable Pages" option and the description for it also uses double quotes. I don't use translated modules though, so could you please double check and confirm that it is the double-quotes. It's always been my experience that you can't use \n inside single quotes, which is why I use them in situations where I want to break things across more than one line. "NB" is a common acronym in English for Nota bene which is latin for "Note well".
  8. Thanks for the kind words and for your efforts on this translation - must have been quite a task - there's lots to translate in this module I accepted your PR and also fixed (I think) the issue you were having translating that the enabled templates setting description. Please let me know if it works now.
  9. Adminbar needs to have its classes prefixed to prevent some conflicts with other libraries. I posted about it here: https://github.com/apeisa/AdminBar/issues/12 I would also recommend using teppo's fork: https://github.com/teppokoivula/AdminBar It takes care of several issues with newer versions of PW, although I don't think it includes the class fixes.
  10. The CMS of the future!! http://www.algoritma.it/blog/processwire-il-cms-del-futuro/ Thanks to @enricob A Softaculous installation tutorial video:
  11. True, it is the current visit - not what I was getting at, but it does make it rather useless for you If you add "LIMIT 1,1" at the end of the query you should get the last login. Only catch is that you won't get anything if there has only been the one login for that user, but that is actually probably what you want anyway in this case. PS I've updated my post above to include the LIMIT so others will have a working solution.
  12. Nice, although I would suggest using PDO - I know teppo's module doesn't use it yet, but I am sure he will update sometime soon. Try this: $query = $database->prepare("SELECT login_timestamp FROM process_login_history WHERE user_id = :userid AND login_was_successful=1 ORDER BY login_timestamp DESC LIMIT 1,1"); $query->execute(array(':userid' => $user->id)); $lastvisit = $query->fetchColumn(); echo $lastvisit; Note that I also went with the user id - always better to look up an integer than a text field. PS - Just remember (and I know I already said it above), but this really isn't the "last visit" - you can go forever without needing to login if you visit a site regularly before the session has expired.
  13. How often do you actually log out of a site? My point is that I am not sure how relevant last login/logout is, which is why I went with last_page_load and actually record the date/time the user last loaded a page. My example here: https://processwire.com/talk/topic/5534-new-articles-to-users-with-cookie/?p=53935 takes that approach and works well for me and it about as close as you will get to knowing when a user was last on your site. Is there a reason that won't work for you? If you're sure that they are always going to logout (and therefore be logging in again each time they visit the site) then this should work for you. Put it in your templates/admin.php file. wire()->addHookAfter("Session::login", function(HookEvent $event) { $user = wire('user'); $user->of(false); $user->last_login = $user->current_login; $user->current_login = time(); $user->save(); }); Note that I have two fields there - current_login and last_login, and that the value from current gets moved to last each time the user logs in and then a new current is set. Then on your page you can simply output the value of $user->last_login Does that help? You could potentially solve the problem with a session variable to store the last login before it is overwritten by the hook on login, but I think this is cleaner and more reliable. PS If you don't want to add these fields to your user template, you could make use of teppo's Login History (http://modules.processwire.com/modules/process-login-history/). It maintains a dedicated database table of logins which you could query.
  14. http://eressurs.no/no/processdisplay/
  15. The modules directory now has an option for PW 3.0 compatibility. Please test your modules with the latest dev version of PW and tag your modules with the new 3.0 option if everything works as expected. Thanks for all your contributions which help make PW what it is! For those who haven't discovered it (it's not terribly obvious), here is a list of all the modules that are currently tagged as being compatible with 3.0: http://modules.processwire.com/versions/3.0/
  16. No problem at all - there is nothing wrong with the approach you took - completely valid code and appropriate in many cases so long as you don't need additional logic. Since you're new to PHP (and maybe other scripting languages?), you may not have seen ternary operators before, so here is a great explanation: http://davidwalsh.name/php-shorthand-if-else-ternary-operators They shouldn't be used instead of if/else in all situations, but in many cases they can make code simpler. If used incorrectly with too much nesting, they can become horrible to read If you want to stick to the style you have, you could do this: $staticPages = $about->children("sort=name"); foreach($staticPages as $staticPage) {?> <li class="list-group-item<?=$page == $staticPage ? " active" : ""?>"><a href="<?=$staticPage->url?>"><?=$staticPage->title?></a></li> <?}?> I find it messier, but others may prefer it. Also be warned about php shorttags: <?= vs <?php echo - not all servers will currently support shorttags, although it is the default in more recent versions of PHP.
  17. This should do it. Sorry for reformatting your code, but it becomes awkward trying to add ternary operators into a code block with PHP tags sprinkled into the HTML like that. $staticPages = $about->children("sort=name"); foreach($staticPages as $staticPage) { echo "<li class='list-group-item" . ($page == $staticPage ? " active" : "") . "'><a href='{$staticPage->url}'>{$staticPage->title}</a></li>"; }
  18. This should do the trick! $f = $fields->get("body"); echo '<i class="fa '.$f->icon.'"></i>'; PS make sure you load this on the page: <link rel="stylesheet" href="/wire/templates-admin/styles/font-awesome/css/font-awesome.min.css" type="text/css">
  19. Clients need to regularly update page data from CSV files? Check out the enhanced Batch Child Editor (http://mods.pw/6K) to predefine CSV column - PW field connections.

  20. You might be able to get some ideas from my Table CSV Import / Export module - even if you don't have Profields Table, you should still be able to grab the bits of code you need - take a look at the "Export as CSV" button on the screenshot in the first post: https://processwire.com/talk/topic/7905-profields-table-csv-importer-exporter/ In the repo you'll notice there is a helper Process module (ProcessTableCsvExport.module) for handling the action when that button is clicked. Hope that helps a little, although keep in mind that it uses a hidden iframe technique to spawn the download and as noted by others above, you will probably need an AJAX approach in this case.
  21. Try this: $t = $templates->get("basic-page"); $nt = $templates->clone($t); $nt->save();
  22. Ok, all new features have now been merged to the master branch. I have changed the release state from Stable to Beta for this release. Really just as a precaution for the Update mode options until I have had more feedback on this. Please let me know how this new version works out for everyone. It will probably take you a while to go through all the new configuration options, but I think it's worth the effort. You can use this module as a simple replacement for the Children/Subpages section of the Children tab (which allows for much quicker editing of child pages), all the way through to a fully customizable CSV import tool for site site editors to create and update pages. Feel free to send through any other ideas along with any issues you come across.
  23. You want to use addStatus so that your change goes from 1 to 2049 so that when you remove unpublished via the admin it takes off the 2048 that means unpublished and returns it to one. If you set the status directly to unpublished, it will end up being 2048 which is not what you want. $page->of(false); $page->addStatus(Page::statusUnpublished); $page->save();
  24. Great discussion everyone. In a hurry, but just wanted to mention that I have used that blueimp uploader on a site for several years now and found it awesome, so these guys definitely do good work!
  25. https://processwire.com/blog/posts/processwire-core-updates-2.5.28/#wirecache-upgrades and a little more hot off the press: http://processwire.com/blog/posts/processwire-2.6-rc1-2.5.29-and-more/#whats-new-this-week-processwire-2.5.29
×
×
  • Create New...