2
votes

I have created custom template for PageList block and need it to be used to get required visual effect. User needs to have possibility to add new instances of the block to page (they are used as slides for carousel plugin) but in that case he needs to remember to change block template from default to the custom one each time when new block instance (new slide) is added.

Is there any way to force concrete5 to automatically use custom block template instead default one?

2

2 Answers

5
votes

Yes, you can enforce this on a per-area basis. In your theme's page type template, find the code for the editable area you want to enforce this custom template on, and call the setCustomTemplate function. For example:

$a = new Area('Main');
$a->setCustomTemplate('page_list', 'templates/your_custom_template');
$a->display($c);

The first argument is the blocktype handle for the block you want to apply this to, and the second argument is the custom template (note that there is not a .php extension at the end of that -- the C5 system will add that automatically).

1
votes

It's possible, I did it for work a while ago. Hopefully the link will below will help you get started. There is a section called Override and Modify near the middle, although you are probably going to have to scim through other sections to know what they are referring to.

http://www.concrete5.org/documentation/recorded-trainings/building-blocks/basic-block-development-four/

This may also be helpful:

http://www.concrete5.org/documentation/how-tos/designers/change-how-a-block-looks-templates/