Jump to content

Adding pages with multiple fields as page fieldtype?


opalepatrick
 Share

Recommended Posts

Not sure if I am approaching this right.

Say I have a project page. Each project could have multiple organisations working on it. So I used a page fieldtype and this allows me to select the relevant organisation... if it exists. Then I saw that you could select the ability to add a new 'organisation' (page) in this case.

This works fine if all I want to do is create a new organisation name, but how would I also add the other fields for the organisation like address, city, etc?

As I said , I may be barking up the wrong tree, but any pointers appreciated.

Link to comment
Share on other sites

I don't think that's possible to do with the add new from a page field. However, you can use markdown syntax in the description for your page field to add a "add new organization" link as part of the field description. Be sure to specify

/processwire/page/add/?parent_id={parent-id-here} in the URL.

There are other ways using modules and hooks of course, but they are more involved than I can post on mobile.

Link to comment
Share on other sites

Of course, this still takes you out of context. So you might want to go the module route and load jquery magnific module and use &modal=1 in the URL as well. Sorry for the plain explanations, difficult to post code from a phone.

Link to comment
Share on other sites

I have used jquery magnific before on other sites but this is a first as a module. Another first is using Markdown! Thanks renobird.

So I have the correct link to open the add organisation link,

/processwire/page/add/?parent_id=1032&modal=1 

but at the moment it is not popping as a modal, just as a new tab. I can see Jquery Magnific as a core module but no other settings. Been hunting through the docs. Any idea what I am missing?

Link to comment
Share on other sites

I have used jquery magnific before on other sites but this is a first as a module. Another first is using Markdown! Thanks renobird.

So I have the correct link to open the add organisation link,

/processwire/page/add/?parent_id=1032&modal=1 
but at the moment it is not popping as a modal, just as a new tab. I can see Jquery Magnific as a core module but no other settings. Been hunting through the docs. Any idea what I am missing?

The link has to be given the class that will tell the javascript to open this in a modal. I have not used magnific but in fancybox in ProcessWire, I think the class was 'iframe'. Example code...

"<a href='{$this->config->urls->admin}page/edit/?id={$test->id}' class='myClass iframe'>$test->title</a>"
Edited by kongondo
Link to comment
Share on other sites

Thanks kongondo. Two things.

Markdown afaik does not allow classes in links. Python style markdown does by following with a {: class="iframe"} but this does not work here. So I can't test iframe as a class at the moment. (That was the second thing :-) )

Link to comment
Share on other sites

OK, didn't read about the MD part. Have you also edited your .js? For info though, here's how Wanze did it in ProcessBatcher.js

/**
 * Setup fancybox for page edits
 */
var h = $(window).height()-65;
var w = $(window).width() > 1150 ? 1150 : $(window).width()-100;

$('.batcher_edit').fancybox({
	type : 'iframe',
	frameWidth : w,
	frameHeight : h
});});

In the above the class 'batcher_edit' does the trick (even without using the parameter &modal=1) in combination with the class 'iframe'

Edited by kongondo
Link to comment
Share on other sites

Sorry about that, my posts where a little unclear. The markdown method won't allow for the modal (sorry if I unintentionally lead you down a rabbit hole there). I was referring to using a module and a hook to add the link to the field when using the modal. I'm short on time, but if you don't get it sorted out, I can dig up the code and post it.

Link to comment
Share on other sites

Aaah those rabbit holes. I can find them very easily on my own! Luckily I have processwire forums to get me out of them :-) Thanks both.

I should take a step back I think. Basically I have projects that have organisations that have contacts, amongst other things. They all have their own parent and page structure. If it was me coding it all with php and sql I would be fine, but I need to learn new tricks a la processwire style.

So before I go any further, is using page field types the way to go here or am I backing myself into a corner. I am thinking that, I select an organisation with a page fieldtype (already done) then really would only want to select contacts from that selected organisation, or, again add a new contact but only to that organisation.There could be multiple organisations per project as well. It is a sort of crm light. I would have conversations relating to the project that would all be cross referenced etc. 

The only person using this would be me and I would like to just record the projects, organisations, contacts and conversations in the admin area. I can use all that separately for reporting, forms and follow up reminders after.

So, is this a separate thread territory?

Edit: I should be doing this all out on web pages instead of trying to shoehorn functionality into the admin area, shouldn't I?

Link to comment
Share on other sites

I'm not really sure about the larger questions there. I think you could build this all in the admin (not frontend pages).

I sounds like you might might want to make a process module. List all the projects and provide links to common tasks for each of them. Maybe just a simple admin table would be enough?

Link to comment
Share on other sites

Thanks a lot renobird. I am going to have a look at that and at process modules. I think I am trying to run before I can walk on this admin area. It is the 'pulling it together' in the admin area that I am vague on. So thanks a lot for the tips.

  • Like 1
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

×
×
  • Create New...