-
Posts
1,559 -
Joined
-
Last visited
-
Days Won
49
Everything posted by gebeer
-
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.
-
@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.
-
Thank you for confirming.
-
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.
-
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?
-
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?
-
Bootstrap 3 SASS Fontawesome Blank Site Profile
gebeer replied to gebeer's topic in Themes and Profiles
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.- 6 replies
-
- Fontawesome
- Blank Site Profile
-
(and 2 more)
Tagged with:
-
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!
- 6 replies
-
- 8
-
-
- Fontawesome
- Blank Site Profile
-
(and 2 more)
Tagged with:
-
@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...
-
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.
-
Thank you guys, I did a search for webcomponents import instead of polymer. That's why that thread didn't come up.
- 3 replies
-
- webcomponents
- polyfill
-
(and 3 more)
Tagged with:
-
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.
- 3 replies
-
- webcomponents
- polyfill
-
(and 3 more)
Tagged with:
-
[SOLVED] Pass data to custom user method
gebeer replied to gebeer's topic in Module/Plugin Development
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? -
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
-
Thank you! I am now going with the token approach. That is much cleaner and more REST like.
- 32 replies
-
- helper
- processwire
-
(and 2 more)
Tagged with:
-
I usually make clear in my offer/cost estimate whether I am responsible for the wording or the client. This helps to avoid problems at a later stage. Also to make clear that time I put into wording review and improvement will be charged extra. PS: maybe this should be moved to the dev talk thread?
-
Hello, part of my new project is providing a RESTful webservice through PW. I am using clsource's REST Helper for ProcessWire which is working great. For the REST service part of the site I would like to suppress the setting of session cookie for $session->login and $session->logout because I don't need sessions and I don't want to have Set-Cookie in my response header. For user authentication in a PUT request I use $session->login() to verify username and password: $uId = $input->urlSegment1; $u = $users->get($uId); if ($session->login($u->name, $params["upass"])) { $session->logout(); //update user data } In the response header for that request I get: Set-Cookie: wire=ha6io723mkfc9v4scdib3oe8g7; path=/; HttpOnly wire=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT wire=1n8faeiva3vg7u13ijsrs24bt1; path=/; HttpOnly wire_challenge=YK0WRw0Wrd2ZAhKEUCLPOHd9iSySEPb91; expires=Tue, 07-Apr-2015 14:11:24 GMT; path=/; httponly wire=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT wire=u9m41s8b87d3ca1jp1jbl0r6k3; path=/; HttpOnly wire=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT wire=oidcbmht561qnvts2fjnq4b7p3; path=/; HttpOnly persist=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/ At the moment I get rid of it by doing header_remove("Set-Cookie"); But I would like to avoid setting of that cookie in the first place. I found the relevant methods ___login and ___logout in /wire/core/Session.php But searching Captain Hook for "logout" doesn't bring up those methods. I assume they should be hookable because they start with 3 underscores. Now how would I hook into those methods from my template file (not as an autoload module)? The webservice endpoint url is .../api/users/ and my temlate file for that is users.php What I've tried so far is wire()->addHookBefore('Session::logout', null, 'logoutNoCookie'); function logoutNoCookie($event) { $event->replace = true; $sessionName = session_name(); $_SESSION = array(); // if(isset($_COOKIE[$sessionName])) setcookie($sessionName, '', time()-42000, '/'); // if(isset($_COOKIE[$sessionName . "_challenge"])) setcookie($sessionName . "_challenge", '', time()-42000, '/'); session_destroy(); session_name($sessionName); $this->init(); session_regenerate_id(true); $_SESSION[$this->className()] = array(); $user = $this->wire('user'); $guest = $this->wire('users')->getGuestUser(); $this->wire('users')->setCurrentUser($guest); $this->trackChange('logout', $user, $guest); if($user) $this->logoutSuccess($user); $event->return = $this; } But this gives me an error: Fatal error: Using $this when not in object context because I'm placing my hook function outside the class context. What would be the correct way for calling the hook and placing my hook function?
-
header_remove("Set-Cookie"); did the trick. I guess this is not the cleanest way of doing it. I opened a new thread to find out how I can suppress cookies in the first place as this is somewhat beyond the scope of this thread here.
- 32 replies
-
- helper
- processwire
-
(and 2 more)
Tagged with:
-
Thanks again for your help. I will give header_remove a try when I'm back at my office and report back here. Cheers Gerhard
- 32 replies
-
- helper
- processwire
-
(and 2 more)
Tagged with:
-
Thank you clsource! I would like to use PW built in functionality for authenticating my users rather than implementing my own. I am aware though, that the RESTful approach is supposed to work without server side session handling. That is why I only login the user to check if the correct password was sent and then logout of the session instantly. If there is a way to avoid the Cookie info in the response header, that would be what I'm looking for. If there is none, I will have to rethink my approach and use a token along with the password in the Authentication header. Also I'm a bit confused about the cookie data in the response header. wire cookies expire 1970 and there are several of them? So if anybody can think of a PW API method to suppress cookies, that would be great.
- 32 replies
-
- helper
- processwire
-
(and 2 more)
Tagged with:
-
@clsource Thank you for your REST helper. I'm using it for a project and it is working fine. For my project I'm using basic HTTP Authetication. I added some code to the params method to fetch username and password and merge it into the $params array. The altered code is here: https://gist.github.com/gebeer/5d1447ff76e17931d944#file-rest-php-L265 For a PUT request I use $session->login() to verify username and password. $uId = $input->urlSegment1; $u = $users->get($uId); if ($session->login($u->name, $params["upass"])) { $session->logout(); //update user data } In the response header of that request I get some PW cookie data: Set-Cookie: wire=ha6io723mkfc9v4scdib3oe8g7; path=/; HttpOnly wire=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT wire=1n8faeiva3vg7u13ijsrs24bt1; path=/; HttpOnly wire_challenge=YK0WRw0Wrd2ZAhKEUCLPOHd9iSySEPb91; expires=Tue, 07-Apr-2015 14:11:24 GMT; path=/; httponly wire=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT wire=u9m41s8b87d3ca1jp1jbl0r6k3; path=/; HttpOnly wire=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT wire=oidcbmht561qnvts2fjnq4b7p3; path=/; HttpOnly persist=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/ Can I avoid that somehow other than not using session? In the PW cheatsheet I couldn't find anything related to cookies.
- 32 replies
-
- 2
-
-
- helper
- processwire
-
(and 2 more)
Tagged with:
-
[SOLVED] Pass data to custom user method
gebeer replied to gebeer's topic in Module/Plugin Development
Thank you both, LostKobrakai and Soma ! I call my custom method with $user->saveprofile($params) and can access the data in my method with $userData = $event->arguments(0); PS: Missing the Solved Button -
Hello, I want to add a custom method to the user object and need to pass some data ( an array called $params) to the method when I call it. I will call the method like this $user->saveprofile($params); The method takes that data and saves it to a user profile page. Only I don't know how to pass that data to my custom method. This might be a silly question. Please forgive me, but I am fairly new to OOP and PW modules/hooks development. This is what I have so far (taken off examples from here): public function init() { // init() is called when the module is loaded. $this->addHook('User::saveprofile', $this, 'UserSaveProfile'); } public function UserSaveProfile($event) { //how to pass my $params array to this method // Get the user object $user = $event->object; // get user data - this is where I am stuck $userData = // condition and actions if($user->hasRole("frontend")) { //create and save user profile page $this->message("Userprofile page for user " . $user->name . "has been created"); } } I tried to find examples of how to do that but could not find anything related in the forum. Any help would be appreciated. Thank you.
-
You define $tagnames as an empty string with $tagnames = ""; Later in your foreach loop you treat $tagnames as an array and add items to it in $tagnames[] = $tag->id; Maybe you should declare $tagnames as empty array in the first place, like $tagnames = array(); not sure though if this solves your problem... EDIT: Sorry, I just read in the PHP documentation So forget about what I said above...