Jump to content
LukeCage

Admin Custom Page and Registration

Recommended Posts

Hi! I have a big problem with a client of mine. I have to do something that i don't do very often with processwire, and i'm very afraid that i'm not gonna able to do it. So i write to search some help from you experts.

The website that i'm gonna create will have a database with infos about users. This users are not the actual registrered users, but possible users. I'll try my best to explain this. What i will have is a datasheet in the database with infos about all the users (name, surname, fiscal Code) that can register to the website. So during registration the website is confront with this database of people, and accept or not your registration to the website.

Now. The problems are: the client need a page in the CMS to insert this people in the first place (Custom Admin Page?) in the database. I read what i need to create it, but i don't understand what i need to do next. What i need to do for reading and writing to the database, with data, directly from a custom admin page in processwire?

The other thing is. I can do this control during registration? I Can extend fields in the user account?

I'm completely in your hands.

Share this post


Link to post
Share on other sites
2 hours ago, LukeCage said:

The problems are: the client need a page in the CMS to insert this people in the first place

  1. Is the client going to type in the data one by one or are you importing from a file, .e.g a CSV or JSON file?
  2. How many people potentially in the datasheet?
  3. Will this be done once or will the people be regularly updated?
  4. Can the people be saved as pages (hidden in admin) or you'd rather have them in a table external to ProcessWire?

Manage People Datasheet

You might need to create a simple Process Module, maybe even a one pager that lists the 'people'. You can include some simple actions like delete or edit people. To add people, a click on some button could open a modal window for you to add a person (depends on whether you are importing a file of people or typing manually).

There's also the module RockGrid that you can use for listing the 'people'. I don't know if it can do data imports though. I think it works with ProcessWire pages only, but am not sure.

User registration

Since creating users is a manual process, you have a lot of control here. How you check if a user is on the allowed people list depends on the approach you take above, i.e. whether people are pages or are in a custom database. If they are pages, you can use $pages API, e.g. $newUser = $pages->get("template=people, first_name=$firstName,last_name=$lastName"); Then check if that returned something. If yes, register this user. If you are using a custom table, you'd need to use SQL to fetch, insert, update, etc, people. ProcessWire has a $database API that you can use

Your other option is a custom Fieldtype but that is a bit more technical, going by how you've described your current skill set. 

2 hours ago, LukeCage said:

i'm very afraid that i'm not gonna able to do it. So i write to search some help from you experts.

Depending on your timescales, you might be able to get some help in the forums. If this is needed fairly soon, you might want to consider hiring an experienced ProcessWire developer to carry out the work for you.

  • Like 2

Share this post


Link to post
Share on other sites
6 hours ago, kongondo said:
  1. Is the client going to type in the data one by one or are you importing from a file, .e.g a CSV or JSON file?
  2. How many people potentially in the datasheet?
  3. Will this be done once or will the people be regularly updated?
  4. Can the people be saved as pages (hidden in admin) or you'd rather have them in a table external to ProcessWire?

Manage People Datasheet

You might need to create a simple Process Module, maybe even a one pager that lists the 'people'. You can include some simple actions like delete or edit people. To add people, a click on some button could open a modal window for you to add a person (depends on whether you are importing a file of people or typing manually).

There's also the module RockGrid that you can use for listing the 'people'. I don't know if it can do data imports though. I think it works with ProcessWire pages only, but am not sure.

User registration

Since creating users is a manual process, you have a lot of control here. How you check if a user is on the allowed people list depends on the approach you take above, i.e. whether people are pages or are in a custom database. If they are pages, you can use $pages API, e.g. $newUser = $pages->get("template=people, first_name=$firstName,last_name=$lastName"); Then check if that returned something. If yes, register this user. If you are using a custom table, you'd need to use SQL to fetch, insert, update, etc, people. ProcessWire has a $database API that you can use

Your other option is a custom Fieldtype but that is a bit more technical, going by how you've described your current skill set. 

