Jump to content

gebeer

Members
  • Posts

    1,391
  • Joined

  • Last visited

  • Days Won

    39

Everything posted by gebeer

  1. ProcessWire API has methods for session handling: $session To set your custom session variable you can use $session->set($name, $value) or $session->$name = $value and later retrieve it with $session->get($name) or $session->$name So in your case it would be if($config->ajax) { $session->test = "test"; } Here test will only be set if you make an ajax call to the page. From your question it is not clear whether you made that ajax call before trying to get the test value on a normal page load. To retrieve the value you can use $test = $session->test;
  2. In your inline style you are missing the url() part. And the api call to the image is also not correct. Is the image field storing only 1 ore multiple images? If it is multiple, you need to do something like <div class="thumbnail"> <a href="..."> (Link to my gallery) <div class="flex-item6" style="background-image: url(<?php echo $page->images->first()->url; ?>)"> <span class="overlay">stuff</span> </a> </div>
  3. I found a cleaner way of adding modals to $jsConfig. Instead of writing out the whole array, we can do: $jsConfig['modals'] = $config->modals; This way also changes to the core get picked up.
  4. Just wanted to note here that with PW 2.6.x the pwimage plugin stopped working. So I couldn't insert images in CKEditor anymore. I discovered that in the config json array with PW 2.6 a element "modals" got added (through /wire/config.php around line 848). You need to add this to the $jsConfig like: <script> <?php $config = $this->wire('config'); $jsConfig = $config->js(); $jsConfig['modals'] = array( 'large' => "15,15,30,30,draggable=false,resizable=true,hide=250,show=100", 'medium' => "50,49,100,100", 'small' => "100,100,200,200", 'full' => "0,0,0,0", ); $jsConfig['urls'] = array( 'root' => $config->urls->root, 'admin' => $config->urls->admin, 'modules' => $config->urls->modules, 'core' => $config->urls->core, 'files' => $config->urls->files, 'templates' => $config->urls->templates, 'adminTemplates' => $config->urls->adminTemplates ); ?> var config = <?php echo json_encode($jsConfig); ?>; </script> Then the modal popups for inserting images will work again. See also my thread about pwimage plugin in frontend forms.
  5. After an upgrade from 2.5.2 to 2.6.3 my setup stopped working I cannot choose and insert images anymore in my frontend form CKEditor field with the pwimage plugin. If I click on the insert image button in the editor toolbar, nothing happens and it throws a js error: It seems the way the pwimage plugin works changed significantly. I guess I need to load some additional scripts in the frontend to make this work again but I can't seem to find what is missing. Any help would be much appreciated. EDIT To make frontend forms work, I added this to the head: <?php if ($user->isLoggedin()) { ?> <script> <?php $jsConfig = $config->js(); $jsConfig['urls'] = array( 'root' => $config->urls->root, 'admin' => $config->urls->admin, 'modules' => $config->urls->modules, 'core' => $config->urls->core, 'files' => $config->urls->files, 'templates' => $config->urls->templates, 'adminTemplates' => $config->urls->adminTemplates ); ?> var config = <?php echo json_encode($jsConfig); ?>; </script> <?php } ?> This outputs a JS config variable in json format. When I compare the output of config from the admin page edit source to my frontend page edit source, I find that following part is missing in the config json on the frontend: "modals": { "large": "15,15,30,30,draggable=false,resizable=true,hide=250,show=100", "medium": "50,49,100,100", "small": "100,100,200,200", "full": "0,0,0,0" }, "JqueryWireTabs": { "rememberTabs": 0 }, Now what do I need to add when building the json via PHP so that this gets included also on the frontend? EDIT2: I think I found it. In wire/config.php around line 848 there is $config->modals = array( 'large' => "15,15,30,30,draggable=false,resizable=true,hide=250,show=100", 'medium' => "50,49,100,100", 'small' => "100,100,200,200", 'full' => "0,0,0,0", ); I added this to my code so it now reads: <?php if ($user->isLoggedin()) { ?> <script> <?php $config = $this->wire('config'); $jsConfig = $config->js(); $jsConfig['modals'] = $config->modals; $jsConfig['urls'] = array( 'root' => $config->urls->root, 'admin' => $config->urls->admin, 'modules' => $config->urls->modules, 'core' => $config->urls->core, 'files' => $config->urls->files, 'templates' => $config->urls->templates, 'adminTemplates' => $config->urls->adminTemplates ); ?> var config = <?php echo json_encode($jsConfig); ?>; </script> <?php } ?> And, voila, the modal for selecting images is now working again on my frontend form
  6. 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.
  7. Thank you, Ryan, for looking into this. Yes, they occurred immediately after each other.
  8. 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
  9. 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.
  10. 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.
  11. 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.
  12. 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?
  13. 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.
  14. 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.
  15. 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.
  16. 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.
  17. 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.
  18. 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"?
  19. 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
  20. 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
  21. 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/
  22. 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?
  23. 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.
×
×
  • Create New...