• Content count

  • Joined

  • Last visited

  • Days Won


diogo last won the day on April 1

diogo had the most liked content!

Community Reputation

4,512 Excellent

About diogo

  • Rank
    Portuguese expat
  • Birthday 08/09/1978

Contact Methods

  • Website URL

Profile Information

  • Gender
  • Location
  1. Hi Louis, I suspect that this might have to do with the user himself. Can you indicate the user and post in question?
  2. We're developing the site for a Swiss architect, and meanwhile we prepared a very simple temporary page: http://gamisch.ch/ It's powered by PW, so I thought I should post anyway
  3. On the subject: https://blog.toggl.com/how-does-music-affect-work-infographic/
  4. Are you getting any error message? Can you try this and see if it works? $user->of(false); // this disables output formatting $user->my_planet = "mars"; $user->save('my_planet');
  5. Since a few days I'm completely addicted to listening to this while working https://www.youtube.com/channel/UC5FUNVH36ebM6ffQd3rvz8g
  6. @PWaddict I think you can add icons only to templates, and not individual pages. On the instructions I tell you to give the "admin" template to the pages, but I guess you could create a new template for it as long as it has you assign the "process" field to it. Be aware that this field won't appear on the select when assigning fields to templates, so you will have to create the template and then go to the fields list — show built-in fields — edit the "process" field — from there, add it to your new template.
  7. Hey! My pull request with an integration for PW for the Toggl Chrome button was just accepted, yay! https://github.com/toggl/toggl-button/pull/788 For those who don't know, Toggl is a really great time tracker, and they have a handy Chrome extension that integrates with web apps by adding Toggl buttons to tasks and projects. Generally, these integrations are with task manager apps and CRMs, but I thought I could develop an integration for the PW admin. Although I did it mostly for the fun of it, I think this can be useful in some cases, and definitely it's great to see PW featured on their extension and github page!. They also seem to be quite picky with these integrations, so I'm glad they accepted the pull request. Here are some images to give you a taste of it
  8. @Sérgio just to let you know. I did a small test, and without making any change, the module already has kind of multilanguage support because the value will be set in the language of the user visiting the page. So, if you set the TRUE parameter to force the value and visit the page with another language, it will actually set the values in that language to the values that are currently set in the value parameter. Not sure if that's more useful than editing the page in the admin though.
  9. Thanks @Sérgio! Just some minutes ago I added the possibility to create multi language fields and uploaded a new zip file. This doesn't let you add the language values, it only allows you to define the field as multi language. I'm not sure how useful it would be to add the possibility to add the language values, since it can get really complicated in sites with lots of languages and I thought of this as a fast development tool. I would check how to support all major field types first, and then think of multi language.
  10. Hey! This is a very early/experimental/alpha not for production environments release of a new module I'm working on. Just testing the possibilities and the interest that might be for such a thing. The idea is to be able to quickly create fields while working inside the template files without having to go to the admin. For example, in an early stage of development when creating a layout, insteading of putting a placeholder headline and then going to the admin to create the headline field where the real content will be, you can create the field directly from the template file by doing: <h2><?=$page->field("A nice headline", "headline", "text")?></h2> This will create a new "headline" text field when it doesn't exist in the system and add it to the the template of the page you're working on and add "A nice headline" value to it. On a second run the module will recognize that the field already exists on that template and will simply return it's value. The method accepts three string parameters in the order ( value, field name, field type ). Value and name are required but field type will assume "text" when omitted. $page->field("A nice headline", "headline"); // creates a text field $page->field("A nice paragraph", "body", "textarea"); // creates a textarea field The method also accepts a boolean parameter in any position: TRUE forces the value to be saved into the field on that page, FALSE (or omitted) sets that value to the field when it adds it to the template, but leaves it how it is when the field already exists in the page. This is the only situation when this module can be destructive, and it's only concerning the value of the field on that page: $page->field("Another nice headline", "headline", TRUE); // will create or add a text field and add the value to the page even if the field already exists there The method also accepts an array as parameter. This array will be used as options for the creation of the field. The options array will override the string parameters when they clash. $page->field("A nice headline", "headline", array( 'name' => 'subtitle', 'label' => 'Subtitle' )); // will ignore the name "headline" and use "subtitle" instead As soon as the fields are created and added to the template, all the method will do is return the value, just like if using $page->headline, unless you use the TRUE parameter which will override the value of the field by the value in the first parameter. -- With this module you can, for instance, convert an existing HTML template quickly, just by pasting the html into a template with no fields created yet, and going through all the code, replacing the content by calls to my field() method. In the end you should have a working page with all the fields created in the template. Now you just need to go to the fields and adjust their preferences. So, just download it > install it > test it > tell me what you think! dynamicPageFields.module.zip -- Edit: Multilanguage fields threw an error but they don't now. You can create a multi lang text by doing: $page->field("A nice headline", "headline", "textlanguage"); that third parameter is just a case insensitive simplification of input field names to make it easier to write. You can still use the original input field name like "FieldtypeTextLanguage" if you prefer.
  11. And here goes some code. Place this on site/ready.php (or create a module from it) and edit the first lines to your liking: /*************************/ /******* EDIT HERE *******/ /*************************/ // ID of the page where the custom content is $this->pageID = 1; // name of the field where the custom content is $this->fieldName = 'body'; // name of html tag and id from the parent of the custom content on the 505 file $this->elementTag = 'div'; $this->elementID = 'message'; /*************************/ /******* END EDIT ********/ /*************************/ // regex to get the contents of parent element $this->regex = '/(<'.$this->elementTag.'\sid=("|\')?'.$this->elementID.'("|\')?>)([^<]|<.+>.*<\/.+>)+(<\/'.$this->elementTag.'>)/i'; // On save the content of the field on the 505.html file $this->addHookAfter('Pages::saved', function(HookEvent $event) { $page = $event->arguments[0]; if($page->id !== $this->pageID) return; $file = wire('config')->paths->templates . '/errors/500.html'; $content = file_get_contents($file); $field = $this->fieldName; $content = preg_replace($this->regex, '$1'.$page->$field.'$3', $content); file_put_contents($file, $content); }); // On render the edit page, save the content of 505.html file on the field to show it $this->addHookBefore("ProcessPageEdit::buildFormContent", function(HookEvent $event) { $page = $event->object->getPage(); if($page->id !== $this->pageID) return; $file = wire('config')->paths->templates . '/errors/500.html'; $content = file_get_contents($file); preg_match($this->regex, $content, $matches); if($matches) { $page->of(false); $field = $this->fieldName; $page->$field = $matches[0]; $page->save($this->fieldName); } }); The above code assumes that your "505.html" file has a <div> with the id "message" in it, you just have to adapt it to yours.
  12. You can create a page with a ckeditor field and then hook on save to rewrite the static file. No time to give you code now.
  13. Or just output the same PHP for all and deal with the differences with css nth-child.
  14. It worked with me, it's stuck in my head now, damn you!
  15. "Everything has to be a thing, even if you don't use it as a thing"