Jump to content

gebeer

Members
  • Posts

    1,386
  • Joined

  • Last visited

  • Days Won

    39

Everything posted by gebeer

  1. I updated my site from 2.5.2 to 2.6.3 with the ProcessUpgrade Module. When updating InputfieldTime (also through ProcessUpgrade Module) I got a worning that it is not compatible with 2.6. I went ahead anyways to see what will happen. After upgrade I got 2 Warnings: and a message: InputfieldTime was updated successfully. Button: Continue to module settings In the module settings I got: There are multiple copies of this module. Select the module file you want to use. /site/modules/InputfieldTime/InputfieldTime.module (the new one after update) /site/modules/PW-FieldtypeTime/InputfieldTime.module (the old one) I chose the new one. Then I did the same for Fieldtype Time module. Everything seems to be working fine with 2.6.3 Just wanted to let you know.
  2. Thank you, Ryan, for looking into this. Yes, they occurred immediately after each other.
  3. Yeah, stupid me Forgot that $images will be altered after removing. When I do $images = $page->images; echo count($images) . " images<br>"; foreach ($images as $img) { echo $img->basename . "<br>"; } $firstimage = $images->eq(0); echo "firstimage<br>"; echo $firstimage->basename . "<br>"; $restimages = $images->remove($firstimage); echo "restimages<br>"; foreach ($restimages as $img) { echo $img->basename . "<br>"; } everything works as expected
  4. Hi All, I have an images field for multiple images set to always return an array. My images field holds 5 images. I'm trying to get the first image of the array and then remove that to get an array that holds images 2-5. Here's my testing code so far $images = $page->images; $firstimage = $images->eq(0); //also tried $images->first() with same result $restimages = $images->remove($firstimage); echo count($images) . " images<br>"; foreach ($images as $img) { echo $img->basename . "<br>"; } echo "firstimage<br>"; echo $firstimage->basename . "<br>"; echo "restimages<br>"; foreach ($restimages as $img) { echo $img->basename . "<br>"; } And here's the output: 4 images mario_florenz_1.jpg mario_florenz_3.jpg mario_florenz_2.jpg mario_florenz_5-1.jpg firstimage mario_florenz_4.jpg restimages mario_florenz_1.jpg mario_florenz_3.jpg mario_florenz_2.jpg mario_florenz_5-1.jpg A few things that buffle me: -count($images) returns 4 where it should be 5 -foreach through $images returns only 4 images where it should be 5 -$images->eq(0) returns the first image but this one is not returned when I loop through all images -$images and $images->remove($firstimage) return the same I really don't understand what is happening here. Reading through the API docs on images and WireArray manipulation it seems my code should work. Any help would be much appreciated.
  5. Welcome to the forum, mosid! Here is a discussion about RESTful API in PW where Ryan shares his thoughts about it. And there is Ryan's module Pages Web Service. I don't think it needs to be in the core. Thanks to PW's modular structure it is easy to implement.
  6. I was not sure from your first post whether you just wanted to collapse the field when empty. That is why I included those instructions. Further down in my first post I describe that I have the same behaviour here on a 2.5.29 dev site with multi language setup. This is to confirm your problem. Looks like a bug to me. Maybe you want to file an issue at github.
  7. You don't need dependencies for this to work if you want to show the image_field itself only when there are images. In the field settings for your image_field go to input tab -> visibility and choose "Collapsed only when blank". This should do what you want. EDIT: I just tried this on a 2.5.29 dev install and I can confirm that it is not working as expected. I have a field images and a field bodycopy. For bodycopy I choose "Show this field only if..." images.count>0 The bodycopy doesn't show at all, no matter if there is an image in the images field or not. The field is there in the HTML with an attribute data-show-if='images.count>0' in the field wrapper. Maybe the JS cannot compute the >0 part. But this is just a guess and needs further investigation. Should we file this as bug? EDIT2: I tested this in a multi language setup. In the dependencies documentation section limitations it says Do you also have a multi language setup?
  8. Thanks for your reply. $warning will not be available inside the each() callback function because of variable scope. Also the callback function needs to either echo or return something. So I'm afraid your code won't output anything and give a PHP notice like "variable $warning not defined" because you define $warning outside the callback function. This is mentioned in the link that I posted in #1 EDIT Sorry, I overlooked the "use (&$warning)" part. So forget about what I just said I implemented your proposed solution. But still the return value gives me the page ids of pages within the $divesites page array where I would expect it to be empty. EDIT again Got it. I still had $warning = $divesites->each(function... After removing the $warning = part, it works. Only I had to replace {title} with {$item->title} Thanks again. But with my limited PHP knowledge I still don't understand why that is so.
  9. Hello, I'm playing with the new each() API method. $warning = $divesites->each(function($item) { $warning = ""; if (!$item->marker->address) { $warning .= "<div class='alert alert-warning'>coordinates for {title} not set</div>"; } else { $warning .= ""; } return $warning; }); $warning should return an empty string, when all dive site adresses are set. But instead it returns the page id of the last dive site in the loop. When I do it the foreach way $warning = ""; foreach ($divesites as $site) { if (!$site->marker->address) { $warning .= "<div class='alert alert-warning'>coordinates for {$site->title} not set</div>"; } else { $warning .= ""; } } the $warning is an empty string as expected. Why is that? Any pointers would be much appreciated.
  10. I installed an additional language on 2.5.27 dev and everything went fine. Now I added a 3rd language and get several errors: Session: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_title.data1372' in 'field list' Session: SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'data1372' Session: SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'data_exact1372' Session: SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'data1372' and warnings Session: language is missing column field_title.data1372 Session: language nl is missing column field_title.data1372 Prior to installing the 3rd language I created an options field. Upon entering the transaltion for the field options I got errors but I didn't note them down. But I cannot save translations for the options. Field for entering translations remains blank after save. Maybe add language error is related to the problems with that options field? I removed the 3rd language and upgraded to 2.5.29 dev. But same errors when adding the 3rd language again.
  11. I you want to convert a PW pages array to json, here is some useful code from Ryan that you can use and adjust to your needs.
  12. You might want to show them the Canton speakers site done with PW that was introduced lately and also announced in PW weekly newsletter. This is a worldwide brand. If they trust in PW, why shouldn't your potential customer. EDIT And cmscritic.com might serve as an example. Their article ProcessWire vs WordPress has some good arguments for PW and against WP. Then there is this article about PW in the german IT magazine c't: "German computer magazine c't has just published an article about ProcessWire, and Tuts+ has announced they are going to commission tutorials on ProcessWire" (taken from PW weekly #43). Some ideas for your points 2 and 3: - you could offer free updates for a period of time since it is so easy to do - if you have the capabilities, you could offer a free port of the system to WP or Drupal in case PW development will stop in the future. This will underline your total confidence in PW And, if you have the opportunity, you could show them the PW backend and how easy it is for editors to work with.
  13. A warm welcome to the forum, tekno (sorry I forgot that in my last post) Did you change the title field to be type "PageTitleLanguage"?
  14. Did you install the Languages Support - Page Names module? You might want to have a read about multi language support in PW And there is a forum section about multi language
  15. Thank you for the quick reply and the fix. I updated and can confirm that it is working now also for multi-language page names
  16. There is a comments fieldtype that makes adding comments to pages a breeze. Since reviews are some kind of 'comments', maybe you can use that module and then extend it to add a rating star system. EDIT here's a thread about adding additional fields to the comments system https://processwire.com/talk/topic/2898-adding-additional-fields-to-comments/
  17. Thank you for this module. I installed it on a 2.5.28 multi language site and it is not changing page names at all, no matter what aettings I try. I the module supposed to work in a multi language environment?
  18. I definitely would encourage you to give PW a try. Most people who took the initial effort are now very happy PW developers You might want to jump right in and have some good reads. Categorizing content tutorial Example code for creating a form with file upload If creating frontend forms through the API is over your head at the moment, you could always use the very affordable paid extension form builder. Easy to use and a big time saver. Multi language And learning PHP when working with PW can be fun. Don't worry, you fill find tons of helpful posts in the forum and the friendly community will help you get started.
  19. In the joomla-vagrant context it makes perfect sense because with that command you can setup a new site in a subdomain so you can have multiple dev sites residing in one virtual machine. But I see your point when considering multi site environments.
  20. Thank you for putting this together. This is absolutely great I came over from Joomla some time ago and one of the many joomla devs have created joomla-console. They combine it with their joomla-vagrant box which is a great tool for development. I am actually still using it for quick setup of PW projects And I've been thinking for quite some time how great it would be to have a console tool for PW. And now it is here. So big thumbs up! I see that there is some kind of naming convention for commands now. Have you ever considered renaming the 'new' to 'site:create' Thats what joomla-console uses and they also have a 'site:delete'.
  21. As a big fan of Pro Fields I use the Textareas Field to combine 2 checkboxes. And I wasn't aware of the options field type. So thanks for the pointers here
  22. I knew that this would cause conflict because there are so many different ways of implementing script loading. So your comments on this are more then welcome. I read and revived this discussion about how to best approach script inclusion when developing a module. And chose a mixed approach because I'm really not sure myself how to best do it and to experiment with different methods. The original approach of the Google Maps module just didn't seem perfect since it forces users to include stuff in the head. So what to do as a user if you don't want to have scripts in <head>. But then I guess there is no perfect way. Main reason for injecting the "inline script" at the very end: wanted to make sure that scripts get loaded in the right order. @Soma why wouldn't you want to have it before </body>? @Wanze thanks for clarifying the terminology. I'm quite new to PW module development. So I really appreciate any input that I can learn from.
  23. Solved this way: I made an additional autoload module 'MarkupAddInlineScript' to execute the hook. In the render() method of the map markup module I assign my inline script string to the page object $this->page->inlineScript = $inlineScript; Now in init() of MarkupAddInlineScript I execute the hook $this->addHookAfter('Page::render', $this, 'addInlineScript'); that calls my hook method public function addInlineScript($event) { $page = $event->object; if ($page->inlineScript) { $event->return = str_replace("</body>", $page->inlineScript . "</body>", $event->return); } } My hook method only executes when $page->inlineScript returns a value other then null. This will happen only on pages that instantiate a map object with $map = $modules->get('MarkupLeafletMap'); As a result I have the script that was previously insertet inline on the page, neatly attached to the end of my page body <script type="text/javascript">...</script> </body> All other scripts that are required for rendering the map are also attached at the end of the body before the "inline script" through $config->scripts->add() in the init() method of the 'MarkupLeafletMap' module. Now when people install this module, they don't have to worry about including the various scripts themselves in the head or body and I can be sure that they get executed in the right order, too. Only thing users of the module need to do now is include <?php foreach($config->scripts as $url) echo "<script src='$url'></script>"; ?> before </body>
×
×
  • Create New...