Depending on your timescales, you might be able to get some help in the forums. If this is needed fairly soon, you might want to consider hiring an experienced ProcessWire developer to carry out the work for you.

1- the idea was that the client update this list. The option that imports from a csv is an option but can be very handy. What I know is that the interest is to export in a csv registered user and other lists. So I a do people as pages, I can export an hidden category with lots of pages in a csv? 

2- The people's list are very very large. Actually there's a database in the old website that I need to import in the first place. 

3- will be regularly updated once or twice a year, maybe more. 

4- No the people can be pages. The peoples are gonna store in the same database, so the important thing is to have a tab in the admin, so can be easy to the client to see only the people, and not all the pages etc.. I want to create a tab because I think that the page tree, with all the names, are gonna be very large, and not very easy to read.

Edited by LukeCage
  • Like 1

Share this post


Link to post
Share on other sites

I would go with a custom module to give ability to your administrators to insert/remove/update the potentials users which ares stored in the pages tree.  If the people pages list is very large, it is not a problem, you will end up with a paginated pages tree, and you will have the ability to find easily those users (pages) from the search case or even the Pages  > Find menu. You can also write a small Process module to manage those pages with a datatable, rockgrid or whatever you would like to use.

-

Reading @kongondo's answer after writing I see that he already explained the idea.

 

4 hours ago, LukeCage said:

I can export an hidden category with lots of pages in a csv?

Check this thread.

4 hours ago, LukeCage said:

The people's list are very very large. Actually there's a database in the old website that I need to import in the first place. 

Simply build a template for "people" and import them as a pages. 

4 hours ago, LukeCage said:

No the people can be pages.

This make things a lot easier. Just build your Process module to manage those pages. You can have a working prototype at the end of the day with all the information found on this forum.

  • Like 3

Share this post


Link to post
Share on other sites

Yeah, what @flydev said. Pages is the easier route in your case. We are not saying it cannot be done by using your custom database and querying it directly. That's possible, but in your case, a lot more technical work.

Your client does not have to see the tree of people pages. You can have those hidden under a single parent whose parent is /admin/ rather than home (/). This way, only superusers can see the people tree. With a Process Module, you don't have to be visiting the page tree even as a superuser. You only need to know that they are there and the evidence is that you can see them in your Process Module :-).

The 'each person is a page' approach means that ProcessWire does all the heavy lifting, dealing with databases operations. Heck, your Process Module will allow you to filter users or sort them according to some column. Your database columns, depending on the data, can either be stored as single ProcessWire fields - name=text;surname=text,other_data=integer, etc OR as one blob of JSON text in a single text field, which can be retrieved and turned into an array. We need to see the column names and how many you got, to give a definite answer.

How has your client been updating the database in the old website? 

You still haven't told us how soon you need this 🙂

 

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, kongondo said:

Yeah, what @flydev said. Pages is the easier route in your case. We are not saying it cannot be done by using your custom database and querying it directly. That's possible, but in your case, a lot more technical work.

Your client does not have to see the tree of people pages. You can have those hidden under a single parent whose parent is /admin/ rather than home (/). This way, only superusers can see the people tree. With a Process Module, you don't have to be visiting the page tree even as a superuser. You only need to know that they are there and the evidence is that you can see them in your Process Module :-).

The 'each person is a page' approach means that ProcessWire does all the heavy lifting, dealing with databases operations. Heck, your Process Module will allow you to filter users or sort them according to some column. Your database columns, depending on the data, can either be stored as single ProcessWire fields - name=text;surname=text,other_data=integer, etc OR as one blob of JSON text in a single text field, which can be retrieved and turned into an array. We need to see the column names and how many you got, to give a definite answer.

How has your client been updating the database in the old website?

You still haven't told us how soon you need this 🙂

 

They write to csv, then they send this to the developer. But after i said them they were absolutely doing this directly from the website, they were absolutely enthusiastic.

My question is: I have read how to do a module in the Admin (it is very easy to create it), but how i can display the pages only in that new tab? Like an html table or something similar? And maybe in all of those, insert the modify button (that redirect to the normal page edit). Technically i never do this, and i don't know where to start.

Share this post


Link to post
Share on other sites
1 hour ago, LukeCage said:

My question is: I have read how to do a module in the Admin (it is very easy to create it), but how i can display the pages only in that new tab? Like an html table or something similar? And maybe in all of those, insert the modify button (that redirect to the normal page edit). Technically i never do this, and i don't know where to start.

Luke, the reason am asking particular questions is so that we can offer a tailored response. Without more information, it is difficult to offer a specific answer. For instance, I asked, how many columns in the database? But it seems to me you now want to go with pages, as per our suggestion, right?

Assuming you are going with pages. 

Display

Your process module, in its execute function (I am assuming you've read about this?) will render your HTML table. You can either render a ProcessWire table, or your own custom HTML table, or use Process Lister or RockGrid. All of this can be paginated so that only a limited number of people are loaded at a time. See Process Blog module for displaying pages in a HTML table.

In the HTML table, do you want to display all data columns (e.g. name, surname, fiscal thingy, etc) OR do you want to display only full name (i.e. Steve Job?)

Modal

  • Then when client clicks on Steve Job, it opens a modal to the Steve Job page.
  • The Steve Job page has several fields for name, surname, fiscal thing, etc.
  • The client edits the fields he wants and closes the modal
  • The page reloads (or if using ajax, only the data reloads)
  • See Blog module (Process blog for opening pages in modal for editing)

Note: Since the pages are in admin, we will have to by-pass user access check in order for client to edit the page

Uploading new 'people'

  • We have a button or file field for uploading new people data as CSV (see my FieldtypeMatrix module for example)
  • When the csv file is uploaded, a script loops through it and creates people pages on the fly, mapping csv columns data to the ProcessWire page's fields. Before creating a page we check if there is already a people page with similar data {same email, same name, same surname, etc}
  • You then decide what you need to do; update if duplicate found or skip creation of that people page?
  • People page reloads (or ajax refresh)

These are ideas, but very doable. But we need specific answers to our questions. You never know; someone might just create a draft module for you 🙂

Edited by kongondo
  • Like 2

Share this post


Link to post
Share on other sites
31 minutes ago, kongondo said:

Luke, the reason am asking particular questions is so that we can offer a tailored response. Without more information, it is difficult to offer a specific answer. For instance, I asked, how many columns in the database? But it seems to me you now want to go with pages, as per our suggestion, right?

Assuming you are going with pages.

Display

Your process module, in its execute function (I am assuming you've read about this?) will render your HTML table. You can either render a ProcessWire table, or your own custom HTML table, or use Process Lister or RockGrid. All of this can be paginated so that only a limited number of people are loaded at a time. See Process Blog module for displaying pages in a HTML table.

In the HTML table, do you want to display all data columns (e.g. name, surname, fiscal thingy, etc) OR do you want to display only full name (i.e. Steve Job?)

Modal

  • Then when client clicks on Steve Job, it opens a modal to the Steve Job page.
  • The Steve Job page has several fields for name, surname, fiscal thing, etc.
  • The client edits the fields he wants and closes the modal
  • The page reloads (or if using ajax, only the data reloads)
  • See Blog module (Process blog for opening pages in modal for editing)

Note: Since the pages are in admin, we will have to by-pass user access check in order for client to edit the page

Uploading new 'people'

  • We have a button or file field for uploading new people data as CSV (see my FieldtypeMatrix module for example)
  • When the csv file is uploaded, a script loops through it and creates people pages on the fly, mapping csv columns data to the ProcessWire page's fields. Before creating a page we check if there is already a people page with similar data {same email, same name, same surname, etc}
  • You then decide what you need to do; update if duplicate found or skip creation of that people page?
  • People page reloads (or ajax refresh)

These are ideas, but very doable. But we need specific answers to our questions. You never know; someone might just create a draft module for you 🙂

That's exactly what i want to do. The info are gonna be more than six or seven "fields" per person.

What i haven't done before is importing with csv and transform to pages, i have to dig more into this.

How can i display a ProcessWire table in excecute() ? I can not understand how to do that...

Share this post


Link to post
Share on other sites

Here's something to chew on.

Start with this tutorial: https://processwire.com/blog/posts/building-custom-admin-pages-with-process-modules/

Some code to play with. This creates a paginated ProcessWire-rendered HTML table.

  • Create a module as per above tutorial.
  • Use the following code in your Process module's execute() method.
  • You need to create some people pages. In this example, they use the template 'people'.
  • Edit functionality not included. Have a look at Blog module for that, here.
  • For CSV upload (not included), have a look at Matrix module here for uploading CSV file and here for reading CSV file.

 

/**
 *	Display, Add and Edit People.
 *
 *	Called when the URL is peoples's page URL + "/people/" i.e. URL Segment.
 *	Renders a table with People information. People can be edited via modal.
 *
 *	@access protected
 *	@return mixed $form rendered form
 *
 */
public function ___execute() {

    $modules = $this->wire('modules');
    $input = $this->wire('input')->post;
    $pages = $this->wire('pages');

    // CREATE A NEW FORM
    $form = $modules->get('InputfieldForm');
    $form->attr('id', 'people');
    $form->action = './';
    $form->method = 'post';

    // CREATE AN INPUTFIELD MARKUP: Will hold list of people table
    $m = $modules->get('InputfieldMarkup');
    $m->textFormat = Inputfield::textFormatNone;// make sure ProcessWire renders custom HTML
    // $m->label = $this->_('Edit');
    // $m->description = $this->_('Click on a title to edit the item.');

    // CREATE A NEW TABLE: for people
    $t = $modules->get('MarkupAdminDataTable');
    $t->setEncodeEntities(false);
    $t->setClass('peopleTable');

    // set header rows
    $peopleTableHeaders = array(
        '<input type="checkbox" class="toggle_all">',
        $this->_('Title'),
        $this->_('Name'),
        $this->_('Surname'),
        $this->_('Another Column'),
        $this->_('One More Column'),
        $this->_('Published'),
        #$this->_('Date'),
    );


    $t->headerRow($peopleTableHeaders);

    // grab a limited number of people to show in people dashboard. Limit is hardcoded in this example
    $people = $pages->find("template=people, include=all, sort=-created, parent!=7, limit=10");

    foreach ($people as $p) {
        if (!count($people)) break;// if no people found, break early
        // check if person page  is published or not
        $p->is(Page::statusUnpublished) ? $status = '<span class="unpublished">' . $this->_('No') . '</span>' : $status = $this->_('Yes');
        // set table rows
        $peopleTable = array(
            "<input type='checkbox' name='posts_action[]' value='{$p->id}' class='toggle'>",// disabled sorting on this in .js file
            "<a href='{$this->wire('config')->urls->admin}page/edit/?id={$p->id}&modal=1' class='editPeople pw-modal pw-modal-medium'>$p->title</a>",
            $p->title,
            $p->person_name,
            $p->person_surname,
            $p->another_column,
            $p->one_more_column,
            $status
        );

        // render the table rows with variables set above
        $t->row($peopleTable);

    }// end foreach $people as $p

    // display a headline indicating quantities. We'll add this to people dashboard
    $start = $people->getStart()+1;
    $end = $start + count($people)-1;
    $total = $people->getTotal();

    if($total) $peopleCount = "<h4>" . sprintf(__('People %1$d to %2$d of %3$d'), $start, $end, $total) . "</h4>";

    // add a description to people dashboard {postsCount, limitSelect and instruction OR no people found status}
    $m->description = $total == 0 ? $this->_('No items found.') : $peopleCount . $this->_('Click on a title to edit the item.');
    $m->notes = "People table notes";

    $currentUrl = $this->wire('page')->url . $this->wire('input')->urlSegmentsStr."/";// get the url segment string. In this case it is "people"
    $pagination = $people->renderPager(array('baseUrl' => $currentUrl));

    $m->attr('value', $pagination . $t->render() . $pagination);// wrap our table with pagination

    $form->add($m);

    $post = $this->wire('input')->post;

    // render the final form
    return $form->render();

}

 

Edited by kongondo
  • Like 6

Share this post


Link to post
Share on other sites
8 hours ago, LukeCage said:

The people's list are very very large

What is "very very large" ?

 

4 hours ago, flydev said:

You can also write a small Process module to manage those pages with a datatable, rockgrid or whatever you would like to use.

3 hours ago, LukeCage said:

My question is: I have read how to do a module in the Admin (it is very easy to create it), but how i can display the pages only in that new tab? Like an html table or something similar? And maybe in all of those, insert the modify button (that redirect to the normal page edit). Technically i never do this, and i don't know where to start.

1 hour ago, LukeCage said:

How can i display a ProcessWire table in excecute() ? I can not understand how to do that...

RockGrid, RockGrid, RockGrid! It's a perfect szenario for it and it was mentioned several times already by @kongondo and @flydev - it seems you didn't have a look yet?

 

8 hours ago, LukeCage said:

The option that imports from a csv is an option but can be very handy. What I know is that the interest is to export in a csv registered user and other lists. So I a do people as pages, I can export an hidden category with lots of pages in a csv? 

There are several modules to help you with CSV import: https://www.google.com/search?q=site:processwire.com+import+csv

 

  • Like 2

Share this post


Link to post
Share on other sites

Forgot one:

8 hours ago, LukeCage said:

What I know is that the interest is to export in a csv registered user and other lists. So I a do people as pages, I can export an hidden category with lots of pages in a csv?

One click with RockGrid, already built in - and they can even filter the grid before exporting 😉

  • Like 1

Share this post


Link to post
Share on other sites
6 minutes ago, bernhard said:

One click with RockGrid, already built in - and they can even filter the grid before exporting 

Awesome! I really need to get some time to test it!

This topic should be marked as [almost solved], eh? ;-). Read @bernhard tutorial on Process Modules and use his RockGrid module 🙂

  • Like 3

Share this post


Link to post
Share on other sites
7 minutes ago, bernhard said:

Forgot one:

One click with RockGrid, already built in - and they can even filter the grid before exporting 😉

Just now, kongondo said:

Awesome! I really need to get some time to test it!

This topic should be marked as [almost solved], eh? ;-). Read @bernhard tutorial on Process Modules and use his RockGrid module 🙂

