Jump to content

Pages with detail records?


pokmot
 Share

Recommended Posts

Hi,

I have just come across ProcessWire, and it looks very interesting for a directory application I am just starting to write. My plan was to make it in DooPHP with Smarty, but I will be investigating whether ProcessWire is a better solution.

Here's how the application will work. Taking your skyscraper example, for instance a page like http://processwire.com/skyscrapers/cities/atlanta/suntrust-plaza/

Let's assume that on that particular page I ALSO need to display a list of all the offices on all the floors. I have roughly 30,000 records that are "offices" in this case, from a list of approximately 3,000 "skyscrapers".

What is the best way to manage the "offices", particularly as there are changes from time to time?

Would you recommend it's managed within ProcessWire, and if so, how?

Or alternatively, should my template retrieve the "offices" directly from the "office" table on the mysql server?

For this particular application the "offices" change on a regular basis and are updated by a master application. The purpose of the PW application is to provide a view of the data rather than managing it.

The master application will also add and remove "skyscrapers" on a regular basis, so I will be writing a synchronization script to keep the database up to date.

One complication here is that we need to be able to produce pages that list all "offices" of a particular type and which then links to the corresponding "skyscraper".

Final question - is PW able to use URL's with wildcards, so for instance if the URL is /cities/*mycityname* a particular template is executed and the parameter *mycityname* is passed through to the template? That would be a most useful feature as it could be quite suitable for my type of application.

Thanks for any feedback!

Regards,

Steve

Link to comment
Share on other sites

Hi and welcome Steve!

I'm busy but will give short answer:

Offices would be pages too that's separate in a branch so you can edit them within PW admin, or alternatively you could using search in admin or create a bootstrap php somwhere outside and build a data table for easy finding and editing and use the excellent PW API, you're not bound to use PW admin.

In your "skyscraper" template you would have a page reference field to select one or multiple offices. You could also create them all using simple script through API.

Finally you can build all sort of lists and searches whether from offices view or skyscapers using the powerful selectors. You can easily relate them using the page reference field. The setup can vary to your needs.

So you can also use PW only for presentation and connect it easily with your master application. See bootstraping. This enables you to build an easy maintain script synching or whatever using the excellent PW API.

Finally PW supports urls segments up to 4 or more (not sure atm) if this is what you mean. It has to be enabled on PW template setup. After you can use segments to give it to the php template.

So kinda yes, yes, and yes :D

Have fun!

Link to comment
Share on other sites

Hi Steve and welcome to the forums.

For me it seems that your application would fit ProcessWire nicely. Although with this information it is hard to say if it would be wise to implement data syncing between offices database or just read that database directly or through some kind of API (and I think that this is something you need to decide however you will build your application). PW doesn't get into your way at all when you need to do some "real coding". In Soma's answer he talks about the way where you do sync the data, but you could also just save ID values from offices DB and query the data from there.

Final question - is PW able to use URL's with wildcards, so for instance if the URL is /cities/*mycityname* a particular template is executed and the parameter *mycityname* is passed through to the template? That would be a most useful feature as it could be quite suitable for my type of application.

Yes, PW got that. You can define per template basis if you want to allow urlSegments. If you do allow, then you get those as a parameters in your template: http://processwire.com/api/variables/input/ (Retrieving URL segments via $input->urlSegment(n)).

Link to comment
Share on other sites

Hi guys,

Thanks for the very quick responses!

Found the URL segments after writing my post, and it does seem to do the trick.

One thing I really liked of PW when I was reading the API was the ease it can be called from a system shell, or integrated from another script. I have never come across a CMS quite like that.

Soma, I presume the offices would need to be pages to be able to display them and link back to the skyscrapers? I should probably have mentioned that the offices must be listed on the skyscraper page rather than being separate pages. Would probably be more appropriate to call it a Recipe where the recipe description is the equivalent of the skyscraper, and the offices would be the ingredients. At the same time you need to be able to list all ingredients in the system, then have a page for each ingredient that shows all the recipes, and finally link back to what recipes they are used in.

I guess the best approach would then be to use the API to get the pages of ingredients/offices containing the ID of the recipe/skyscraper, and display them in the recipe page.

