Bulk Pages in Database

Permalink 1 user found helpful
Is it possible to, using a simple sql statement against the c5 db, to add the needed files to bulk create pages?

Instead of inputting this information for each page one by one in the dashboard.

Example, youtube video player page. Obviously the layout is the same, but Title, Video itself, and other dynamic text changes.
THIS is what I would like to do an import / bulk add this dynamic portion.

Now, I can examine where this content is in the C5 db.. and sql in the hundreds of dynamic pieces of info.
Can I go this route, OR is the creation of these pages more involved then merely putting the needed records into the db?

I'm fully aware of a primary key if needed, etc. I'm wondering if when creating the needed records for a page, is there something else that gets update at another table?

Lastly, for this import of bulk pages / records, I don't need versions.. like as if I were creating them one by one and C5 keeps all the versioning.

View Replies: View Best Answer
jshannon replied on at Permalink Reply
It's much more complicated than that.

Yes, at the end of the day everything is in the db and if you insert into the correct tables it'll be indistinguishable from pages created manually. BUT... there are a lot of tables to update. There's Pages, PagePaths, PageSearchIndex, version tables, etc. And that's just for the page. If you want any blocks or attributes on it, add another half dozen tables.

You really should export from the db into some format (like csv) that allows you to use the PHP APIs to loop through and create the pages.

If you want to see how hard it is, I'd suggest you dump your entire db to a .sql file, add a page, add some content, attributes, etc, then do another dump and diff the files. (I'd be curious to see the result...)

How many pages are we talking about?
BG410 replied on at Permalink Reply
Yea, your first paragraph is what I was hoping to not confirm! But answers my question.

As far as how many pages.. think of american football teams.
Theres the NFL (which is made up of teams).

Each team has its own page, same layout, but obviously diff team logo, team images, colors, etc.

Now, I know i can simply create just one single page and handle this dynamically, I will be using JohnTheFish addons, one of which is Magic Data, which is perfect for this.. (symbols).

But, I'm thinking about SEO, and having each page being able to be indexed.

So, to have actual individual pages, keep in mind, in this case I'm not concerned about versioning for these. I would have to create these pages one by one to get them correctly into C5 DB tables?
Also to answer your question, I'm looking at a minimum of 245 (individual teams).

The only other thing I can think of is, SOMEHOW to do something tricky to sitemap page and htaccess search engines to that maybe?
jshannon replied on at Permalink Best Answer Reply
You seem pretty sophisticated, though maybe not necessarily with c5.

Especially if you don't want to edit the team data in the c5 "Page" interface and you're fine using the same template for all pages, I would do this as a single page and some logic on the single page that grabs data from a non-c5 table (probably one that you already have).

Google doesn't know the difference between a single page and an actual page. It's true that /nfl?teamID=x isn't very SEO friendly. But single pages (very easily) support "arguments" in the form of /nfl/team-name . So, just use team-name as the key and do whatever db stuff you need to do with your own table.
BG410 replied on at Permalink Reply
Yea, I'm definitely using a separate DB, and tables / joins, simply because honestly, I already have that much data!

I was just hoping that at minimum I could import a bunch of separate pages with some minimal stuff like that H1, a title, team / base image for the search engines to absorb, and all the other stuff say like stats and 'stuff' like that I could get that in dynamically on pageload.

Looks, like it maybe a helluva lot easier to just go ahead with the one page for all, and see what I can do to get atleast google bots to see the number of pages.

The downside to that is little things like say on Team #1 page there is a link to Team #2 page, when bot hits that link.. there is no 'jump to' a live Team #2 page.

But yea, I'll explore the single page method you mentioned, that maybe the solution for this.

I'll figure it out.. but thanks for atleast confirming that I cant just do a simple sql import.
jbx replied on at Permalink Reply
Actually, there is another option you may not have considered...

I've recently had a similar situation where we needed to import around 100 news pages - same page type, but different content and attributes on each page, from a csv file.

I created a tool to do this. This gives you access to the full C5 API. So you can create a page, assign a page type, add the attributes and place content into a specific block already added to the page type default etc., all through code.

Took around 30 minutes to write the import, another few minutes to run, and then we had all our news pages.

Just a thought...

BG410 replied on at Permalink Reply
But does this create actual pages or 100+ single pages?
Also, IF it creates actual pages are all necessary record changes throughout the db/tables done correctly like if adding page through dashboard?

Lastly, what did you use for source.. csv? a db you already had?
jbx replied on at Permalink Reply
Absolutely - real pages, not single pages, so they would all be indexed in the sitemap.xml and accessible through the Full Sitemap in the dashboard.

There is no real difference between clicking 'Add page' in the dashboard and calling Page::add($data); in code.

Check this out for a starting point. If you know your way around php, should take you no more than an hour to get a simple working example up and running: