Client Log-In with custom projects page for each client and comment functionality


#1

A client of mine asks the following (and I am not sure if kirby might be the right tool for that):

He wants a website where

  • his clients can login
  • each of his clients have their own projects page
  • each project should be its own page …
  • … to this projects the client & website-owner should be able to add texts, images and videos (probably as documents / file upload)
  • to each of these documents the client and website-owner should be able to give comments (also with text, images or videos )

My first guess would be to use RAILS with AWS-S3
My client proposed a wordpress theme for that - I am absolutely not a WP fanboy, and actually I am not familiar with it (I love kirby for its simplicity!!!)

I’m happy about every suggestion … thanks


#2

From my perspective, all these requirements can be realised with Kirby

  1. his clients can login
    • yes, Kirby users can log in and can have fine-grained permissions both on the Panel and in the front-end
  2. each of his clients have their own projects page
    • yes, possible, access to other pages both in the Panel and and on the frontend can be locked with Kirby’s permission system
  3. each project should be its own page …
    • well, yes, Kirby is file/page based, basically, you would have a projects folder per client and the single projects as subpages of this folder
  4. … to this projects the client & website-owner should be able to add texts, images and videos (probably as documents / file upload)
    • Yes, this can be achieved via the Panel or via front-end upload forms
  5. to each of these documents the client and website-owner should be able to give comments (also with text, images or videos )

The Project Hub theme - while older and not using Kirby’s permission system - is actually a theme that meets exactly these requirements.


#3

I have actually built something similar to manage my clients. They can each login and only get to pages related to them. It’s a way for me to share stuff with them and provide copies of past invoices and stuff. It’s totally do able, and not all that hard. :slight_smile:


#4

Greate! Sounds promising.

Is it possible that the client only sees the Front-End (after login -> redirect to his projects-page) and to place upload-forms etc. to his project-page ???

will definitely look into “permissions” …


#5

Yes, that is possible, you can create users without Panel access. However, instead of recreating forms on the frontend, limiting Panel access to only a particular page and its subpages is probably easier.

What you can also do is have a login form on the frontend that redirects to the Panel user pages after the user is successfully logged in.


#6

Would it be possible for a client to send a post-request through the front end with some date which would be saved in a struct-field? And how?


#7

Check out this recipe: https://getkirby.com/docs/cookbook/creating-pages-from-frontend

At the end of the tutorial, you will find information how to update a structure field.


#8

thanks. will look into it


#9

ok got it working. But I want to return a parent()->parent() page, how would that be possible.

so I have a Project page which shows it’s Subpages (Steps) as a list. Each Step has Subpages (Tasks) and lists them out. Each Task has Messages saved in a StructureField.

so on the Project Page I have Steps containing task where each Tasks has a Form for submitting a comment. This forms have an action to the Task Controller as ‘Post’ Request.

Now the controller saves the submitted message in the StructureField as intended - but returns not to the Project-Page but to the Task-Page

=> I would like the Task Controller to Return the Project Page which is the Parent()->Parent() Page
(If that makes any sense :grinning:) [ Projects / Steps / Tasks ]


#10

I’m a bit surprised that this works if you don’t have a task template but only a controller. I think your form handling logic should either be in the controller of the page where the form is actually shown or in the snippet that renders the forms. After all, you need your messages to be shown directly in the page.

However, having multiple identical forms with the same submit value in the same page won’t work.


#11

ha, actually I have a task-template (because I also want to support to display single tasks)

the form actions “routes” to the task as shown below:

<form class="task-messages--msg-form" action="<?= $task->url() ?>" method="post">
  ....
</form>

Is there a way to render a different page from within the tasks-controller (eg the parent()->parant() page) ???
(maybe the redirect-page could also be submitted in the form ?)


#12

Yes, but in this case it doesn’t help you, because your form is in the project page, how do you handle alerts and success messages in this case?

If you are displaying single tasks, why don’t you put the form there and just put a link in the overview parent? Will make your life much easier.

Haven’t tested, but maybe it can be done with a route.


#13

I got it working:

so I provide in the form an input field with the current url:

<form class="task-messages--msg-form" action="<?= $task->url() ?>" method="post">
	..
	<input type="text" name="redirecturl" id="redirecturl" value="<?= $page->url() ?>"/>
	..
</form>

Than in the controller before the final return statement I added:

			// Redirects to page if redirecturl is set
			if( !empty(get('redirecturl')) ) {
				go( get('redirecturl') );
			}

I don’t know if this is a not recommended practice or anything like that, but I had no trouble so far…

The cookbook-example controller would look sth like this:


<?php

return function($site, $pages, $page) {
	$alert = null;
	if(r::is('post') && get('register')) {
		// ... do stuff ...
		// some of the data is invalid
		if($invalid = invalid($data, $rules, $messages)) {
			$alert = $invalid;
		} else {
			// everything is ok, let's try to create a new registration
			try {
				// ... do stuff ...
			} catch(Exception $e) {
				echo 'Your registration failed: ' . $e->getMessage();
			}
		}
	}

	// Redirects to page if redirecturl is set
	if( !empty(get('redirecturl')) ) {
		go( get('redirecturl') );
	}

	return compact('alert', 'data', 'success');
};


#14

How, in this setup, does the user know that the comment was successfully created? How does the user know if an error occurred? It looks as if this information is not returned to the user?


#15

Yes that’s true, but good enough for the time being.
The page get’s reloaded with the new content (new message). And it works from all pages [ Projects / Steps / Tasks ] with no extra cost.

If there is a better solution I would really like to know.