Jump to content

Creating a real estate application


KarlvonKarton
 Share

Recommended Posts

Hello everyone,

I want to make an application for storing Real Estate data.  Since I am fairly new (translate: Noob) to PW, I get stuck a lot of times just trying to understand what’s the best way to find a “solution” for a certain “problem”.  

So, if you people don’t mind, I will use this topic for asking questions occasionally / regularly.


I will start now with my first set of questions:

In the application there would be one superadmin (me) and a unknown amount of users (clients).  The users should be able to use the same template for adding estates (make sense to me, but maybe I’m wrong), but the users may not see the data (estates) of the other users.

1. Is there a built-in system in PW to do that?
2. Should I work with e.g. a branch per user? (user1 -> estatesTemplate, user2 -> estatesTemplate)

Link to comment
Share on other sites

@mr-fan: I see that Vladar had a (almost) similar question: "restricted access to some sensitive informations (like landlords contact details, clients info and so on)".

What I want to accomplish is that users log in to the application and only see their portfolio of estates.   The users are concurrence of each other and not agents that work on the same portfolio.

Link to comment
Share on other sites

You could this accomplish....the question is what route you wanna take like....

-> Did you plan to use PW Admin for the users as administration or would you create a frontend presenation of your "application" with frontendedit

-> you can have all estates under one parent and connect them to the user that created the single estate search for page field type - this is one of the centric concepts of PW you build your content and separate it in logical parts (pages, templates, url segments) and connect them with pagefields (single or multiple selects)

 

Link to comment
Share on other sites

@mr-fan

1. Yes, I want to use PW Admin for the users as administration of their portfolio.

2. I know about the Page Field Type (I already used it for tags and categories in another project), but I'm still a little bit in the dark here ;-)  Do you mean that when a user adds a new estate that the pagefield would store the user itself?

Link to comment
Share on other sites

1. If you use the admin the follwing topics are interesting:

This would provide a solution if every user has it's one branch of estates...would be more complex to setup than all estates under one parent.

Take a very deep look in ListerPro - you could use it as a admin page for your users so that the even won't see the pagetree and get a UI for managing their estates:

https://processwire.com/talk/store/category/9-listerpro/

You could give access to a admin page with a lister that provide searching and filtering, add new and edit interface depending on the user.

 

If this commercial module is no option you could setup a own admin page:

you could create a admin page with a template file for the logic without that you have to create a process module...

with ProcessDashboard you have another option for a own dashboard that you could provide for your users...

2. A Pagefield is just a simple connection - if you know database structures you could build 1:n, 1:1 and n:n connections with a Page Field the different select inputfields are depending on the usecase - but with the great PW API and selectors you could get any data on any place that is related via a Page Field

In your example for the connection of the user and the estate you even don't need a Page Field since you could access the createdUser so on the $pages->find for loading all estates of a user you could use this connection.....it's just usefull for cathegories, tags, options of your single estates!

 

  • Like 5
Link to comment
Share on other sites

Hello (again),
I was wondering if the following can be done (or has been done already):

I have some pages (with a template 'estate') that have a field 'estate_user_id'.
I also have a role 'clients' that only show the pages with template 'estate' in the user backend.

What I would like to create, that is a module that only show the pages where the 'estate_user_id' is equal to the ID of the user viewing the pages in the backend.

- Do I need a process module for that?  Or - if not - what other kind of module?
- What Hook do I need that only hooks when the page tree is viewed in the user backend?
- How do I refine/filter on the field 'estate_user_id' ?

Link to comment
Share on other sites

Some questions...

1. you mean the pagetree (user viewing pages in the backend)

2. estate_user_id is a pagefield?

3. you really wanna go with the pagetree for your clients to manage their estates...? (I wrote some posts above about ListerPro and own Admin Dashboards....)

It would be much more simpler to setup a own admin page and show the needed pages depending on the $user that is logged in....than bending the pagetree...

regards mr-fan

Link to comment
Share on other sites

@mr-fan

1.  yes, 2. no just an integer field, 3. I have installed an admin dashboard for the users with role 'clients'. (listerpro is not an option now)

To be honest, I've been reading and reading, but only found people that were discouraged to alter the pagetree like this...  So in the meanwhile I think I will have to stick with the idea of making my own admin pages, as you say too.

Showing data on that custom user admin is one thing, but adding new estates or editing estates will be a bit harder, I guess?
What route do you have to take to make a page for adding an estate (e.g.)?  Do you have to make the form myself or is there a nifty way of using an existing add form/page (like the one I made in the superuser admin)?

ps: I've read all the posts you referred to ;-) but I'm still trying to grasp the concepts of PW...  (sorry for that)

Link to comment
Share on other sites

@Robin S no this module only works if estates are as childpages under every client! If you have all estates under one parent and separate with a pagefield this would not work...

