pwFoo
Members-
Posts
708 -
Joined
-
Last visited
Everything posted by pwFoo
-
Module FrontendUser: login, logout and register users / members
pwFoo replied to pwFoo's topic in Modules/Plugins
Set a field to not required is done with FrontendUserRegisterEmailValidation "plugin" $form->get('password')->required = false; $form->get('EmailPreValidation')->required = false; You can remove fields with required false // prepare / modify registration form $form->remove($form->get('password')); -
Module FrontendUser: login, logout and register users / members
pwFoo replied to pwFoo's topic in Modules/Plugins
Take a look here how to manipulate forms: https://bitbucket.org/pwFoo/frontenduser/wiki/Login extensions and plugins https://bitbucket.org/pwFoo/frontenduser/wiki/Register extensions and plugins https://bitbucket.org/pwFoo/frontenduser/wiki/Code snippets / Examples You could try to hook FrontendUser::save $fu->addHookBefore('save', function($event) { $userObj = wire('fu')->userObj; $form = wire('fu')->form; // Do... }); Or username or email field // hook after field processed (form need to be submitted) $myField->addHookAfter('processInput', function($event) { $form = wire('fu')->form; $currentField = $event->object; // Do ... } -
Module FrontendUser: login, logout and register users / members
pwFoo replied to pwFoo's topic in Modules/Plugins
It could also be done with a PW hook Make username hidden and not required. Hook into form process and set the required user object value server side. -
Module FrontendUser: login, logout and register users / members
pwFoo replied to pwFoo's topic in Modules/Plugins
The module just uses PW features. So it uses the default user template. You need to add custom fields to save additional attributes! -
Module FrontendUser: login, logout and register users / members
pwFoo replied to pwFoo's topic in Modules/Plugins
Not the module, but PW. Just hook into form processing / user registration and generate the needed value before the user object will be saved. The module methods are hookable too. -
Module FrontendUser: login, logout and register users / members
pwFoo replied to pwFoo's topic in Modules/Plugins
Hi @modifiedcontent, your question isn't module related. It's form api related. -
Hi, I haven't tested it with caching or worked with PW caching yet. I'll do some tests with PW caching in the future... The module hookAfter Page::render and add the rendered page content to the global / layout TemplateFile object. // add current page output to global layout $this->layout->set($this->currentPageContent, $event->return); $event->return = $this->layout->render(); Anyone tested this approach with caching?
- 4 replies
-
- views
- templatefile
-
(and 2 more)
Tagged with:
-
WIP: TemplateFileHelper & AjaxIntercoolerJS
pwFoo replied to pwFoo's topic in Module/Plugin Development
Part two: Both modules are testing only!!!- 6 replies
-
- controller
- intercoolerjs
-
(and 4 more)
Tagged with:
-
Module: http://modules.processwire.com/modules/ajax-intercooler-js/ Repo: https://bitbucket.org/pwFoo/ajaxintercoolerjs AjaxIntercoolerJS module features integrates IntercoolerJS async CCS ("loadCSS") and JavaScript load / update optional disable async css / js handling for blocks, sidebar, ... Intercooler X-IC response header support support / hook $session->redirect multiple X-IC-Trigger handling multiple X-IC-Script handling Usage Basics It's a autoload module, but you need to enable it inside of your templates, because scripts and dependencies ("JqueryCore") have to be loaded too. You can enable / load it global inside of the TemplateFileHelper controller "_layout.php" $ic->enable(); Some changes are needed to your main template "_layout.tpl". <!-- IntercoolerJS needs a target with ID "pageContent" for (async) page content --> <div id="pageContent"><?=$pageContent?></div> And your navigation links need some IntercoolerJS attributes like that. <a href="..." ic-get-from='/url-to-load' ic-target='#sidebar'>...</a> Your just use and hook MarkupSimpleNavigation. $nav = $modules->get('MarkupSimpleNavigation'); $opts = array( 'show_root' => true, 'item_tpl' => "<a href='{url}' ic-get-from='{url}' ic-target='#pageContent' ic-push-url=true>{title}</a>", 'item_current_tpl' => "<a href='{url}' ic-get-from='{url}' ic-target='#pageContent' ic-push-url=true>{title}</a>", ); // optional modify a specific link to use another target. For example "#sidebar" $nav->addHookAfter('getTagsString', null, function($event) { $link = $event->arguments[1]; if ($link->title == 'sidebar') { $event->return = "<a href='{$link->url}' ic-get-from='{$link->url}' ic-target='#sidebar'>{$link->title} (sidebar)</a>"; } }); // render and set as _layout.tpl template var $layout->set('navigation', $nav->render($opts)); Disable CSS refresh (remove "current" styles and load the new one) The current loaded page css shouldn't removed if the sidebar is updated. So it's possible to disable the asyncHandler inside of the "sidebar" template. $ic->asyncHandler(false); Quick and dirty FrontendUser integration You just need a PW template file like that. $fu = $modules->get('FrontendUser'); $fu->login(); $button = $fu->form->fhSubmitBtn; $button->attr('ic-post-to', $page->url); $button->attr('ic-target', '#pageContent'); if (!empty($_GET['logout'])) { $fu->logout($page->url); } // Workaround until IntercoolerJS 1.0.1 release if ($input->post['ic-trigger-name']) { $input->post[$fu->form->fhSubmitBtn->name] = $input->post['ic-trigger-name']; } $processed = $fu->process($page->url); if ($processed && !$user->isGuest()) { // $processed == false if login failed (not submitted / login successful == true) echo "Hello $user->name!"; echo "<a href='$page->url?logout=1'>Logout</a>"; } else { echo $fu->render(); } X-IC Response Headers /** * Set x-ic-trigger response header * @param array $array One or more events with related data arrays */ public function trigger($array) { $json = json_encode($array); header('x-ic-trigger: ' . $json); } /** * Set x-ic-script response header * @param string $js Valid javaScript code */ public function script($js) { header('X-IC-Script: ' . $js); } /** * Stop current / parent element Intercooler polling */ public function cancelPolling() { header ('x-ic-cancelPolling: true'); } /** * Resume current / parent element Intercooler polling */ public function resumePolling() { header ('x-ic-resumePolling: true'); } /** * Set current / parent element Intercooler polling interval * @param string $interval */ public function setPollInterval($interval) { header ('x-ic-setPollInterval: ' . $interval); } /** * Set x-ic-refresh response header * @param string $pathCsv Comma separated paths to refresh. */ public function refresh($pathCsv) { header('x-ic-refresh: ' . $pathCsv); } /** * Set x-ic-open response header * @param string $url New window / tab address */ public function open($url) { header('x-ic-open: ' . $url); } /** * Set x-ic-redirect response header * @param string $url Redirect destination address */ public function redirect($url) { header('x-ic-redirect: ' .$url); } Wrapper for X-IC-Trigger Add a event trigger with event name ($event) and parameters array ($array). "addTrigger()" method is a wrapper for usage with multiple event triggers. Native method for a single execution is method "trigger()" $ic->addTrigger($event, $array); Wrapper for X-IC-Script String of javascript code for client side execution. "addScript()" method is a wrapper for multiple usage of "script()" method. $ic->addScript($javascript); $session->redirect is hooked! The module hooks $session->redirect() method for ajax calls. It's needed to execute redirects by IntercoolerJS X-IC-Redirect for ajax calls. Used for the FrontendUser integration.
- 1 reply
-
- 9
-
- ajax
- intercoolerjs
-
(and 1 more)
Tagged with:
-
WIP: TemplateFileHelper & AjaxIntercoolerJS
pwFoo replied to pwFoo's topic in Module/Plugin Development
Part one:- 6 replies
-
- controller
- intercoolerjs
-
(and 4 more)
Tagged with:
-
Module: http://modules.processwire.com/modules/template-file-helper/ Repo: https://bitbucket.org/pwFoo/templatefilehelper/overview TemplateFileHelper module features add global controller and template to current page by a Page::render hook Manage global ($layout) and current page ($view) styles and scripts with a $config->scripts / $config->styles context mapping. So $config->styles / $config->scripts works fine too load sub-templates with a controller file an array of data to fill template variables just an html template Ajax page load in mind Usage Global layout A global controller / template is added by a Page::render hook. /site/templates/_layout.php // controller /site/templates/_layout.tpl // view / html template Example _layout.tpl <!doctype html> <html lang="de"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>TemplateFileHelper Processwire</title> <?=$styles?> <?=$scripts?> </head> <body> <div id="nav"><?=$navigation?></div> <div id="pageContent"><?=$pageContent?></div> </body> </html> Example _layout.php // MarkupSimpleNavigation $nav = $modules->get('MarkupSimpleNavigation'); $layout->set('navigation', $nav->render($opts)); // Global and current page styles $styles = ''; foreach ($layout->styles as $style) { $styles .= "<link href='{$style}' rel='stylesheet' class='global'>"; } foreach ($view->styles as $style) { $styles .= "<link href='{$style}' rel='stylesheet' class='current'>"; } $layout->set('styles', $styles); // Global and current page scripts $scripts = ''; foreach ($layout->scripts as $script) { $scripts .= "<script src='{$script}' type='text/javascript' class='global'></script>"; } foreach ($view->scripts as $script) { $scripts .= "<script src='{$script}' type='text/javascript' class='current'></script>"; } $layout->set('scripts', $scripts); Current page The PW template of current page will rendered inside the global view by Page::render hook. /site/templates/basic-page.php // controller /site/templates/basic-page.tpl // view / html template Example basic-page.tpl <div><?=$contentHome?></div> Example basic-page.php $view->set('contentHome', 'Simple output...'); echo $view->render(); Output (for example to debug) is possible too. echo "My PW template file output..."; $view->set('contentHome', 'Simple output...'); echo $view->render(); Sub-templates It's possible to use sub-templates / chunks inside of a PW template / controller. Sub-template with controller / view files $part = $view->load('parts/test1', 'parts/test1'); // relative to /site/templates (view = .tpl, controller = .php $part = $view->load('parts/test1', true); // same as above. "True" instead of write identical path / file twice $part = $view->load('parts/test1', 'parts/test1_controller'); // view "parts/test1.tpl", controller "parts/test1_controller.php" Sub-template with array data $part = $view->load('chunks/test1', array('variable1' => "value1", 'variable2' => 'value2')); Sub-template just a html chunk $part = $view->load('chunks/test1'); // view file /site/templates/chunks/test1.tpl PW template file as view Because direct output inside a PW template file is possible it also works without a view. Example: PW template without viewTested with the FrontendUser module quick and dirty... $fu = $modules->get('FrontendUser'); $fu->login(); $button = $fu->form->fhSubmitBtn; if (!empty($_GET['logout'])) { $fu->logout($page->url); } $processed = $fu->process($page->url); if ($processed && !$user->isGuest()) { // $processed == false if login failed (not submitted / login successful == true) echo "Hello $user->name!"; echo "<a href='$page->url?logout=1'>Logout</a>"; } else { echo $fu->render(); } Scripts / Styles context The module itself takes care about the global (inside _layout.php) and "current" (inside PW template file). Just use PW $config to set styles and scripts. $config->scripts->add('...'); $config->styles->add('...'); You can also force the context by use the additional global api variables. $layout->scripts->add('...'); // global context $layout->styles->add('...'); // global context $view->scripts->add('...'); // current page context $view->styles->add('...'); // current page context
- 4 replies
-
- 4
-
- views
- templatefile
-
(and 2 more)
Tagged with:
-
Module FrontendUser: login, logout and register users / members
pwFoo replied to pwFoo's topic in Modules/Plugins
At the moment I think about a rewrite and code cleanup, but have no time to do it. The return value of process() method could cause a strange behavior because it returns "true" also if the form wasn't submitted because of the "return $this" for chaining public function process($redirect) { if ($this->form->fhProcessForm()) { switch ($this->action) { case 'Login': $result = $this->auth($this->userObj); break; case 'Register': $result = $this->save($this->userObj); break; } if ($result === true) { $this->session->redirect($redirect, false); // User sucessfully registered } else { $this->form->fhSubmitBtn->error($result); // Save user failed? } } return $this; } -
Module FrontendUser: login, logout and register users / members
pwFoo replied to pwFoo's topic in Modules/Plugins
I'll take a look... don't know when, but I think I have to change the clear session values part... // Clear session values wire('session')->remove('registerToken'); wire('session')->remove('registerUsername'); wire('session')->remove('registerEmail'); https://bitbucket.org/pwFoo/frontenduser/src/0070dc3106945198ac438bab3ab742b1784080e9/FrontendUser/FrontendUserRegisterEmailValidation.module?at=master&fileviewer=file-view-default#FrontendUserRegisterEmailValidation.module-165 https://bitbucket.org/pwFoo/frontenduser/src/0070dc3106945198ac438bab3ab742b1784080e9/FrontendUser/FrontendUserRegisterEmailValidation.module?at=master&fileviewer=file-view-default#FrontendUserRegisterEmailValidation.module-143 It should check and take care about field errors first. -
Anyone uses FormHelper with PW3? It should work and works fine for some FrontendUser tests, but isn't extensive tested.
-
Module FrontendUser: login, logout and register users / members
pwFoo replied to pwFoo's topic in Modules/Plugins
You can use examples from the forum or just modify to fit your needs. There is a mail example inside FrontendUserRegisterEmailValidation. PW hooks: https://processwire.com/api/hooks/ FrontendUser Wiki: https://bitbucket.org/pwFoo/frontenduser/wiki/Register extensions and plugins https://bitbucket.org/pwFoo/frontenduser/wiki/Login extensions and plugins https://bitbucket.org/pwFoo/frontenduser/wiki/Code snippets / Examples https://bitbucket.org/pwFoo/frontenduser/wiki/Documentation#markdown-header-styles-scripts-templates You can hook the FrontendUser methods auth (=login) and save (=register / save user). Just hook after FrontendUser save() and check the event return value if user was saved sucessful... Captain Hook -> search login -> /wire/core/session __login($name, $pass) I love the PW API and hooks -
Module FrontendUser: login, logout and register users / members
pwFoo replied to pwFoo's topic in Modules/Plugins
Take a look at the frontenduser repo wiki (nickname, default role) and the PW hook documentation for examples how to add / modify features. FrontendUser just use PW features (API, InputfieldForm and hooks)! Add own features / plugins by hook into PW / FrontendUser methods (add notification or welcome email after a new user registered successful). -
Module FrontendUser: login, logout and register users / members
pwFoo replied to pwFoo's topic in Modules/Plugins
Please test it with FrontendUser: 0.9.3 and report back. -
Module FrontendUser: login, logout and register users / members
pwFoo replied to pwFoo's topic in Modules/Plugins
@modifiedcontent // krisj / https://processwire.com/talk/topic/9811-frontenduser-login-logout-and-register-users-members/?p=122040 - $form->remove($form->get('EmailPreValidation')); //hide the token field before the email is sent = less distraction + //$form->remove($form->get('EmailPreValidation')); //hide the token field before the email is sent = less distraction $form->get('EmailPreValidation')->attr('disabled', true); @flydev // Load the plain / html email templates - $emailContentHtml = wire('page')->render(wire('fu')->getFile('validationEmail.php', 'templates'), $vars); + //$emailContentHtml = wire('page')->render(wire('fu')->getFile('validationEmail.php', 'templates'), $vars); + $file = wire('fu')->getFile('validationEmail.php', 'templates'); + $emailContentHtml = wireRenderFile($file, ['options' => $vars], ['default_path' => '']); -
Module FrontendUser: login, logout and register users / members
pwFoo replied to pwFoo's topic in Modules/Plugins
Hi @flydev, is it just PW 3.0.33 related? I haven't tested it with PW3... -
Module FrontendUser: login, logout and register users / members
pwFoo replied to pwFoo's topic in Modules/Plugins
No, there is no default like "SELF". Be careful "SELF" could cause a redirection loop: https://bitbucket.org/pwFoo/frontenduser/wiki/Documentation#markdown-header-prevent-redirection-loops return the current instance / object. echo out the object will print the class name I think. -
Module FrontendUser: login, logout and register users / members
pwFoo replied to pwFoo's topic in Modules/Plugins
Could be happen if $redirectDestination is empty. if (empty($redirect)) { return $this; } https://bitbucket.org/pwFoo/frontenduser/src/308afb5ae6517c210a0712fe0124f6892e2fd48f/FrontendUser/FrontendUser.module?at=master&fileviewer=file-view-default#FrontendUser.module-67 -
PW ticket system or simple project / task management would be nice...
-
This module should work with images / pwImage plugin: http://modules.processwire.com/modules/form-helper/ You could test it or take a look in the source how it work.
-
WIP: TemplateFileHelper & AjaxIntercoolerJS
pwFoo replied to pwFoo's topic in Module/Plugin Development
Added IntercoolerJS response header methods... Maybe I reduce the number of methods (for example combine setPollingInterval, cancelPolling, resumePolling with a param to switch case). /** * Set x-ic-trigger response header * @param array $array One or more events with related data arrays */ public function trigger($array) { $json = json_encode($array); header('x-ic-trigger: ' . $json); } /** * Set x-ic-script response header * @param string $js Valid javaScript code */ public function script($js) { header('X-IC-Script: ' . $js); } /** * Stop current / parent element Intercooler polling */ public function cancelPolling() { header ('x-ic-cancelPolling: true'); } /** * Resume current / parent element Intercooler polling */ public function resumePolling() { header ('x-ic-resumePolling: true'); } /** * Set current / parent element Intercooler polling interval * @param string $interval */ public function setPollingInterval($interval) { header ('x-ic-setPollInterval: ' . $interval); } /** * Set x-ic-refresh response header * @param string $pathCsv Comma separated paths to refresh. */ public function refresh($pathCsv) { header('x-ic-refresh: ' . $pathCsv); } /** * Set x-ic-open response header * @param string $url New window / tab address */ public function open($url) { header('x-ic-open: ' . $url); } /** * Set x-ic-redirect response header * @param string $url Redirect destination address */ public function redirect($url) { header('x-ic-redirect: ' .$url); } /** * Add ajax redirect handler to Session::redirect */ public function hookSessionRedirect($event) { $this->redirect($event->arguments[0]); $event->replace = true; } Also successfully tested AjaxIntercoolerJS with Frontenduser I'll do some more tests with PW inputfields (via FormHelper) soon.- 6 replies
-
- 1
-
- controller
- intercoolerjs
-
(and 4 more)
Tagged with:
-
Searched wysiwyg and textile (textile editor with toolbar would also be great...) javascript editors (ContentTool, Quill, wysihtml) and also looked at Trumbowyg again. Looks like much progress and active maintained. Latest commit is 4 days ago. Emoji, upload, pasteimage, table, ... plugins. @teppo Will the PW module also be updated to the latest release and support plugins?