Sorry I have to use these kind of descriptions, I am under an NDA for this, at present, although I might be able to disclose it later.

Regards,

Steve

Link to comment
Share on other sites

offices would need to be pages to be able to display them and link back to the skyscrapers?

In ProcessWire almost everything are pages. Currently all "normal pages", users, roles, permissions, admin pages etc are pages. To take it further, if you build tagging, each of your tag would probably be a "page". Page doesn't have to be something that is accessible from certain url (although it gets a unique url which is one way to identify and give meaning for that certain page) and something that is "meaningful" on his own. Page = node = item = row etc..

So if your site would be just clean PW-implementation then offices would be pages and there would be relation between buildings and offices. And if office can be only in one building, then you probably would just add them as child pages (relation comes there from page hierarchy). But if same office can be in multiple buildings, then you would use special "page"-field, which allows you to have relations between different pages. So you could choose on per building basis on what offices there are.

Link to comment
Share on other sites

Excellent concept, I really like it!

I'll definitely get to grips with this and build a concept/prototype of this.

One thing that really appeals to me is the ability to custom make an admin page that contains only what's needed for the user, and be able to use the API to easily add these as pages.

Looking into the structure of the PW system further, it seems to be some really clever architecture here.

As you guys have been so brilliant, allow me to ask another question. For a completely different application I am looking to create a directory portal of properties. A property owner must be able to edit their own properties, and obviously I need to store a fair bit of information about the property owner.

Should then the property owner also be a 'page', albeit hidden? And I just define the fields I want?

I presume then I need to create a link between the property owner and the property, to ensure only they can edit it. This again would be a new template, for instance /property/edit/property-name, where I do the security check.

Am I on the right track for this?

Hmmm. If so I can see quite a few uses for this system...

Best regards,

Steve

Link to comment
Share on other sites

Should then the property owner also be a 'page', albeit hidden? And I just define the fields I want?

Yes, but PW already has users setup as pages, so that's what you'd want to use for the property owner. If you only wanted them to be able to edit specific pages, you could create a page reference field (using PageListSelectMultiple Inputfield), add it to the 'user' template. Then for the template used by the pages you want them to be able to edit, you could check if the page being displayed is in their list of editable pages you defined, and let them modify it if so. (This idea is from Soma and something that I know he's done before).

Am I on the right track for this?

I'm late to the conversation, but if I understand correctly, you are on the right track! :)

Link to comment
Share on other sites

Ryan is right.

Here's a little module I'm using. I will maybe consider make it official module, but then I would like to have it with some configuration and this would take some time to consider.

You would need to add a page reference field with inputfield asmselect or multiple select and add it to the user template (use filter at top of template overview page to show system templates). In this case it called "editable_pages". Following code does recursive check for editable pages. This works with adminbar in frontend too. If you like only 1 page you could also check only for those explicit. Have fun :)

<?php

/*
* Page access control on user level
* Allows to add pages on to user page to restrict editable workspaces
*
*/

class AccessPageEdit extends WireData implements Module, ConfigurableModule{

public static function getModuleInfo() {
	return array(
		'title' => 'Access Control Page Edit', 
		'summary' => 'Control who can edit what page. Create "editable_pages" page field (asmSelect) and add it to user template. Select pages to allow edit and add access.', 
		'version' => 001, 
		'permanent' => false, 
		'autoload' => true, 
		'singular' => true, 
		);
}

public function init() {
	if($this->user->hasRole("editor")) $this->addHookAfter("Page::editable", $this, 'checkpermission'); 
	if($this->user->hasRole("editor")) $this->addHookAfter("Page::addable", $this, 'checkpermission'); 
}

public function checkpermission(HookEvent $event) {

    // if it was already determined they don't have access, then abort
    if(!$event->return) return;

    $page = $event->object; 
    $parents = $page->parents;

	// run check for parent pages and allow recursive inherit access 
	foreach($parents as $p){
		if($this->user->editable_pages->has($p)) return true;
	}
	// then run check on selected single pages
    if(!$this->user->editable_pages->has($page)) $event->return = false; 
}

}

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...