Quote

I'm still trying to grasp the concepts of PW...  (sorry for that)

So if you grasp the concept it is a very ambitiously to get a real "client" based application running...;)

I will provide you again some links and advice - but i've to say that is is very important not only grasp the concept if you wanna build a working solution...there are many estate applications out there since this is a $$ business ;)

I provide very often on more complex sites a simple stripped down admin page for special users...with AdminCustomPages module.

With Processwire there is no module that does the heavy lifting for you, but PW IS the tool that makes heavy stuff beeing fun.....this is the basic concept of PW.
No "ready to use" solution but a "ready to build" Workbench! ;)

If you have deeper problems on this topic you can PM me or you can use this board, too:

https://processwire.com/talk/forum/22-jobs/

 

best regards mr-fan

 

  • Like 1
Link to comment
Share on other sites

You are right basically there is no problem with that concept...it is only depending on dataset and future features or changes on the project.

I'm personally always wanna have a clear structure so same things belongs to same things - this is what pagefields are for.

And the pagetree is nice - but on a client applicatipon not always the best and flexible CRUD system for custom things and access.

For normal website clients a pagetree is very easy to grasp and administrate - but special content/systems need a own UI - just my opinion.

And at least this is very easy possible with PW, even if you don't invest the little money on ListerPro you have many options to use the PW UI for your dashboards and needed stuff.

Like i always wrote with PW there is no single way to go, it depends on the knowhow, the usecase, dataset and personal opinion how you solve a problem.

But first you have to know all the options....;)

Link to comment
Share on other sites

@mr-fan

Very interesting links, indeed.  Thank you for that.  Sometimes someone showing the path is enough ;-)

Remark about the $$: In my professional life I work a lot for that business, but up until now only frontend development.  Things like synchronizing and replicating data from a database source (connecting with e.g. soap) and stroring it into a web database.
But there is a little niche I know of where the software is provided by only one company (well, in my country) and most people that use it are complaining about... 

@Robin S

Like Mr-Fan said: every client needs to have his own branch and the branch is only hidden on a role basis and not on a user basis. (if I'm correct).

Link to comment
Share on other sites

no like in my example "Reply to Dashboard (Redux)" you could add "action" buttons to your table of estates like:

$table->action(array(
	'New Event' => $config->urls->admin . 'page/add/?parent_id=XXXX',
	'All Events' => $config->urls->admin . 'page/events/',
));

even further you could use a PW feature that use a modal to edit:

//call the script for the modal
$this->modules->get('JqueryMagnific');

//try to add simple modal=1 and a lightbox class to the a tag with this jquery script
$(document).ajaxComplete(function() {
    //add trigger class and modal setup
    $('.yourFancyUILinkToAPage a').each(function(){
        $(this).addClass("lb-edit").attr("href",$(this).attr('href')+"&modal=1");
    });
    //setup lightbox
    $('.lb-edit').magnificPopup({
        type: 'iframe',
        disableOn: 0
    });
});

I used this function on a own build Pagetree but this could be adapted on every "edit" link you wanna use a modal.

So your client get the normal PW PageEdit Form and there is no need for a own form.

But own forms created with the API are possbile, too.

Link to comment
Share on other sites

I thought it might be interesting to share this progress of mine...
The following module redirects users that want to edit pages that are not theirs (but only for the role 'clients').
 

<?php

class RedirectClient extends WireData implements Module {
	
	public static function getModuleInfo() {
		return array(
			'title' => 'Redirect Client To Admin Home',
			'summary' => 'Ensure that client role only edits own pages',
			'author' => 'Karton',
			'version' => 001,
			'singular' => true, 
			'autoload' => true,
		);
	}
	
	
	public function init(){
		
		if ($this->user->hasRole('clients')) {
			
			$this->addHookAfter('ProcessPageEdit::execute', $this, 'checkIfEditPageIsFromThisUser');
		}	
	}
	
	
	public function checkIfEditPageIsFromThisUser($event) {
		
		$p = $this->modules->ProcessPageEdit->getPage();
		
		if ($p->created_users_id != $this->user->id) {
				
			$this->session->redirect($this->pages->get($this->config->urls->admin)->url);
		}
	}

}

Any suggestions/remarks of the experts here?

Link to comment
Share on other sites

You should be able to get the page from this:

$page = $event->object->getPage();

But the other thing to consider is that I think what you are trying to do is already support by a core permission. Try installing that "page-edit-created" permission.

Screen Shot 2016-09-11 at 10.02.04 AM.png

 

It may not be as flexible, but worth point out in case you didn't know about it.

The other thing is that you don't need a full module for small snippets like this - you can place the code in /site/init.php instead.

  • Like 2
Link to comment
Share on other sites

 Share

×
×
  • Create New...