Jump to content

Soma

Moderators
  • Posts

    6,808
  • Joined

  • Last visited

  • Days Won

    159

Everything posted by Soma

  1. Just published an new article. Tutorial: Add custom JS in ProcessWire admin. http://t.co/pqw79Q51t3 #processwire #cms

  2. UPS. My old brother... cheese we are screwd
  3. I did it again http://soma.urlich.ch/posts/custom-js-in-processwire-admin/
  4. It may a good one to add a naming convention for quality 500x0-70? The quality setting is relatively new.
  5. This is also wrong board.
  6. This is wrong board?
  7. Just as side note: $category_ids = $category->__toString(); You never need to do this, toString is a magic method that does automatic if you write: $category_ids = $category; Or simply $categories = $pages->find("template=category"); $articles = $pages->find("template=articles, parent=$categories");
  8. Um no, It does save as it should for me. No matter If I specify 1 or 0 as the default in construct, if checked and saved, fname: 1 is saved to db (without the "workaround”) and when I uncheck and save the fname: 1 is cleared and no value in db, as it should. As said, in you don't specify a uncheckedValue it will always be checked, cause there's no value saved for unchecked and on load it will set 1, and not overwrite it as there's no value coming from db.
  9. In case of checkbox, by default behaviour unchecked is NOT saved in DB, that's not a bug but a feature. No need to store a value, this is to either keep the logic of checkboxes and not waste space in DB. This only is an issue if you want to make the checkbox checked by default, even if you won't find any checked checkboxse by default in PW. Because it a better pattern to most of the time to inverse the logik and check a box to disable something, not the other way around. But for this case of still wanting to do the default 1, you can set the checked and unchecked value to make sure unchecked is a value that is saved.
  10. It's a feature not a bug.
  11. Ok, looked at this situation as I wondered and had similar issues in the past. If you really want to have a checkbox inputfield checked by default in this context you have to use the uncheckedValue, checkedValue property instead to make it work. Following example works fine: $f->attr('name', 'formatting'); $f->attr('uncheckedValue', "no"); $f->attr('checkedValue', "yes"); $f->attr('checked', $this->formatting == "yes" ? 'checked' : ''); This makes sure a unchecked value is saved, instead of nothing. And default in construct then can be $this->set('formatting', "yes");
  12. But that anyway a little special with checkboxes, you usually don't have it checked by default. Maybe I'm completely off but it's all a little tricky with checkboxes: Since when a checkbox is not checked there will be no setting saved, it's "empty", not sent etc. So only when checked it will have an value of 1 saved to db. Defining a default value of 1 in construct will not save it to db, only if you save the first time, but then it will always be 1 cause you overwrite it when it's loading. So what you trying to do is: if checkbox is empty/not set make it checked? How is this gonna work anyway when there's no value saved when unchecked? So making a default of checkbox to 1 will give hard time as when it's not checked. Not going to work. Apart from that, contrary to what you say, for me the value, when checked and saved, is save in db no matter what the default is. Instead make it inverse, by default it's on and disable it when checked.
  13. That means this doesn't work for you? $field->attr('autocheck', 1); $field->attr('value', $this->fname); I can't reproduce this. Works fine. There's no issue, as you don't specify value = 1 for checkbox. So don't do this: $field->attr('value', 1);
  14. Put in search.php $log->save('querylog', $q) And you'll have a log file querylog with timestamp and queries.
  15. It's the same as "status<" . Page::statusTrash . ", sort=bla" Or "status<" . Page::statusUnpublished . ", sort=bla" Edit: edited As it has to be smaller than trash or unpublished, since include=all will also return unpublished pages.
  16. Trash has id 7 so this should work. Do you have any other has_parent in your selector?
  17. Yeah first! Cool, looks great, great idea, haven't been able to look at this yet as just too much going on lately...
  18. Ah sorry for the misinforming, ok it's the value is returned by the formatValue so you grab it via $event->return. This should work: wire()->addHookAfter("FieldtypeText::formatValue", null, function($event){ $value = $event->return; $value = str_replace(array("<p>","</p>"), "", $value); $event->return = $value; });
  19. The alternative lang fields work fine, so your doing something wrong. Are the langs really named fr it? Are the file field limited to 1 file upload?
  20. RT @processwire: Performance tip: Sorting by 'name' is always faster than sorting by 'title'. So sort by 'name' when either can work in you…

  21. Just don't specify a parent. It's not mandatory if you have template or selector.
  22. If you add temporary code, to delete certain pages, to the templates/admin.php: remember to remove it afterwards to avoid headaches, facepalms and keep you healthy. Actually happened a couple times already, I'm getting older too.
  23. Ahm, so just missed that also with my earlier posts, it's that formatValue() or format() in Textformatters arent really hookable as it stands now. What you would instead do is hook into the text fields and hook into formatValue(), which is where textformatters are run when output formatting is on. Those are hookable in the system as they contain ___. So it would look like this instead of hooking a textformatter: $this->addHookAfter("FieldtypeText::formatValue", $this, "hookTextFormating"); public function hookTextFormatting($event){ $field = $event->arguments("field"); $value = $event->arguments("value"); .... } Or in a template wire()->addHookAfter("FieldtypeText::formatValue", null, "hookTextFormating"); function hookTextFormating($event){ $field = $event->arguments("field"); $value = $event->arguments("value"); .... } So after all coming this route, it doesn't matter if a Textformatter uses format() or formatValue().
  24. I'm not against at all with you doing it with a hook, just am confused why you choose the "extra" manual hook way over what is obviously already there and can be done via adding multiple textformatters. It's exactly designed for what you need here, so have hard time seeing the need to do extra workaround with a hook. But if it's for learning reason, why not... I'm not sure what you mean my solution is elegant? The code to add the Textformatters? Or simply using a second textformatter on the text field, which is obviously not my solution but designed best practice in PW. I think the method you have isn't hookable because it's not hookable. Does it have like "___formatValue" three underscores?
  25. Yeah but the $user is still from the request and it's not overwriting it for $user as that was already set earlier, you may have to load it again before user is the new logged out user. $session->logout(); $user = wire("user"); if($user->isLoggedin()){ $content .= "user is logged in $user->name"; } BTW I don't trust that API gen and never use it, I would recommend to use github so cause the code you linked isn't the exactly the same in current version. Although the behaviour remains the same. https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/core/Session.php#L324
×
×
  • Create New...