Jump to content

ryan

Administrators
  • Posts

    16,715
  • Joined

  • Last visited

  • Days Won

    1,517

Everything posted by ryan

  1. This is the route that ProcessWire takes with the admin too (you can see it by view source in browser when in PW admin). PHP-powered JS files are definitely cool in the right places. But I worry a little about browser cache issues. You generally want your browser to cache those JS and CSS files. If you are outputting dynamic data with them, you may be preventing the browser from caching them, or battling it over caching them when you don't want it to. There are ways around it (managing cache headers and keeping track of when stuff changes) but it just seems like kind of a pain to me, though I've not done a lot of it.
  2. Sorry for the typo, I've corrected my original post. Thanks for finding it Adam.
  3. I don't know if there is a way to do that, but I also use MAMP here and it only prompts me for the password when I restart apache or reboot. I might do this once a month or so. The password isn't too bothersome if you don't reboot often.
  4. We may have to add a button like that soon. Currently it restores defaults when you set it to the blank/original unset value. But of course that prevents you from overriding a default populated value with an unpopulated one. So currently it's best to leave the default (no context) value blank if you want it to be blank/unset in any alternate template contexts. Luckily, I don't think that's a common situation (at least not here). I'm not sure that I understand? There isn't a foundation for context outside of multiple template/fieldgroups, but maybe I'm not reading this right. Can you give me a more specific example or what you mean?
  5. Actually this sounds familiar now, I think I remember that Safari for some reason does not support drag-drop file uploads. That was awhile ago that I remember talking about this before, and figured they would have fixed it by now. It seems like Apple is not giving much love to Safari lately.
  6. Ray this is fantastic! Thanks so much for writing and sharing this with us. I am setting up a case studies forum as a subforum of showcase (unless you guys think it should go elsewhere?) and will move this there. Thanks again!
  7. Sevarf2, I tried to duplicate this over the weekend, but so far not having luck. My repeater had an datetime field that auto-populated the current date and also had a datepicker on it. I tried saving them, deleting them, etc. I tried this with both setting the "ready pages" number and 0, 1 and 3. I'm wondering if there might be any other factors -- Are there any other fields in your repeater? Are you using the default admin theme or another? And any other modules installed? Thanks, Ryan
  8. It sounds like it really is a Page object then, as it should be. The question then is why PHP is throwing a "not object" error. I'm wondering about the eAccelerator that your phpinfo said is installed. I have a feeling that line 78 isn't really line 78, and that it's line 78 of a cached file or something. I look forward to getting a closer look at the install (per your PM).
  9. To assign the class to your article, like the one in your link (a full page article) you could add the category name to your <body> tag. <body class="<?php if($page->category) echo $page->category->name; ?>"> Then in your CSS file, you would do like what Diogo suggested: body.climate #article em { background-color: #07ABBA; }
  10. You can do that, or you can download the ZIP and replace the /wire/ directory from your installation with the /wire/ directory from the ZIP. When not using git, I usually rename the existing /wire/ dir in my site to /wire.old/ temporarily, just in case I need to revert. Yes, everything should work in Safari. Though I would use Chrome over Safari to avoid the continuous beachballing on every site I visit with it (or maybe that's just my computer).
  11. Pete, I'm still really confused about how that line 78 is throwing a "trying to get property of non-object" error. It really shouldn't matter if it says "single page or boolean false" or "single page or NullPage". Line 78 doesn't deal in that, and it's just a really unusual error. So I'm really curious to know what exactly $page is in that instance. It's apparently non-zero, non-object, which is something that $pages->get() technically shouldn't be able to return. Can you try adding this before line 78? var_dump($page); exit(); And see what it tells you that it is? Btw I don't see anything in your phpinfo that looks like a problem.
  12. This is a good question, and one of the most advanced questions I've ever seen asked here. Here's how to do it. Unfortunately the $field context isn't available to the Pagefile/Pageimage, though the $page context is (accessible as $this->page from a Pagefile/Pageimage object). Given that, we can find the $field context like this: public function init() { $this->addHook('Pageimage::action', $this, 'pageimageAction'); } public function pageimageAction(HookEvent $event) { $field = null; // where we'll keep the field we're looking for $image = $event->object; $page = $image->page; $action = $event->arguments[0]; // find all fields of type FieldtypeImage that are part of the page we're using $imageFields = $page->fields->find('type=FieldtypeImage'); // loop through to find the one we're looking for foreach($imageFields as $imageField) { // good to get unformatted in case it's a single image field, // because it'll still be an array rather than 1 image $pagefiles = $page->getUnformatted($imageField->name); // if the image's pagefiles property matches the one with the // field we're looking at, we have a match. save in $field if($image->pagefiles === $pagefiles) { $field = $imageField; break; } } if($field) { $out = "<ul>" . "<li>Field: {$field->name}</li>" . "<li>Action: $action</li>" . "<li>Filename: {$image->filename}</li>" . "<li>advSetting: {$field->advSetting}</li>" . "</ul>"; $event->return = $out; } } To examine the result, do this: // single image field echo $page->image->action('test'); // multi image field foreach($page->images as $image) { echo $image->action('test'); } I will look closer at adding the $field context to the pageimages/pagefiles/pagefile/pageimage instances in the near future so that it's not necessary to find it yourself like this. But this is the best way to go for now.
  13. Thanks Soma, this is a great module and a recurring need--I think it will be helpful to a lot of people, including myself. Nice work with the good documentation too.
  14. I'm not sure there's enough to go on here to say for sure. Where are you setting the $input->whitelist values? That's probably the same place where you want to build your search selector. Something like this: $selector = 'parent=/products/, '; $name = $sanitizer->pageName($input->get->manufacturer); $man = $pages->get("parent=/manufacturer/, name=$name"); if($man->id) { $input->whitelist('manufacturer', $man->name); $selector .= "manufacturer=$man, "; } list($priceMin, $priceMax) = explode('-', $input->get->price); $priceMin = (int) $priceMin; $priceMax = (int) $priceMax; if(!$priceMax) $priceMax = 99999; // or some other max value $input->whitelist('price', "$priceMin-$priceMax"); $selector .= "price>=$priceMin, price<=$priceMax, "; $selector .= 'limit=25'; $products = $pages->find($selector); if(count($products)) echo $products->render(); else echo "<h2>Sorry no products found</h2>";
  15. Thanks for fixing that Soma, and thanks for finding it Alan.
  16. Peter originally contacted me. My schedule is overloaded in the short term, so I suggested that he post here instead. Peter also is a great guy and does awesome work and I'm confident he'd be good to work for.
  17. Great module Soma! Thanks for making this and posting. The only thing I wonder is why make it an autoload module? This is one that is meant for on-demand use, so it doesn't technically need to be an autoload module. Though I agree it does make for a nicer API call: echo treeMenu->render(...); // vs. echo $modules->get('MarkupSimpleNavigation')->render(...); But I'm just thinking that if every module took this approach, PW wouldn't run as efficiently, or could even run out of memory. But I love this module either way.
  18. Pete that error message you posted is very likely the issue. If you've got an error consistently being displayed, that will interfere with the ability of any ajax request to complete... the resulting JSON would be unparseable. I looked at line 78 of InputfieldPageAutocomplete.module and I'm not quite sure how it could generate that error. Can you double check that line 78 of that file is the same as this in your installation? foreach($this->value as $page_id) { $page = $this->pages->get((int) $page_id); if(!$page || !$page->id) continue; // THIS IS LINE 78 $out .= $this->renderListItem($page->get($this->labelFieldName), $page->id); } I am thinking that somehow your installation must be different, because it should be impossible (from what I can tell) for the statement at line 78 to produce that particular error. Please let me know what you find?
  19. Thanks Oliver. I think the issue here is this: // offer user roles to choose $roles_field = Wire::getFuel('fields')->get('roles'); $field = $roles_field->getInputfield(Wire::getFuel('page'), $roles_field); // HERE $field->label = __("User roles", __FILE__); $field->description = __("Roles given to users created for this type of login by default", __FILE__); $field->value = $value; $field->name = 'user_roles'; return $field; Note the line I labeled 'HERE'. You are asking it to get an inputfield for the 'roles' field in the context of $page. At that time, $page is /processwire/modules/ (template admin) and that page has no 'roles' field. So I think this is unpredictable. Instead, I would suggest doing this: // offer user roles to choose $field = wire('modules')->get('InputfieldCheckboxes'); $field->attr('name', 'user_roles'); $field->label = __('User Roles')); $field->description = __("Roles given to users created for this type of login by default"); foreach(wire('roles') as $role) $field->addOption($role->id, $role->name); $field->attr('value', $user_roles); Just tested here and it works. Also, unrelated, but had a couple other things I wanted to mention: Wire::getFuel('something') is the same as wire('something'). The wire('something') is newer syntax, and you'll usually see the older syntax in the core. But I find wire('something') easier to read, so just wanted to mention that you don't have to use Wire::getFuel() unless you want to. For language translation, __('something'); and __('something', __FILE__); are equivalent. Specifying the __FILE__ saves a little overhead, as PW doesn't need to figure it out on it's own. But for something like a module config, or even your own site templates, it probably doesn't matter much. I've mainly been including the __FILE__ part in getModuleInfo() functions because those do have potential to be called on each request, so every little optimization helps there. Note that none of this is applicable to the $this->_('something'); syntax, but if course that syntax can't be used in a static function. For the top of your getModuleConfigInputfields($data) function, I recommend including something like this: $defaultData = array( 'user_roles' => array(), 'consumer_key' => '', 'consumer_secret' => '', ); $data = array_merge($defaultData, $data); That initializes defaults and makes any corresponding values in $data overwrite them (if present). But if values aren't present, then you don't have to worry about PHP complaining about uninitialized indexes when you are in PW debug mode.
  20. Adam, sorry I linked to the wrong message in that thread before. Here's the instructions for the 'replace' hook: http://processwire.c...ndpost__p__7435 You don't want to call $pages->___save() unless you are using a 'replace' hook. For all other hooks, the original method that you hooked is still called (either before or after your hook). So a 'replace' hook is different in that it tells PW you are completely taking over the implementation. These have not been used a lot, and there is potential for conflicts with other modules hooking the same function. So that's why I say it's probably better to throw an exception where possible. In that case, your hook would look like this: function savePageValidation($event) { $page = $event->arguments[0]; $everythingIsOkay = true; if($page->other != $page->that) { // pseudocode $everthingIsOkay = false; } if(!$everythingIsOkay) throw new WireException("Aborted save because other != that"); } A replace hook would look like this: function savePageValidation($event) { $event->replace = true; $page = $event->arguments[0]; $options = $event->arguments[1]; $everythingIsOkay = true; if($page->other != $page->that) { // pseudocode $everythingIsOkay = false; } if($everythingIsOkay) { $event->return = wire('pages')->___save($page, $options); } else { $event->return = false; $this->error('Page was not saved because other != that'); } }
  21. Thanks Sevarf2, I'll take a look at this and find a fix. Just to confirm, you only experience this effect when using a date field that's set to populate today's date?
  22. Thanks guys, keep me up to date. I think this sounds like a great idea, and looking forwarding to adding it.
  23. Soma, you are right it shouldn't be autoloading that JS, given that the module is not an autoload one. Turns out that the $modules->isUninstallable($class) was inadvertently init'ing the class when it did its check, so it was causing the modules init() function to be called when viewing its config screen. Just fixed this in latest commit. Thanks, Ryan
  24. Thanks Antti, just fixed in latest commit. This applies to situations where you are adding a page somewhere and only 1 template is allowed (per the parent page's template family settings).
  25. Great work Soma, it looks and works great! A great alternate way to navigate pages in the admin. Just tested here and it works great. Javascript error, ProcessDataTable.js line 26.
×
×
  • Create New...