Add content from plugin (or virtual parent page)

For a client I have to create a small plugin that adds people to their panel. So I have a pages/person.yml blueprint for creating people. I also have a sections/people.yml blueprint that the client can add to their site.yml so they have a place to create people.

What I need
The client wants to have people as children of a people page, so the URLs are like ‘people/johndoe’.

The problem
I don’t have access to the clients’ panel and so I can’t just add a people page to their content folder.

Question
Is there a way to add a page to the content folder via a plugin? Or use a virtual page as parent for the person.yml pages?

Why make things complicated? Either the client can add the page themselves via the Panel (and you change the site.yml blueprint so that they can), or you can add it the page via the file system? If you can add a plugin, I’m sure you can also add a page, no?

A virtual parent doesn’t make sense, you have to add the children somewhere, after all.

Yeah, that would be the way with a regular client. :wink: Unfortunately this client is huge, with a very weird server setup and even my immediate contacts there don’t have access to the panel. I also can’t access either the panel or the content folder directly. And the ones that do have access to the panel sometimes mess things up — like deleting important parent pages. That’s why I wanted to make this as easy as possible for them.

What I don’t understand is how you want to add a plugin if you don’t have access to the server? Unless you have some deployment process to add such changes to the code. In any case, if you want to have a parent page to which you can add children, you need to create this parent page somehow. Either manually or programmatically (and you probably want to make changes to the blueprint, so that the page is accessible via the Panel). Of course, you could also create this page via a plugin, by calling Page::create() but make sure this is then executed only once (so if page does not exist yet).

1 Like

I have to send them the recent version of the site as a Zip. Someone down the line implements the changes then. But that person doesn’t have control over the content folder. I have no idea how they’re doing that, but you’d think a client of that size would have more sophisticated deployment process in place. Nevertheless, the client gets what the client wants. :man_shrugging: It’s the first time I ever had such a weird workflow.

The Page::create() method was the only one I could think of that would certainly work. I just thought maybe there was a native way to do this. Thanks for your help!