Jump to content
pwFoo

FrontendContentManager

Recommended Posts

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 by pwFoo
  • Like 5

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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)?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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...

Share this post


Link to post
Share on other sites

It's also possible to edit any page...

echo $fcm->edit($pages->get("/"));

Next update url segment check will be removed.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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();
    }
  • Like 2

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 ;)

Share this post


Link to post
Share on other sites

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!

  • Like 3

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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/

  • Like 4

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

  • Like 1

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

I found solution for one problem and now a other problem... :)

For the Textarea the CKEditor doesn't appear...

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By eelkenet
      Hi! I've created a small Inputfield module called InputfieldFloatRange which allows you to use an HTML5 <input type="range" ../> slider as an InputField. I needed something like this for a project where the client needs to be able to tweak this value more based on 'a feeling' than just entering a boring old number. Maybe more people can use this so I'm hereby releasing it into the wild. 
      EDIT: You can now install it directly from the Modules directory: http://modules.processwire.com/modules/inputfield-float-range/
       
      What is it?
      The missing range slider Inputfield for Processwire. 
      What does it do?
      This module extends InputfieldFloat and allows you to use HTML5 range sliders for number fields in your templates.
      It includes a visible and editable value field, to override/tweak the value if required.  
      Features
      Min/max values Precision (number of decimals) Optional step value (Read more) Optional manual override of the selected value (will still adhere to the rules above) Configurable rounding of manually entered values (floor, round, ceil, disable) Usage
      Clone / zip repo Install FieldtypeFloatRange, this automatically installs the Inputfield Create new field of type `Float (range)` or convert an existing `Float`, `Integer` or `Text` field. To render the field's value simply echo `$page->field` Demo
      A field with Min=0, Max=1, Step=0.2, Precision=2

      Field with settings Min=0, Max=200, Step=0.25, Precision=2

       
      Todo
      Make the display-field's size configurable (will use the Input Size field setting)  Hopefully become redundant  
      Changelog
      004 (current version)
      - Make rounding of manually entered values configurable (floor, round, ceil or disable)
      - Fix small JS bug when the value-display field was not displayed
      - Update README
      003
      - Code cleanup, add some ModuleInfo data & LICENSE
      - Submit to PW Modules directory (http://modules.processwire.com/modules/inputfield-float-range/)
      002
      - Fix issue where setting the step value to an empty value created problem with validation
      - Make the display-field optional
      001
      - Initial release
       
      Thanks!
       
       
    • By Gadgetto
      Status update links (inside this thread) for SnipWire development will be always posted here:
      2019-10-18
      2019-08-08
      2019-06-15
      2019-06-02
      2019-05-25
      If you are interested, you can test the current state of development:
      https://github.com/gadgetto/SnipWire
      Please note that the software is not yet intended for use in a production system (alpha version).
      If you like, you can also submit feature requests and suggestions for improvement. I also accept pull requests.
      ---- INITIAL POST FROM 2019-05-25 ----
      I wanted to let you know that I am currently working on a new ProcessWire module that fully integrates the Snipcart Shopping Cart System into ProcessWire. (this is a customer project, so I had to postpone the development of my other module GroupMailer).
      The new module SnipWire offers full integration of the Snipcart Shopping Cart System into ProcessWire.
      Here are some highlights:
      simple setup with (optional) pre-installed templates, product fields, sample products (quasi a complete shop system to get started immediately) store dashboard with all data from the snipcart system (no change to the snipcart dashboard itself required) Integrated REST API for controlling and querying snipcart data webhooks to trigger events from Snipcart (new order, new customer, etc.) multi currency support self-defined/configurable tax rates etc. Development is already well advanced and I plan to release the module in the next 2-3 months.
      I'm not sure yet if this will be a "Pro" module or if it will be made available for free.
      I would be grateful for suggestions and hints!
      (please have a look at the screenshots to get an idea what I'm talking about)
       




    • By Robin S
      Another little admin helper module...
      Template Field Widths
      Adds a "Field widths" field to Edit Template that allows you to quickly set the widths of inputfields in the template.

      Why?
      When setting up a new template or trying out different field layouts I find it a bit slow and tedious to have to open each field individually in a modal just to set the width. This module speeds up the process.
      Installation
      Install the Template Field Widths module.
      Config options
      You can set the default presentation of the "Field widths" field to collapsed or open. Field widths entered into the Template Field Widths inputfield are only applied if the Edit Template form is submitted with the Template Field Widths inputfield in an opened state. "Collapsed" is the recommended setting if you think you might also use core inputs for setting field widths in a template context. You can choose Name or Label as the primary identifier shown for the field. The unchosen alternative will become the title attribute shown on hover. You can choose to show the original field width next to the template context field width.  
      https://github.com/Toutouwai/TemplateFieldWidths
      https://modules.processwire.com/modules/template-field-widths/
    • By adrian
      Tracy Debugger for ProcessWire
      The ultimate “swiss army knife” debugging and development tool for the ProcessWire CMF/CMS

       
      Integrates and extends Nette's Tracy debugging tool and adds 35+ custom tools designed for effective ProcessWire debugging and lightning fast development
      The most comprehensive set of instructions and examples is available at: https://adrianbj.github.io/TracyDebugger
      Modules Directory: http://modules.processwire.com/modules/tracy-debugger/
      Github: https://github.com/adrianbj/TracyDebugger
      A big thanks to @tpr for introducing me to Tracy and for the idea for this module and for significant feedback, testing, and feature suggestions.
×
×
  • Create New...