Automatically populate site tree elements for SilverStripe site

I'm still learning SilverStripe, and now I have a list of 50-60 pages that I have to create for the site. It has been suggested that I found a way to automatically populate the SilverStripe site tree with some code 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 CMS). I know what the names of the parent and child pages are, and I believe that I will need to create a loop to create the child pages for each parent.

Is this possible in SilverStripe? Would a for loop be the best approach or is there a more efficient way? If I can facilitate the creation of these pages, it will be great for me for this project and for the future, so any advice would be appreciated!

+4
source share
3 answers

My understanding of this question is that you want to pre-populate the pages and their content programmatically, rather than manually entering them into the CMS. There are several projects that can help you.

Or you can simply override DataObject :: requireDefaultRecords and build pages there. I often used this method for functional or one-time pages (e.g. ShoppingCart).

+4
source

There is also a Site Tree Importer from SilverStrip Labs . It was hosted on github

+3
source

Yes it is possible.

<ul> <% loop $Menu(your id here) %> <li> <a href="$Link" class="$LinkingMode">$MenuTitle.XML</a> <% if $Children %> <ul> <% loop $Children %> <li> <a href="$Link" class="$LinkingMode">$MenuTitle.XML</a> <% if $Children %> <ul> <% loop $Children %> <li> <a href="$Link" class="$LinkingMode">$MenuTitle.XML</a> </li> <% end_loop %> </ul> <% end_if %> </li> <% end_loop %> </ul> <% end_if %> </li> <% end_loop %> </ul> 

Keep in mind that the code may be slightly different and that this is for SilverStripe v3 +

0
source

All Articles