pwFoo Posted October 18, 2014 Posted October 18, 2014 (edited) FrontendContentManager (unstable / testing) FrontendContentManager is a module based on FormHelper to generate needed page edit / add form via form api. NO sanitizing of form values at the moment!!! edit pages create / add new pages add, replace and remove images Download ProcessWire module page: http://modules.processwire.com/modules/frontend-content-manager Bitbucket Repo: https://bitbucket.org/pwFoo/frontendcontentmanager Version 0.2.0 Required FormHelper (0.7.1+) Usage Example template file <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title><?php echo $page->title; ?></title> <?php // Load FormHelper module and also set wire('fh') variable $fcm = $modules->get('FrontendContentManager'); // edit existing page //$form = $fcm->edit($pages->get('1108')); // add a new page based on a template and a parent object $parent = $pages->get('name=test'); $form = $fcm->add($parent, $parent->template); // jsConfig needed by ckeditor echo $fcm->JsConfig(); // outpunt needed scripts for inputfield modules, ... foreach ($config->styles as $file) { echo "<link type='text/css' href='$file' rel='stylesheet' />\n"; } foreach ($config->scripts as $file) { echo "<script type='text/javascript' src='$file'></script>\n"; } ?> </head> <body> <h1><?php echo $page->title; ?></h1> <?php // output the forom echo $form; ?> </body> </html> *UPDATED TO 0.1.0* At the moment I have no usage for FCM module, but after FormHelper 0.5.2 is finished I've done a quick FCM rewrite. Only few tests done yet! *UPDATED TO 0.2.0* Updated to work with redesigned FormHelper 0.7 Edited April 7, 2015 by pwFoo 5
adrian Posted October 18, 2014 Posted October 18, 2014 Hey pwFoo, Just a couple of things - it isn't possible to install your module directly from the modules directory because the bitbucket link doesn't work properly. FormHelper did download and install automatically though, so maybe you just need to tweak something with the url to your module. Next thing - I installed and put: $fcm = $modules->get('FrontendContentManager'); // edit page (editable permission needed) echo $fcm->edit($page); in a template file, but nothing was output and I was logged in as a superuser. Am I missing something obvious?
pwFoo Posted October 18, 2014 Author Posted October 18, 2014 Hi Adrian, is it a problem with the link or because the module isn't approved yet? Sorry my bad! I have to update the documentation. At current version I use url segments! But maybe I change this. Module checks permissions, template isn't an admin template AND url segment /add or /edit. What do you think. Should I remove the url segment check from module and move it to the template (in developers hand)?
adrian Posted October 18, 2014 Posted October 18, 2014 You're right - probably just because it isn't approved yet. Adding edit to the url - with url segments enabled did the trick, but I am concerned that there will be issues with your module relying on segments if the dev also wants to use segments for controlling output on the frontend. It might be better to just go with: /?edit=1
pwFoo Posted October 18, 2014 Author Posted October 18, 2014 Ok, thanks for testing I think it would be better to remove url segment check. So developer have the choice how to handle it (for example a simple if / else). I try to build it as simple and flexible as possible...
pwFoo Posted October 18, 2014 Author Posted October 18, 2014 It's also possible to edit any page... echo $fcm->edit($pages->get("/")); Next update url segment check will be removed.
Marty Walker Posted October 19, 2014 Posted October 19, 2014 I'm nowhere near my Mac. Does this work like Fredi does?
pwFoo Posted October 19, 2014 Author Posted October 19, 2014 Hi Marty, Fredi use the backend interface in an overlay. So you should get a styled edit page (like backend admin). FCM is based on FormHelper module (generate and process forms). You can use it inside the frontend page without an overlay and with your own styles. At the moment it's tested with simple pages/ templates. create pages edit page fields (it's also possible to skip fields and so remove from edit form) upload, replace and remove images) It's untested with multi language or repeater fields for example.
pwFoo Posted October 21, 2014 Author Posted October 21, 2014 I redesigned FCM to be more flexible. New testing branch working like this (inside a demo module "conversation"). public function add ($parent, $redirect = null, $options = array('clearValues' => true)) { $fcm = $this->modules->get('FrontendContentManager'); $form = $fcm->createForm($parent, $options); if ($fcm->formProcess()) { $page = $fcm->add($parent); // Manipulate page object from outside... $page->name = $page->id . '-' . $this->sanitizer->pageName($page->title); $fcm->save(); if ($redirect === null) $redirect = $page->url; $this->session->redirect($redirect); } return $form->render(); } public function edit ($topic, $options = null) { $fcm = $this->modules->get('FrontendContentManager'); $form = $fcm->createForm($topic, $options); if ($fcm->formProcess()) { $page = $fcm->edit($topic); // Manipulate page object outside... $page->name = $page->id . '-' . $this->sanitizer->pageName($page->title); $fcm->save(); $this->session->redirect($topic->url); } return $form->render(); } 2
pwFoo Posted October 21, 2014 Author Posted October 21, 2014 Updated git and module repo to promised reworked version 0.0.3! FCM 0.0.2 isn't compatible to 0.0.3. It's redesigned.
pwFoo Posted November 19, 2014 Author Posted November 19, 2014 After some changes and improvements to FormHelper I'll start to update FCM too. Most work to realize a page add / edit is done by FormHelper (create, modify, render, process form and also care about file / image upload). FCM brings FormHelper together with a create / save page functionality. Page save vs. field save Current version of FCM update all the fields and finally save the hole page. That's fine to save the all the changes done before. But I think about a rewrite to a field save instead of a page save, because a "fieldSave" process module could be used stand alone to handle frontend page edit and also ajax based updates (an optional submodule...)? Any hints or suggestions about pro and cons? Permission check Access control was removed in the second dev version, but should be added optional to FCM again. It won't have it's one permission handling, but will use PW $page->editable() and $page->addable(). Your ideas and suggestions are welcome to improve the module
pwFoo Posted February 8, 2015 Author Posted February 8, 2015 FCM has to be rewritten and isn't ready to use! Do NOT use FCM module yet!
pwFoo Posted February 19, 2015 Author Posted February 19, 2015 Module is deprecated! The current module code won't be supported or updated.
pwFoo Posted March 1, 2015 Author Posted March 1, 2015 At the moment I have no usage for FCM module, but after FormHelper 0.5.2 is finished I've done a quick FCM rewrite. Only few tests done yet! 3
pwFoo Posted April 7, 2015 Author Posted April 7, 2015 Updated to work with FormHelper 0.7.1 / FormHelperExtra after redesign. FCM is NOT ready to use!!! No value sanitizing without additional code (set a sanitizer to each field.
pwFoo Posted June 21, 2015 Author Posted June 21, 2015 FCM release 0.5.0 (no documentation at the moment... sorry!) requires FormHelper add / edit pages default sanitizer based on field type (textarea or text) if no sanitizer is set to the field skip fields optional use admin form styles file / image upload during page add (check input, page pre-save, set field values and add files and again save the page...) usage / example // load FCM $fcm = $modules->get('FrontendContentManager'); // ADD a page to given parent with parent template $output = $fcm->renderAdd($parentPage); // or EDIT given page $output = $fcm->renderEdit($pageToEdit); // echo jsConfig inside the html head element echo $fcm->JsConfig(); // outpunt needed scripts for inputfield modules, ... inside your html head element foreach ($config->styles as $file) { echo "<link type='text/css' href='$file' rel='stylesheet' />\n"; } foreach ($config->scripts as $file) { echo "<script type='text/javascript' src='$file'></script>\n"; } // echo $output inside your template / html body element echo $output; PW module repo: http://modules.processwire.com/modules/frontend-content-manager GIT repo: https://bitbucket.org/pwFoo/frontendcontentmanager/src/ 4
Erik Richter Posted November 27, 2015 Posted November 27, 2015 Just had a look at this module and tried to make it work. The only thing I see is a submit button. If i click it a new page will be created or (if i uncommented that for edit) the given page will be edited (or u get redirected to the page 1015 for example). But there are no fields at all to change anything. What did I do wrong? Installed formhelper and this is my template: <?php // load FCM $fcm = $modules->get('FrontendContentManager'); // ADD a page to given parent with parent template //$output = $fcm->renderAdd($pages->get('1015')); // or EDIT given page $output = $fcm->renderEdit($pages->get('1015')); // echo jsConfig inside the html head element echo $fcm->JsConfig(); // outpunt needed scripts for inputfield modules, ... inside your html head element foreach ($config->styles as $file) { echo "<link type='text/css' href='$file' rel='stylesheet' />\n"; } foreach ($config->scripts as $file) { echo "<script type='text/javascript' src='$file'></script>\n"; } // echo $output inside your template / html body element echo $output; ?> As you can see, I am trying to edit the page number 1015, which has a different template only with title and textarea field. And I was expecting to see those fields on the edit page, with the template written above. Appreciate your help!
pwFoo Posted November 28, 2015 Author Posted November 28, 2015 Could you post your complete template file, please? With this simple line I get a form with all fields of the template. $fcm->add($pages->get('title=my-page-title')); // OR //renderAdd is a shortcut for add() + process() + render() $fcm->renderAdd($pages->get('title=gfh')); Get page by ID should also work (it needs a page object). The other params are optional. Short edit / add tests with my dev setup show all the form fields. Form should be processed and rendered before you output the results.
siilak Posted March 10, 2016 Posted March 10, 2016 I made a template for add new page. Page is added under home page. <?php include('./_header.php'); ?> <?php // Load FormHelper module and also set wire('fh') variable $fcm = $modules->get('FrontendContentManager'); // add a new page based on a template and a parent object $parent = $pages->get('name=home'); $form = $fcm->add($parent, $parent->template); // jsConfig needed by ckeditor echo $fcm->JsConfig(); // outpunt needed scripts for inputfield modules, ... foreach ($config->styles as $file) { echo "<link type='text/css' href='$file' rel='stylesheet' />\n"; } foreach ($config->scripts as $file) { echo "<script type='text/javascript' src='$file'></script>\n"; } ?> <div class="uk-container uk-container-center"> <h1><?php echo $page->title; ?></h1> <?php // output the forom echo $form; ?> </div> <?php include('./_footer.php'); ?> and only result I get is this. Any help? https://www.dropbox.com/s/2mwtksa20qxs5bk/Screen%20Shot%202016-03-10%20at%2011.52.48.png?dl=0 1
Filkaboy Posted April 14, 2016 Posted April 14, 2016 From my side with the new version on PW 3.0.12 I see only the Submit button!!! ***EDIT*** I resolve this issue by adding the FormHelperExtra (testing!) Module
pwFoo Posted April 14, 2016 Author Posted April 14, 2016 Thanks for posting this. I don't use it. Dependency seems missing, but FormHelperExtra is needed here... create a form object with fields based on Template, Page, Form objects or field data array form file upload handling (temp page uploads, creation of a hidden storage page)
Filkaboy Posted April 14, 2016 Posted April 14, 2016 The only other problem for now are the textarea sanitizer. Its like the sanitize do not recognize the good type and put a text sanitize on a textarea and pass only 255 characters and not the 16384 for the textarea. *****EDIT****** I finally found the problem... the class type in the module are "FieldTypeTextarea" but with multi-language the class type are "FieldTypeTextareaLanguage". I will add the other Field type in the condition and all work fine.
Filkaboy Posted April 14, 2016 Posted April 14, 2016 I found solution for one problem and now a other problem... For the Textarea the CKEditor doesn't appear...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now