What is the series of mySQL statements which must be carried out to add a page to Concrete5 programatically?

StackOverflow https://stackoverflow.com/questions/4228995

  •  26-09-2019
  •  | 
  •  

Question

I wish to create then periodically replace content in a concrete5 CMS.

I have identified 15 tables which are changed when a new page is added (by doing an MYSQL diff).

However I dont quite follow how these tables are getting their values, especially the bID value in btcontentlocal.

I only discovered concrete5 today, so if you know that there is an API to post content to the backend, please share that with me too!

Was it helpful?

Solution

Concrete5 doesn't usually "replace" content -- rather, it adds a new revision to the history of a page (note that due to historical reasons, a page is often called a "collection" in the code and database -- as in "a collection of blocks"). The bID is the block id, which will change every time a block is edited (again, because it's not actually editing the block that was there, but rather copying that block to a new one so the old one sticks around for the revision history).

So... not sure what exactly you're trying to do, but if you want to update a content block that's on a page, you need to create a new collection version (which I believe implicitly carries all existing blocks forward), then copy the block in question block (I think there's a "copy" or "clone" method in the block model for this purpose), then update that block's content, then un-assign the old block from the new collection version, then assign the new block to the new collection version, then approve/publish the new collection version.

I would strongly advise against doing this via database queries -- Concrete5 is a very complex system and there are lots of little things going on that you don't want to accidentally leave out of the process. The better approach is to figure out how to do it through the models themselves. Unfortunately I don't think there's one simple API function for doing all this, though -- instead you'll need to figure out the 5 or 6 different things that need to be done. You might have more luck if you ask this question on the concrete5 forums: http://www.concrete5.org/community/forums/customizing_c5/

OTHER TIPS

See this documentation. http://www.concrete5.org/documentation/developers/pages/overview

You can add pages by using code of C5 self;)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top