Jump to content

Soma

Moderators
  • Posts

    6,808
  • Joined

  • Last visited

  • Days Won

    159

Everything posted by Soma

  1. Thanks Nik for sorting this out. You're right actually. But I remember some case where it wasn't like this and the order would matter, but that's half year ago, so probably messed up or something has changed since then.
  2. That's great. I felt the same way when seeing even I could make such powerful modules without learning something very difficult. It's not very different from when using API anywhere in front-end. So you can use your knowledge already aquired and start dreaming away. Agreed. See examples on previous post
  3. Of course you can improve it a little with more logics if needed. Only on pages that have the publish_date field. Remove date if page is unpublished. Add value if published and not populated yet. public function afterSave($event) { // get page object saved $page = $event->argumentsByName('page'); // only on pages that have a publish_date field if(!$page->template->hasField('publish_date')) return; if($page->is(Page::statusUnpublished)) { // if unpublished, empty the field if not empty already if(!$page->publish_date) return; $page->publish_date = ''; $page->save('publish_date'); } else if(!$page->publish_date) { // if page (published) and field not populated, add current timestamp $page->publish_date = time(); $page->save('publish_date'); } }
  4. That's a good example sinnut, but a minor change to make it work: public function afterSave($event) { $page = $event->argumentsByName('page'); // get argument by name, more readable if($page->is(Page::statusUnpublished) || $page->publish_date) return; $page->publish_date = time(); $page->save('publish_date'); } isset() wouldn't work in the previous example as the field exists but is not populated it will always return true. Also $page->of(false) isn't really required as in a module the page has no outputformatting on anyway. To populate the datetime field you'd just give it a timestamp. As the field holds input-outputformatting date formatting it will take that. Not wrong but no need to. If you also need to restrict to certain pages you could add a check for the template before status check. if("article" == $page->template) return;
  5. Yeah thats from our resident luis forum member.
  6. If there is no hookable function you cant. And as you found out if db connect error is thrown theres nothing you can do obviously. But if you let us know what you like to do we maybe can help.
  7. I think you can try $page->isTrash to check if page is in trash.
  8. Edit template -> family tab there you can specify various settings to restrict children templates.
  9. Diogo, you don't have to do it manually, just a save hook. Giving you back a simple find() on front-end it is worth considering it. It would also even work in admin sorting by the field and so on. Sure an simple page array where you store the height of the first image in a runtime property to then sort by it is also a way. But then just add a line or two more to save the result to the page and you already have a "function" to do it automaticly. $pa = new PageArray(); foreach($pages->find("template=xyz") as $p){ $h = $p->images->first()->height; $p->img_height = $h; $pa->add($p); } foreach($pa->sort("-img_height") as $p){ $img = $p->images->first(); .... }
  10. I'd suggested a integer field too, simple. You get what it requires to do something. Not "I want to do this but don't want to..."
  11. $pageArray->has($page); http://processwire.c...er=has Also it doesn't matter if you add duplicates as PW will remove them anyway.
  12. Sure a login would help. I'm sure it's something simple.
  13. Make sure you published the roles as they wont show up otherwise.
  14. Soma

    ProcessWire on the web

    I also started to see u when i did the logos. In diogos I see Photoshop Welements. I don't think the cloud is something we should incorporate into a or any of the logos of PW. Just to fit the current website... which will change in 2-3 years. The letters typing is ok, but doesn't make a logo I'd want to live with. I'm not sure anymore what is required or not and the way to go from here.
  15. Just throwing that in, cause I know there some threads about similar subject. Let's see http://processwire.com/talk/topic/523-good-hosting-for-processwire/ I think hosting companies like serverInt are the ones to look out for. I'd even prefer to pay a little more if service is really good and server fast. Never take a cheap just to save money.
  16. !Feliz navidad¡
  17. Soma

    Hi Everyone

    Hey kongondo, welcome to the forums. Glad to have you here!
  18. The module doesn't parse plain text fields. Only Textarealanguage fields. I'm still not sure what should not work. It works well for all Textarealanguage fields, no matter what is called or where it is used. Every field if a href="..." found it will change it to be the right link in that language, prepend the /langcode/ etc. Tested back and forth. This is the behaviour of PW with languages and has nothing to do with this module. If an alternative language is empty it will fall back to the default. I think you could try appending the language id to the field name if you explicitly want a language. $langcode = $languages->get("de"); echo $page->get("headline$langcode|title$langcode");
  19. Sorry the dumb question but what if the center is near the edge and the cropping size wouldn't fit there (overlapping)?
  20. Soma

    Date input

    Use separate fields for d m and Y. Then u would be able to do finds more easy and have no limit. Not sure what else but there seems no other way. To calculate day of week Im not sure you could simply use php date functions to do that.
  21. I see it's a process module for an admin page so the template would be 'admin' and it already has page numbers active. So my first suggestion still holds true I think. Little OT: the selector should first sort and then limit as youll get different results.
  22. Limit=1 doesnt yet work. Also make sure page mumbers are turned on on template url settings.
  23. Ah yes. Or simply $skill->name.
  24. That would be after ProcessModule::execute. The $event->return would be the markup rendered. You could then wite $event->return = $yourmarkup . $event->return;
  25. I think this should do it. A check box is either 1 (true), or 0 if not checked (false). Also if you get fields like this you have to get the field of the page afterwards. Let me know if that works. $skills = $curpage->fields->find("label=Skill"); foreach($skills as $skill){ if($curpage->get($skill)){ echo"{$skill->name} "; } }
×
×
  • Create New...