I will try this first. If is not gonna work form i will go for @kongondo solution.

Next few days i will start programming, and I will let you know how it went!

Share this post


Link to post
Share on other sites
2 minutes ago, kongondo said:

Awesome! I really need to get some time to test it!

You should really do that as soon as possible 😉 I'm using it on all my projects and it's an absolutely awesome listing tool. Much better than the core listing in most of the cases IMHO (not praising my own work here, most of the awesomeness comes from agGrid).

I decided to make it free (MIT) so that others can use it in their modules (batch child editor, the new padloper, etc. - really a lot of possibilities here). I really think that it opens up a new world for processwire regarding how users can manage their content (GUI). 

4 minutes ago, LukeCage said:

Next few days i will start programming, and I will let you know how it went!

Great, good luck and have fun 😉

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, bernhard said:
11 hours ago, LukeCage said:

The people's list are very very large

What is "very very large" ?

?

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 BitPoet
      Inspired by this thread with a little nugget based on AOS by @benbyf to visually distinguish development systems from production ones, I wrote a small module that does the same and lets you adapt colors and text.
      Link to the github repo:
      AdminDevModeColors
      Version 0.0.1 is still very alpha and only tested on PW 3.0.124.
      Description
      This module lets you change the color for the top toolbar and add a small piece of text for development systems, so you are immediately you aren't working on production (and vice versa). The adaptions are made through pure CSS and applied if either the "Enable DEV mode" checkbox in the module's configuration is checked or the property $config->devMode is set to true in site/config.php.
      Works with Default, Reno and Uikit admin themes (though probably needs a lot of testing with different versions still).
      Since a screenshot says more than thousand words...
      Production system (unchanged):

      Dev system (Default admin theme):

      Dev system (Reno admin theme):

      Dev system (Uikit admin theme):

      Feel free to leave any feedback here and report any problems either in this thread or the github issue tracker.
       
    • By SwimToWin
      The basic Processwire workflow assumes that I (as an Editor) want to save new Pages in draft mode - and therefore new pages are always set to unpublished by default. To publish the page, it is necessary to actively press "Publish", otherwise the Page will not be visible.
      The workflow is:
      Add new Page Status is now "Unpublished: Not visible on site." Press Publish - the page is now visible on site I want to publish pages right away (without having to press Publish).
      Where is that configured?
      ProcessWire 3.0.123
      Uikit v3 admin theme (0.3.0)
    • By SwimToWin
      I have a website that allows users to create their personal "website" (a page with sub-pages).
      Users shall be able to:
      Log in (frontend and/or admin), Edit "their" page(s) - I am using the "Page Edit Per User"-module (https://modules.processwire.com/modules/page-edit-per-user/) to grant access to the relevant pages Create child pages - possible? Users shall not be able to see other pages in the admin interface - "Admin Restrict Page Tree" may do the trick (https://modules.processwire.com/modules/admin-restrict-page-tree/)? Frontend editing shall be possible - I am considering "Fredi" (https://modules.processwire.com/modules/fredi/) for this. The challenge is that it takes a lot of modules and configuration.
      Is there a way to set this up that doesn't require a lot of configuration for each new user?
    • By Noel Boss
      Admin Theme Boss
      A light and clear theme based on Uikit 3
      Features
      Four unique color options Beautifully redesigned login screens Modern typografy using Roboto Condensed Extended breadcrumb with edit links Extends AdminThemeUikit, so you can continue using all current and future AdminThemeUikit features Option to activate theme for all users   Updated and Releases
      There is a shiny new release page where you can subscribe to updates for new releases of AdminThemeBoss.   Color Variants:
      ProcessWire Blue


       
      Dark Black


       
      Vibrant Blue

       
      Happy Pink

      Requirements
      Requires a current ProcessWire version with AdminThemeUikit installed and activated.
      Installation
      Make sure AdminThemeUikit is activated Go to “Modules > Site > Add New“ Paste the Module Class Name “AdminThemeBoss“ into the field “Add Module From Directory“ Click “Download And Install“ On the overview, click “Download And Install“ again… On the following screen, click “Install Now“

      Manual Installation
      Make sure the above requirements are met Download the theme files from GitHub or the ProcessWire Modules Repository. Copy all of the files for this module into /site/modules/AdminThemeBoss/ Go to “Modules > Refresh” in your admin Click “Install“ on the “AdminThemeBoss“ Module
    • By benbyf
      I always seem to get this warning on every new install of PW on my Ubuntu 14 box with Digital Ocean. The servers are usually based in the UK and I was wondering if I should be adding something other than the below in the config? Is there a UK based locale code? Quick Google didnt come up with much.
      Warning: your server locale is undefined and may cause issues. Please add this to /site/config.php file (adjust “en_US.UTF-8” as needed): setlocale(LC_ALL,'en_US.UTF-8');
      Added to the config file:
      setlocale(LC_ALL,'en_US.UTF-8');  
×
×
  • Create New...