How to create pages programmatically?

Feed 12 posts, 4 voices

Aug 14, 2008 22:09
Avatar
286 posts

Has anybody done this? I'm talking about creating pages without using the GUI. I need something like an API...

 
Aug 15, 2008 04:12
Avatar
37 posts

Hi, See the Page model (in /frog/app/backend/models/Page.php) and how the PageController (/frog/app/backend/controllers/PageController.php) use it (particulary the _add method if you want to create a new page).

 
Aug 15, 2008 04:21
Avatar
286 posts

thanks gido, i'll check it out!

 
Aug 15, 2008 04:55
Avatar
396 posts

I'm not sure it is wise to use Frog internal code to do that. Any method you see which is prefixed with an underscore (_) should be considered off-limits since it is a private method and might change in future Frog versions.

If you explain why you're trying to add a page programmatically, we might be able to point you in the correct direction or simply add a method to the Plugin API to provide the functionality you need.

 
Aug 15, 2008 06:37
Avatar
286 posts

hi mvdkleijn, i have a dynamic mashup page and i want to do snapshots of it once a day so i can have an archive of how it looked on any given day. so i just want to automate and cron the procedure of creating the archive pages. thanks for any advice!

 
Aug 15, 2008 12:15
Avatar
396 posts

So you have a page with dynamic content which changes daily (couple of rss feed for example), and each day you want to save that day's content so people can refer to it later for example....

My guess is you could go one of three ways with this:

  1. You could dynamically create a page in Frog. This method would have a couple of side effects: the pages tab would quickly fill up with your archive pages / content editors might lose track of the overview
  2. You could use a custom database table for your plugin and store the archived content in there. Then your plugin could provide multiple methods of accessing that content and dynamically create the archived page when a user wants it.
  3. You could store archived data on disk somewhere and dynamically access it to create an archive page when people need it.

Option 1 would require the least amount of work I guess since it would probably be a "simple" copy-paste of content kind of action. Downside would be the number of pages it creates and a possible lack in overview for content editors.

Option 2 is more similar to the current "Archive" plugin's behaviour and thus more in line with Frog's "style" if we have any. ;-) Anyway, this would also give you the most flexibility with regards to accessing the data in custom ways. Here the downside is that it would require more work to do properly and the database might grow very quickly in size.

Option 3 is the least desirable in my humble opinion since it would require having disk access, would require you to write and read files to disk, have the appropriate permissions, etc. etc.

My advice? Use option 2....

If you really don't want to do that, I guess we can put a createPage method (and related methods) in the Plugin API. I think that probably wouldn't be a bad idea anyway. I'll discuss that with the guys to see if they like it.

 
Aug 15, 2008 19:48
Avatar
286 posts

mvdkleijn, thanks for your post. with regard to option 1, is it any different than the blog posts? i havne't used the blogging feature of frog, but if you wrote a post every day wouldn't that also create a large number of pages to manage. what is frog's way of dealing with this? is there any sort of pagination?

 
Aug 16, 2008 04:30
Avatar
820 posts

@ricks - deep in the recesses of my "mind" there was a memory that this came up once before. I managed to find this thread on "paging in the admin". I think that's the only place it has come up before. Something worth thinking about?

 
Aug 16, 2008 10:23
Avatar
396 posts

@ricks – with regard to option 1, is it any different than the blog posts?

Actually, the blog/archive posts are using a system more similar to option 2. The main difference between your plugin and the Archive plugin is that your plugin (correct me if I’m wrong) displays a single page which automatically(?) changes its contents every day. You then automatically store that days content in an archive somehow.

The Archive plugin actually is just a collection of normal “static” posts and a method of displaying a sorted list of those posts based on creation date.

@David – I agree we’ll have to figure out a method of dealing with large number of pages in the admin section of Frog. I created this issue for the problem…

Though it’s not one we’ll solve easily I think. Do we have any large 2000+ pages sites available to get performance data from?

 
Aug 16, 2008 16:44
Avatar
286 posts

@mvdkleijn, Thanks for your advice. I think what I want to do is similar to the way that Article pages are currently archived, so that's probably the way to go. I'll take a look at the way it's designed.

Instead of discussing pagination here, I think we should open another thread on that.

 
Oct 17, 2008 22:02
Avatar
286 posts

I’m not sure it is wise to use Frog internal code to do that. Any method you see which is prefixed with an underscore (_) should be considered off-limits since it is a private method and might change in future Frog versions. …we might be able …to add a method to the Plugin API to provide the functionality you need.

Is this in 0.9.4 by any chance?

 
Oct 18, 2008 04:34
Avatar
396 posts

Nope… there wasn’t an issue/feature request recorded for this in the issue tracking system so I kind of forgot about this. (hint.. hint..)

;-)

 
Oct 18, 2008 16:06
Avatar
286 posts

darn! alright I guess I’ll have to use the evil google issue tracker…