1

Topic: Auto-generate pages?

Hello there! I'm new to Wolf CMS, and very eager to try using it for my website. I looked at all the resources I could find, and couldn't find an answer to this question, so I apologize if I'm retreading an old topic here.

Is there a way to rapidly build hundreds of pages in Wolf CMS, all identical but with unique names?

I'm building a website to feature nearly 400 short radio play recordings I've made at conventions over the last four years. Ideally, I would have a dedicated web page for each recording, so that each one could be individually commented on and rated by visitors. Further, I'd like to create individual pages for each voice actor (there's two in each recording) that would feature all of that individual's performances and once again offer a chance for visitors to comment and rate. Finally, I'd like to do the same for the scripts (about 100 of them) and each convention that I've recorded at (about 20).

In the end, it would be around 1,000 individual pages. I already have an SQLite database organizing all of the individual pages I would need, and from what I understand, I should be able to make snippets for each page to include a PHP query to the database to grab the necessary media based on the title of the page. All I would need then is a way to make lots of pages at once, all identical, calling a snippet that uses the page title as input for the db query.

Are there any tools for doing this? Or will I have to manually build each page through the web interface?

Much thanks!!
Carrizo

Thumbs up

2

Re: Auto-generate pages?

There is no such tool for Wolf CMS.
Though you could write a script that does what you want, its not advise, just a method wink

3

Re: Auto-generate pages?

I thought I might have to. smile I'm pretty good with Python. Is there a command-line method for creating a page in Wolf CMS?

Thumbs up

4

Re: Auto-generate pages?

Here's one suggestion to make things quicker: you could use the page copy feature. As noted in the documentation, "page copy" also copies child pages. If you copy a "page" with 10 child pages (or a hundred!), you get the original "page" plus its 10 (or 100!) "children".

With a bit of thought and planning, that might help you build your site fairly quickly. Maybe? hmm

Using Wolf CMS professionally and for profit? Please consider supporting Wolf financially. Thanks!

5

Re: Auto-generate pages?

CarrizoCoyote wrote:

I thought I might have to. smile I'm pretty good with Python. Is there a command-line method for creating a page in Wolf CMS?

If you would use a scripting solution then it might be best to use raw mysql queries,
its not that simple without understanding how Wolf stores its content.

The "page copy" method that David proposed it much safer and easier to use.

Either way both methods will take a reasonable amount of time in my opinion,
certainly not rapidly as requested.

Another idea might be to use the Page Dash plugin give it a try anyway.

6

Re: Auto-generate pages?

David wrote:

Here's one suggestion to make things quicker: you could use the page copy feature. As noted in the documentation, "page copy" also copies child pages. If you copy a "page" with 10 child pages (or a hundred!), you get the original "page" plus its 10 (or 100!) "children".

That does seem to work really well! I'd still need to change all the metadata, but at least the pages would be built up quickly. Thank you very much!

Thumbs up

7

Re: Auto-generate pages?

So, I came up with a solution for generating 394 pages all at once. It seems to be working fine, but I wanted to post it in case anyone could point out an issue I hadn't seen.

Looking directly at the database (I'm using MySQL), I found every time I created a new page, the 'page' and 'page_part' tables were updated. I didn't see any other table updates, so I took a risk and wrote up a Python script to auto-generate a series of MySQL commands. (After backing up, of course.)

...
INSERT INTO page ( behavior_id, breadcrumb, comment_status, created_by_id, created_on, is_protected, layout_id, needs_login, parent_id, position, published_on, slug, status_id, title, updated_by_id, updated_on ) VALUES ( '', 'fwperf_0008', 1, 1, NOW(), 0, 0, 2, 8, 9, NOW(), 'performance-8', 100, 'Performance #8', 1, NOW() );
INSERT INTO page_part ( name, page_id ) VALUES ( 'body', ( SELECT id FROM page WHERE title='Performance #8') );
INSERT INTO page ( behavior_id, breadcrumb, comment_status, created_by_id, created_on, is_protected, layout_id, needs_login, parent_id, position, published_on, slug, status_id, title, updated_by_id, updated_on ) VALUES ( '', 'fwperf_0009', 1, 1, NOW(), 0, 0, 2, 8, 10, NOW(), 'performance-9', 100, 'Performance #9', 1, NOW() );
INSERT INTO page_part ( name, page_id ) VALUES ( 'body', ( SELECT id FROM page WHERE title='Performance #9') );
INSERT INTO page ( behavior_id, breadcrumb, comment_status, created_by_id, created_on, is_protected, layout_id, needs_login, parent_id, position, published_on, slug, status_id, title, updated_by_id, updated_on ) VALUES ( '', 'fwperf_0010', 1, 1, NOW(), 0, 0, 2, 8, 11, NOW(), 'performance-10', 100, 'Performance #10', 1, NOW() );
INSERT INTO page_part ( name, page_id ) VALUES ( 'body', ( SELECT id FROM page WHERE title='Performance #10') );
...

I had the benefit of very simple page design. All I needed was 394 children to a parent page I had manually created, all inheriting their parent layout. My layout was written to query an SQLite3 db I had separately written from Wolf CMS, using the breadcrumb as a value, so all of the content was built into the layout. No need for any data in the body, just a bunch of pages with specific titles, breadcrumbs, slugs, parents and positions.

I used Python to quickly generate the query in text format, then copy-pasted the text into phpMyAdmin to run it. After it was done, my pages were present, the settings on each were correct, and they properly pulled the data from the SQLite3 query, meaning the breadcrumbs were accurate.

One note is that I first tested by only updating the 'page' table and leaving the 'page_part' alone. Oddly enough, this seemed to work just fine, and the page loaded properly. When I edited the page just to confirm the variables were correct, I saved my work, and the 'page_part' table was properly updated. So I may not have needed those 'page_part' inserts at all-- still, better safe than sorry.

So...is there anything I'm missing? Or is this an acceptable way to auto-generate pages? If it is, maybe I can figure out a way to translate my Python script into PHP so this can be used as a plug-in. I could see a tool for converting a CSV of basic data points into auto-generated pages very useful.

Carrizo

Last edited by CarrizoCoyote (2015-12-06 07:24)

Thumbs up +1

8

Re: Auto-generate pages?

CSV import tool would be cool actually.

Thumbs up

9

Re: Auto-generate pages?

There is one. Check the plugins repository.

Tutorials at Project 79 | Wolf CMS Docs