Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto-populate site tree items for SilverStripe site

I am still learning SilverStripe, and right now, I have a list of 50-60 pages I have to create for a site. It was suggested that I find a way to auto-populate the SilverStripe site tree with some code in order to save time (as opposed to manually creating each page one at a time). I have never tried something like this before (with or without a CMS). I know what the parent and child page names are, and I suppose I would need to create a loop to build out the child pages for each parent.

Is this something that is possible in SilverStripe? Would a for loop be the best approach or is there a more efficient way? If I can make creating these pages easier, it would be great for me for this project and future ones, so any advice would be appreciated!

like image 535
Dejsa Cocan Avatar asked Mar 15 '23 03:03

Dejsa Cocan


2 Answers

My understanding of this question is that you want to pre-populate the pages and their content programmatically rather than manually entering them in the CMS. There are a few projects that might help you.

  1. Populate module (https://github.com/dnadesign/silverstripe-populate)
  2. SilverSmith (https://github.com/unclecheese/SilverSmith)

Or you could simply override DataObject::requireDefaultRecords and build the pages out there. I would often use that method for functional or one-off type pages (e.g. ShoppingCart).

like image 53
Mark Guinn Avatar answered Mar 23 '23 23:03

Mark Guinn


There is also a Site Tree Importer from SilverStrip Labs. It's hosted on Github

like image 35
muskie9 Avatar answered Mar 24 '23 00:03

muskie9