Jump to content

adrian

PW-Moderators
  • Posts

    11,097
  • Joined

  • Last visited

  • Days Won

    365

Everything posted by adrian

  1. Hi @joer80. Looks good! Just a few minor layout issues I noticed quickly in Chrome (not tested elsewhere): Unnecessary horizontal scrollbar appearing at all widths The very bottom dark grey is full width (maybe more), but the lighter one and the banner one are not quite (seems like only on the homepage) At narrower screen widths the contents of the bottom list of links (light grey div) are touching the left edge of the viewport - needs some margin/padding
  2. This works: $this->addHookAfter('InputfieldImage::render', $this, 'addTest'); public function addTest(HookEvent $event) { $event->return .= 'test'; } No need to go with InputfieldFile because your changes are only relevant to image fields.
  3. isLoggedIn() doesn't actually have anything to do with whether the user is actually logged in or not - all it does is check if the current user visiting the page is in fact a registered user and not a guest: https://github.com/ryancramerdesign/ProcessWire/blob/6cba9c7c34069325ee8bfc87e34e7f1b5005a18e/wire/core/User.php#L294 So there is no way it could be of any use for looking up whether a specific user is currently logged in or not EDIT: Sorry that might have come across too adamant - of course the user's id is stored in a session variable. I think Pete's synopsis of how tricky this can be is spot on!
  4. I think this should help with what you are trying to achieve: function isUserOnline($userid, $mins=1){ $table = SessionHandlerDB::dbTableName; $sql = "SELECT COUNT(*) FROM $table " . "WHERE ts > '" . date('Y-m-d H:i:s', (time() - ($mins * 60))) . "' " . "AND user_id=" . $userid . " ORDER BY ts DESC LIMIT 1000"; $result = wire('db')->query($sql); $row = $result->fetch_array(); return $row[0]==1 ? true : false; } $whois = $pages->get("template=user,name={$page->name}"); if(isUserOnline($whois->id)) { echo 'true'; } else{ echo 'false'; } With this function you can pass the id of your $whois user to the function and have it return true or false as to whether they are logged in or not. You can pass a second argument to increase the time from 1 minute if you'd prefer. eg: if(isUserOnline($whois->id, 5)) { // 5minutes Hope that helps.
  5. I didn't have to bother. Check out this answer: https://processwire.com/talk/topic/5318-select-online-users/?p=51205
  6. I see - now I understand. I don't think there is any way to interact with the sessions table using the API, so I think you'll have to use some SQL. Take a look here at the code from the Sessions Process module: https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/modules/Session/SessionHandlerDB/ProcessSessionDB.module#L62 I don't have time to write up an example at the moment, but hopefully you can figure it out from there. Otherwise, I will try to help later
  7. Are you trying to test if the logged in user is the person whose page it is? if($user->name == $page->name)
  8. The path history module should take care of those redirects for you. I haven't actually used the date archiver module, so not sure if there is something built-in to take care of this, but from a quick read, it doesn't sound like it. One other possibility is http://modules.processwire.com/modules/process-redirect-ids/ which allows URLs to contain the ID of the page, so even if the name/path changes, the link will always work - just like the way this forum uses the topic ID rather than the title part of the url to load the page.
  9. Thanks @jtherczeg. The best way to handle bugs (no matter how small) is probably by posting an issue at Github (rather than a PR). Thanks for spotting!
  10. Yep $p = $pages->get(xxxx); $p->parent = $pages->get("/archive/"); $p->save(); But with that approach, you might find the Date Archiver module useful: http://modules.processwire.com/modules/process-date-archiver/
  11. Hi @mameluco and welcome to the forums. Here is a pretty comprehensive thread on the issue: https://processwire.com/talk/topic/858-sqlite-has-ftt-could-it-be-a-viable-alternative-database-backend-for-pw/
  12. There are a few small things wrong with that code - missing parent, save not save() etc. This works for me: $p = new page(); $p->template = 'basic-page'; $p->parent = $pages->get(1); //set parent to homepage $p->title = 'testing7'; $p->save(); $p->images->add("http://i.imgur.com/nFJzvUQ.jpg"); $p->save(); Are you talking about the thumb that gets created when you have "Display Thumbnails in Page Editor" checked. The 200 in the filename is throwing me, since these are usually 100px high. I am getting the thumbnail created as soon as I load the page in the admin. What version of PW are you running?
  13. Do you need them actually tagged somehow as expired, or could the selector in your template file just exclude all posts before a certain date? $pages->find("created<xxxx"); or perhaps from a custom published_date field, or whatever.
  14. Macrura has developed module for this scenario (I think): https://processwire.com/talk/topic/6417-processwire-profields-table/?p=64275 The other thing - if you just want to make use of creating child pages with the PageTable interface, rather than actually use them in a PageTable field, check out: https://processwire.com/talk/topic/6102-batch-child-editor/?p=59733 The latest version's edit mode works very similarly to the PageTable edit mode - take a look at the screenshot for "3. Edit" in the first post. You can add new, sort, delete, quickly rename, and click to edit all fields in a modal popup.
  15. Absolutely not - I like what you have done - you just might want to consider changing the layout via a hook instead of modifying the core.
  16. Hi blad - take a look on the Input tab of your images field and check the "Display thumbnails in page editor" option Of course it doesn't float them like you have, but you can use the grid mode toggle for that - button at the top right of the field in the page editor. PS Not meaning to suggest your enhancements aren't nice by the way
  17. This post should be helpful: https://processwire.com/talk/topic/4960-limit-number-of-pages-that-can-be-added/
  18. Are you running 2.4 stable? Does this dev commit fix the issue for you: https://github.com/ryancramerdesign/ProcessWire/commit/c18cf1e62eaafb3df1071a8c0936e5346721f754
  19. It looks like ProcessDatabaseBackup is already on the way https://github.com/ryancramerdesign/ProcessWire/commit/52c09f5ef1980b7cad3876e8332254f3792e795d#commitcomment-7463067
  20. The backup/restore stuff was easy thanks to Ryan I haven't given the module a permission setting so I think that limits it to superuser accounts. Are you seeing otherwise? Something a little weird I just noticed - if you try to enter the url to a Process module, eg: http://pwtest.dev/admin/setup/migrator/ when logged in as a user without the appropriate permission, you get this error: TemplateFile: Unrecognized path - maybe that's better than a meaningful error saying you don't have permission or something? Anyway, I think this is locked down sufficiently to superusers?
  21. @djr - in case you haven't seen it yet, Ryan has added a WireDatabaseBackup class to the core: https://github.com/ryancramerdesign/ProcessWire/commit/52c09f5ef1980b7cad3876e8332254f3792e795d Maybe you can make use of this directly in your module once PW 2.5 is released.
  22. I like this too - I think the "Default Admin Theme" module needs a way to support managing and installing third party color schemes and css layout tweaks that can be applied to whatever the current admin theme version is. No messing with functionality from the module,inc,php files - just a way of skinning the theme.
  23. Hey Martijn - this sounds very interesting - when you have time, it would be cool to see your code - this sounds like a module waiting to happen
  24. Without knowing what redirects are needed, it's hard to now the best way to help you out here. You might be better off with a modrewrite rule if it's a standard pattern that you could match so you can rewrite all links with one rule, or a collection of rules that handle your different scenarios. Otherwise, you might be able to write a small script to batch create redirect entries for this module based on a regex.
  25. Super cool new feature just added - well at least I think it's cool You can now automatically backup your entire site's database and templates directory during the import process. Backups are archived so you can go back to any previously created version whenever you want. If something goes wrong during the import phase of the migration, or you simply imported the wrong json file, or you changed your mind, you can restore everything with the click of a button! This database part of this functionality relies on Processwire's brand new WireDatabaseBackup class that Ryan committed today, so to use this functionality, go grab the latest dev version of PW and the latest version of this module. Please let me know how it goes for you!
×
×
  • Create New...