Jump to content

gebeer

Members
  • Posts

    1,391
  • Joined

  • Last visited

  • Days Won

    39

Everything posted by gebeer

  1. @Soma I am sorry, didn't mean to flood the forum with this. Was just exited about the whole thing and that maybe made me go a bit far... Your proposed solution for setup and custom selector to get this working with pages that don't share the same tree is great. Very much appreciated. I put something together quickly to have the same functionality in a frontend form with the help of a jQuery plugin.
  2. @Soma that looks great! I am only having trouble understanding where exactly I need to put the "select_page" field and what the selector for this one would be. Because I am not sure what "options pages" refers to. Are these the area and event pages in your example? EDIT: I got it working now for my scenario. Thanks again. -destination template with title and country single page select field -tour template with title, country field and a destinations multi page select field with custom selector "country=page.country, select_page!='', template=destination"
  3. Your welcome. This is just on a playground site at the moment and will not be online until much later this year. But the code I posted is working for me.
  4. I am currently looking into dependent select fields or cascading select fields (as they are sometimes called), too. So I have a quite similar scenario as yours. I already have setup some working code that I want to share here. For a better understanding about my scenario: 1. parent countries with list of all countries 2. parent destinations, each destination gets assigned one country through "countries" pages asm select field. 3. parent tours, each tour gets assigned 1 or more countries through "countries" field and 1 or more destinations from "destinations" pages asm select field In tours form, when countries are selected I want to filter the destinations field to only show destinations of the previously chosen countries. For my solution I am using this jQuery plugin. So you need to call this in your template. My code is still a work in progress and written around my requirements but should be fairly easy to transfer to other contexts. Template code <?php // do not load _main.php for ajax requests if($config->ajax) $useMain = false; // provide dropdown data for the ajax request if ($input->post->depdrop_parents) { $ids = $input->post->depdrop_parents; $params = $input->post->depdrop_params; $options = []; $option = []; if (count($ids) == 1) { // only 1 id $pages = $pages->find("template=$params[0], countries=$ids[0]"); } // todo else { handle multiple ids} foreach ($pages as $page) { $option["id"] = $page->id; $option["name"] = $page->title; $options[] = $option; } echo json_encode(['output'=>$options, 'selected'=>'']); } // render the form if (!$config->ajax) { $content = ""; $destinations = $pages->find("template=destination,sort=countries.title"); $options = []; $option = []; // build options array for first select field: this is very specific to my scenario foreach ($destinations as $destination) { if (seekKey($options, $destination->countries->first()->id) == $destination->countries->first()->id) continue; $option["value"] = $destination->countries->first()->id; $option["name"] = $destination->countries->first()->title; $options[] = $option; } $content = "<form> <select id='parent' name='countries'>"; foreach ($options as $option) { $value = $option["value"]; $name = $option["name"]; $content .= "<option value='$value'>$name</option>"; } $content .= "</select>"; $content .= "<select id='child-1' name='destination'> </select>"; // need hidden input with value "destination" to populate params for the JS plugin // with the value that will be used as template value above in line 14 $content .= "<input type='hidden' id='dest' value='destination'> //todo submit button and logic </form>"; } In my functions.inc // Find the value in a multidimensional array function seekKey($haystack, $needle){ $output = ""; foreach($haystack as $key => $value){ if($value == $needle){ $output = $value; }elseif(is_array($value)){ $output = seekKey($value, $needle); } } return $output; } Javascript $(document).ready(function () { $("#child-1").depdrop({ url: './', depends: ['parent'], params: ['dest'], initialize: true }); }); Hope this helps.
  5. @Soma Thank you for clarifying I was thinking of it as an extra field type because "parent=page.anotherpageselect" is only working for pages that live under the same parent like you explained here. I'd need something more flexible that can be applied to page select fields whose pages have different parents. Meanwhile I posted about this in Wishlist&Roadmap.
  6. Hello, I am not so new here anymore but still very excited to get to know PW and all the forum users

  7. @adrian Thanks for the pointer. I had already found that here. But as Soma points out it only works for pages that are nested under the same parent. I would need something like this for page select fields that live under different parents in the page tree. My use case: 1. parent countries with list of all countries 2. parent destinations, each destination gets assigned one country through "countries" pages asm select field. 3. parent tours, each tour gets assigned 1 or more countries through "countries" field and 1 or more destinations from "destinations" pages asm select field In tours form, when countries are selected I want to filter the destinations field to only show destinations of the previously chosen countries. Destinations cannot live under countries because I need them under a separate parent where the user can add destinations easily without having to drill through the 249 available countries and search for the right one where they want to add their destinations under. What I think would work in theory: An inputfield type that lets you define which select fields in a template depend on each other and what the hierarchy of those fields is. This inputfield type adds the JS logic to the template form that will get the option values for the dependent select fields via AJAX call and fills them. The PHP of the inputfield type holds the logic to retrieve the right pages for the AJAX request. There are jQuery plugins like this or this available that could be used. Or the JS that is already there when using selector "parent=page.otherpagefield".
  8. @kongondo Thank you for pointing me to that one. But it doesn't do what I need and what Ryan is demonstrating in his introduction video to Select Multiple Transfer module: one select field that gets filled based on the previously selected option in another select field. I just posted about this in Wishlist&Roadmap. Maybe we better continue there because I think this is kind of going beyond the scope of this thread?
  9. In the thread for the Select Multiple Transfer module Ryan mentions that he used "dependent selects" for his introduction video: I searched the dev code and the forum up and down but can't seem to find this fieldtype. Has development been discontinued? I would really love to see that fieldtype in PW and would even be happy to pay for it if it was published as a pro field. I switched over to PW from Joomla/Seblod and they have a fieldtype called "Select Dynamic Cascade" that does just that.
  10. In addition to the Service Pages module mentioned by diogo, there is also a rest helper for processwire made by clsource. I am using it in a new project that implements bidirectional communication between mobile devices and a PW powered site. It is working great so far. I extended clsource's code to support basic HTTP Authentication.
  11. @SteveB My use case: 1. parent countries with list of all countries 2. parent destinations, each destination gets assigned one country through "countries" pages asm select field. 3. parent tours, each tour gets assigned 1 or more countries through "countries" field and 1 or more destinations from "destinations" pages asm select field In tours form, when countries are selected I want to filter the destinations field to only show destinations of the previously chosen countries. Destinations cannot live under countries because I need them under one parent where the user can add destinations easily without having to drill through the 249 available countries and search for the right one where they want to add their destinations under. What I think would work in theory: An inputfield type that lets you define which select fields in a template depend on each other and what the hierarchy of those fields is. This inputfield type adds the JS logic to the template form that will get the option values for the dependent select fields via AJAX call and fills them. The PHP of the inputfield type holds the logic to retrieve the right pages for the AJAX request. I switched over to PW from Joomla/Seblod and they have a fieldtype called "Select Dynamic Cascade" that does just that. Ryan writes in his thread about Select Multiple Transfer module that he used dependent selects for the video demo: So the fieldtype that I am looking for seems to exist somewhere but I can't find it. I already asked in that thread but got no answer so far.
  12. The serpentine path on my humble quest for the mysterious dependent select input field type that is mentioned by Ryan here and cheered a lot about further down the same thread, led me here. With great expectations I went straight to the linked git repo, only to find these lines: Please allow me one question before I continue my hunt for this seemimngly lost or hidden and so hardly desired feature: Your fieldtype will not work if the pages that the 2 dependent select fields refer to, are not in the same tree, right? Following another turn-off in my frantic search, I discovered this interesting thread and thought I had reached the end of my journey for good. But that method is also only working for pages in the same tree like Soma patiently explains. I desparately need dependent selects for pages with different parents and hope that one day some more light will be shed on the matter for that my and my fellow travellers restless expedition will finally come to a happy ending.
  13. I just installed this great theme and was searching for about 15 min how to activate it. Then I came across this thread and now I know about this config setting. I totally wasn't aware of the switch in user edit profile page. Maybe because until this day I only used the default theme. I think it could save many people quite some time if this information was visible more prominently somewhere in the docs or even on the admin themes module page. What do you think?
  14. This looks like a great module, thank you! I came here searching for dependent select options with PW. Now I'm reading that the video demo uses dependent selects. That is exactly what I need. But I can't seem to find a fieldtype "dependent selects". Is this part of some other fieldtype that I need to install first or how do I set up 2 dependent select fields in the backend?
  15. You can install the profile first and then open a terminal in site/templates and do "bower install". Sorry, I now see that my instructions are not clear about the sequence of steps here. I amended that.
  16. Since I've been working on a few projects where I used Bootstrap 3 and will be using it for future projects, I put together a blank site profile with Bootstrap 3 Sass, Fontawesome and a few markup render functions for Bootstrap dropdown menu, image carousel and accordion. You can find it at https://github.com/gebeer/site-pwbs Features bootstrap-sass-official font-awesome SASS version jquery modernizr render functions for:BS3 dropdown menu BS3 accordion from PageArray BS3 carousel from PW images array Prerequisites compass bower How to install from zip: download the zip extract the folder "site-pwbs" into a clean ProcessWire install's root folder during install of ProcessWire choose the profile "bootstrap-sass-official fontawesome blank profile" After installation The last step after installing the profile is to install all assets with bower: open a terminal in site/templates and execute "bower install" How it works The profile is based on the blank site profile that comes with PW 2.5 and uses the delegate template approach. It comes with a top navbar, a main container and a footer section. Rest is up to you. CSS gets compiled through compass. You can easily override BS variables and exclude BS components that you don't need. I intentionally did not add structure to the sass folder so you can structure your partials yourself as you please. There is only one folder "generic" with _mixins.scss whith a very lean and flexible breakpoint mixin that I discovered here. JS Since I only use the BS javascript plugins I really need, I usually copy them over to my plugins.js file. I use bower to install bootstrap-sass-original and fontawesome because it gives more flexibility than requiring them through ruby gems. This way you can tweak the BS and FA partials to your liking (of course only if you don't intend to do "bower update" further down the road) Enjoy!
  17. @adrian Yes, that is the one. Info also at http://webcomponents.org/polyfills/ @LostKobrakai Your idea with custom .htaccess rule to allow access of html in bower_components is great I'll see if I can put one together...
  18. This might be a dumb question. But what would be the solution to work with web components import links in a PW template and still maintain good security? I guess that rewrite condition is there for a good reason. But also the use of polymers imports is probably going to increase in future. So it would be great to find a secure way of making them work together smoothly with PW.
  19. Thank you guys, I did a search for webcomponents import instead of polymer. That's why that thread didn't come up.
  20. Hello all, on a new project I want to use https://github.com/stevenrskelton/flag-icon which implements svg icons for country flags via webcomponents import. In the <head> I import the webcomponents polyfill js and the flag icons html with <script src="<?php echo $config->urls->templates; ?>bower_components/webcomponentsjs/webcomponents.min.js"></script> <link rel="import" href="<?php echo $config->urls->templates; ?>bower_components/flag-icon/flag-icon.html"> But I get a 403 error: NetworkError: 403 Forbidden - http://dev/pwtest/site/templates/bower_components/flag-icon/flag-icon.html For testing I did: 1. a clean install of html5-boilerplate (not in PW), added flag-icons through bower and linked the resources as above. Here I don't get the 403 error. 2. a clean install of processwire with the blank profile, added flag-icon through bower and linked the resources as above. And here I get the error again. I did this on 2 different servers. Same result. I also checked permission of the import file and they are fine (644). Then I tried to make a demo install on lightning.pw but the service exits with "We're sorry, but something went wrong." To me this seems to be a ProcessWire related problem. Maybe somebody can confirm this or has an idea what is happening? Thank you.
  21. OK, I added SOLVED to the thread title.
  22. I would like to mark this as solved. But the "Mark Solved" Button is missing. I just used it on another thread of mine. But here it is not available. I opened the thread, so I should see this button?
  23. Thanks clsource! This really helps me for better understanding the whole hooking thing in PW. Instead of messing with cookies, I decided to better use token based authentication instead of sessions. Cheers Gerhard
  24. Thank you! I am now going with the token approach. That is much cleaner and more REST like.
×
×
  • Create New...