Blocks - Sample Content

Hi
When we develop a C5 block and install at dashboard, it comes with blank content and we have to manually add content.

Is there a way we can define sample content in some XML file maybe and once a block is installed it comes with prebuilt content?

Do you need the content to be editable at some point? If not, I believe you could build the block without the edit interface so it would be un-editable. Whatever you code into the view is what your block would then output.

I assume you are using a text area to allow users to "manually add content? if that’s the case, you can look at the content block to see it’s method for qetting content and presenting it to the add view (which is really the in-line editor).

Take a look at the content block in core "/concrete/blocks/content/add.php). It is here that the content block could be made to display default content when a content block is added. Your content block likely has a method of code snippet that retrieves the code for display in the view for edit.

All I’m looking is when we add a custom block to page, it may prefill the fields in block interface like default text, link, image etc

Your custom block will have a file that contains the block add/edit form. For example, the Concrete Feature block has form.php. You can modify the equivalent file in your custom block and set default values for the form fields.

You would implement such in your custom block add/edit interface. In its simplest form, add.php is only used for a new block, so you can safely code default values there to appear in the block dialogue without danger of interfering with future edits.

For many of my addons (but not all of them), I provide a dashboard copy of block dialogues for globally pre-setting the default values when adding a new block.