Leaderboard
Popular Content
Showing content with the highest reputation on 08/02/2017 in all areas
-
OAuth2Login for ProcessWire A Module which give you ability to login an existing user using your favorite thrid-party OAuth2 provider (i.e. Facebook, GitHub, Google, LinkedIn, etc.).. You can login from the backend to the backend directly or render a form on the frontend and redirect the user to a choosen page. Built on top of ThePhpLeague OAuth2-Client lib. Registration is not handled by this module but planned. Howto Install Install the module following this procedure: - http://modules.processwire.com/modules/oauth2-login/ - https://github.com/flydev-fr/OAuth2Login Next step, in order to use a provider, you need to use Composer to install each provider ie: to install Google, open a terminal, go to your root directory of pw and type the following command-line: composer require league/oauth2-google Tested providers/packages : Google : league/oauth2-google Facebook: league/oauth2-facebook Github: league/oauth2-github LinkedIn: league/oauth2-linkedin More third-party providers are available there. You should be able to add a provider by simply adding it to the JSON config file. Howto Use It First (and for testing purpose), you should create a new user in ProcessWire that reflect your real OAuth2 account information. The important informations are, Last Name, First Name and Email. The module will compare existing users by firstname, lastname and email; If the user match the informations, then he is logged in. ie, if my Google fullname is John Wick, then in ProcessWire, I create a new user Wick-John with email johnwick@mydomain.com Next step, go to your favorite provider and create an app in order to get the ClientId and ClientSecret keys. Ask on the forum if you have difficulties getting there. Once you got the keys for a provider, just paste it into the module settings and save it. One or more button should appear bellow the standard login form. The final step is to make your JSON configuration file. In this sample, the JSON config include all tested providers, you can of course edit it to suit your needs : { "providers": { "google": { "className": "Google", "packageName": "league/oauth2-google", "helpUrl": "https://console.developers.google.com/apis/credentials" }, "facebook": { "className": "Facebook", "packageName": "league/oauth2-facebook", "helpUrl": "https://developers.facebook.com/apps/", "options": { "graphApiVersion": "v2.10", "scope": "email" } }, "github": { "className": "Github", "packageName": "league/oauth2-github", "helpUrl": "https://github.com/settings/developers", "options": { "scope": "user:email" } }, "linkedin": { "className": "LinkedIn", "packageName": "league/oauth2-linkedin", "helpUrl": "https://www.linkedin.com/secure/developer" } } } Backend Usage In ready.php, call the module : if($page->template == 'admin') { $oauth2mod = $modules->get('Oauth2Login'); if($oauth2mod) $oauth2mod->hookBackend(); } Frontend Usage Small note: At this moment the render method is pretty simple. It output a InputfieldForm with InputfieldSubmit(s) into wrapped in a ul:li tag. Feedbacks and ideas welcome! For the following example, I created a page login and a template login which contain the following code : <?php namespace ProcessWire; if(!$user->isLoggedin()) { $options = array( 'buttonClass' => 'my_button_class', 'buttonValue' => 'Login with {provider}', // {{provider}} keyword 'prependMarkup' => '<div class="wrapper">', 'appendMarkup' => '</div>' ); $redirectUri = str_lreplace('//', '/', $config->urls->httpRoot . $page->url); $content = $modules->get('Oauth2Login')->config( array( 'redirect_uri' => $redirectUri, 'success_uri' => $page->url ) )->render($options); } The custom function lstr_replace() : /* * replace the last occurence of $search by $replace in $subject */ function str_lreplace($search, $replace, $subject) { return preg_replace('~(.*)' . preg_quote($search, '~') . '~', '$1' . $replace, $subject, 1); } Screenshot7 points
-
Just read your comment here and found out AOS now has some profound documentation. You're a monster, @tpr! The wiki is awesome! I saw it and said to myself: "Ha, but he probably does not have changelog!" But I was wrong (and astonished)! I think the main PW repo could benefit from a CHANGELOG.md like this. Especially that there are enough of nice changes to be mentioned almost every week. Sorry for offtop))3 points
-
I'm looking forward to client-side image resizing in PW. I have clients who will upload massive 24-megapixel 10MB images without a second thought. I use the "Max width for uploaded images" option but it's not working reliably because the oversized images still get through somehow (perhaps out-of-memory issues). Anyway, I was looking for a foolproof way for non-tech-savvy clients to resize images and found this: https://bulkresizephotos.com/ Images are resized client-side so it's much faster than many of the other online tools. You can resize multiple images at once and get a ZIP file back with the results. And the best feature is that you can set the tool up how you want and then generate an embeddable drag-and-drop widget, so it's super-easy for clients to use and there are no options for them to mess up. I created a Hanna Code for the widget and added it to the online documentation I supply to clients so it's right there when they need it. Could even potentially be embedded directly in the admin theme. Until client-side resizing comes to PW this is a useful stopgap.2 points
-
Hello! If this can help someone, this is how I build my login form: // Sign In controller <?php namespace ProcessWire; /** * Class SignIn * * @package ProcessWire */ class SignIn { /** * Render * * @return string * */ public function render(): string { $input = wire("input"); $template = $this->getSignInTemplate(); if($input->post("login_submit")) { // taken from ProcessLogin->execute(); $name = wire('sanitizer')->pageName($input->post("login_name")); $pass = substr($input->post("login_pass"), 0, 128); if(wire('session')->login($name, $pass)) { // Successful login wire("session")->redirect(""); } else { // Login failed $template->set("error", "login failed!"); $template->set("sign_in_form", $this->signInForm()); } } else { // set template variables $template->set("sign_in_form", $this->signInForm()); } return $template->render(); } /** * @return string */ protected function signInForm() { $input = wire("input"); $modules = wire("modules"); // create a new form field (also field wrapper) $form = $modules->get("InputfieldForm"); $form->action = "./"; $form->method = "post"; $form->attr("id+name", 'sign-in-form'); $f = $modules->get('InputfieldText'); $f->set('label', "Username"); // Login form: username field label $f->attr('id+name', 'login_name'); $f->attr('class', 'Name'); $f->attr('value', $input->post("login_name")); $f->collapsed = Inputfield::collapsedNever; $form->add($f); $f = $modules->get('InputfieldText'); $f->set('label', "Password"); // Login form: password field label $f->attr('id+name', 'login_pass'); $f->attr('type', 'password'); $f->attr('class', 'Pass'); $f->collapsed = Inputfield::collapsedNever; $form->add($f); $f = $modules->get('InputfieldSubmit'); $f->attr('name', 'login_submit'); $f->attr('value', "Sign in"); // Login form: submit login button $form->add($f); return $form->render(); } /** * Get Sign In template * * @return \TemplateEngine * */ protected function getSignInTemplate(): \TemplateEngine { return wire("factory")->load("/components/sign-in"); } } Thanks :).2 points
-
2 points
-
In general, you should do this by putting your HTML structure into your template files. Only content should come from your fields. So this... ...should be in your template file, not in a textarea field. Once you've got the hang of "normal" template files you can explore field template files too - these are more of an optional extra than a must have.2 points
-
Anyway, I use another solution: I convert the array into a json object, put it into the session variable and afterwards I convert it back to an array like this. Inside $Post $valuesbefore = array( $user->fields->get('usergender')->$label => $user->usergender->id, $user->fields->get("user_first_name")->$label => $user->user_first_name, $user->fields->get("user_real_name")->$label => $user->user_real_name, $user->fields->get('email')->$label => $user->email, _t('Username', 'Login') => $user->name, //$user->fields->get('pass')->$label => 'yes', $user->fields->get('language')->$label => $user->language->id, $user->fields->get('userimage')->$label => $user->userimage->basename, 'Password' => 'no'//special type ); $valuesbefore = json_encode($valuesbefore); $session->predata = $valuesbefore; The session variable predata holds the json array and after submission I grab this session variable and convert it back to a php array like this: $valuesbefore = json_decode($session->predata, true); Now I have submitted a session with an array1 point
-
If I understood correctly what is the need, here is another simple idea I used in the past to have a text field where you can add hundreds of url's one per line. After that, wherever you need to pull every url, you just grab the line and you are done: <?php foreach(explode("\n", $page->your_urls_text_field) as $url) { // Explode every new line as a new url echo "<p>$url<br />"; //You can add <a href.. etc. } ?> The only requirement is to have every new url on a new line to make it work. Hope that helps...1 point
-
https://github.com/rolandtoth/AdminOnSteroids/wiki#fieldandtemplateeditlinks1 point
-
Admin on steroids adds that functionality (among many others). Just for the record.1 point
-
Great, @mel47! But I was not actually advising to add an extra field to the template. I thought it would be enough just to write $page->sizeColumn = 2; before the render call. It would add a temporary property to the current $page object, which will be passed to field template (but will not write this field to database).1 point
-
Ok great that it works for you....a more complex solution with a hook on saveReady if SEO fields are empty put some own magic in there....if tey not empty do nothing... functions that i use: the hook itself works in admin.php under site/templates/: As always it is not the best PHP code since im no professional....but it works for me....if i somedays get some time i could add something like that with optionfields to the module itself. Best regards mr-fan1 point
-
1 point
-
That is unlikely an error with the ProcessVue template. Are you using Ubuntu? I found this thread with a similar problem where they fixed it by using the "--unsafe-perm" flag during "npm i", so basically you'd have to run it with this command: "npm --unsafe-perm i". Edit: from that thread it seems that the user you're using may not have the right write permissions.1 point
-
This block thingy are features of the template engines (twig, smarty, jade...). ProcessWire does not offer this, you may look at regions, though I've never used them. This module does not implement any new features, it just serves to connect different template engines to ProcessWire and to use them via a common interface. If you use ProcessWire as template engine, you get all the features of ProcessWire templates: http://processwire.com/api/templates/ Cheers1 point
-
Hey, @mel47! Here is the code for the method. Seems like the 3rd parameter is to override default field value, not to provide additional variables to the template: @param mixed|null $value Optionally specify value to render, otherwise it will be pulled from this $page. Did not try this, but you probably can do this to have additional variable in the field template context: // main template $page->$sizeColumn = 2; $content .= $thanks_page->render('images', '/images_column'); // images_column.php foreach($value as $image) { echo " <article class='column is-{$page->sizeColumn}'> .... }1 point
-
This describes a kind of liberty ... (this is why I find Processwire so attractive).... but... ..''Is the technology an instrument of liberation or enslavement?'' You have four hours. GO ! Just joking Thank you for the answers: each of them open up the door a little more.1 point
-
1 point
-
more ideas: https://modules.processwire.com/modules/fieldtype-yaml/ https://modules.processwire.com/modules/fieldtype-matrix/ ProFields: Page Table in the core.1 point
-
My clients have also been using bulkresizephotos.com for a while, so far it's been a reliable service.1 point
-
Following on from Kongondo's answer: https://processwire.com/talk/topic/4134-include-template-name-in-admin-page-list/ Although you might want to do it via the ProcessPageList settings so that it works for all templates: /processwire/module/edit?name=ProcessPageList1 point
-
Where you can do some nice integration with Shopify is via their post order hooks. You can very easily set Shopify to ping a URL on your ProcessWire site with some JSON data about an order, immediately after it takes place. From there you can easily automate creation of member accounts, for example.1 point