Adding a Designer Content block to a page type by default
Permalink Browser Info Environment
I've created a block using Designer Content (in c56) which works fine when added to a page in the normal way to add a block. I now want to create a page type which contains that block by default so I've taken an existing page type and changed
to
* These fields are required
But it doesn't display the block and I can't edit the block contents.
I get the field names from the block controller
I did try to add the block to the page type default but because there are several required fields I have would have to enter some default values when I add the block to the page type and I'd rather not do that.
Have i done something wrong or missed something out?
Thanks
$a = new Area('Main'); $a->setBlockLimit(1); $a->display($c);
to
$pub = BlockType::getByHandle('publication'); $pub->controller->field_1_textbox_text = ''; // Title * $pub->controller->field_2_image_fID = 0; // Cover image * $pub->controller->field_3_wysiwyg_content = ''; // description * $pub->controller->field_4_textarea_text = ''; // Publisher name & address * $pub->controller->field_5_link_url = ''; // email $pub->controller->field_6_link_url = ''; // website $pub->controller->field_7_file_fID = 0; // optional download link 1 $pub->controller->field_8_file_fID = 0; // optional download link 2 $pub->render('view');
* These fields are required
But it doesn't display the block and I can't edit the block contents.
I get the field names from the block controller
I did try to add the block to the page type default but because there are several required fields I have would have to enter some default values when I add the block to the page type and I'd rather not do that.
Have i done something wrong or missed something out?
Thanks
Type: | Pre-Sale |
---|---|
Status: | In Progress |
I'm not sure why your code isn't working, but in general I'd recommend not hardcoding blocks into pagetype templates. Use a global area instead, and disable the editing controls on all pages except the "Page Type Defaults", so you can set it up once and not worry about the people adding/editing pages accidentally changing anything. Seehttp://concrete5tricks.com/blog/dont-hardcode-blocks-use-a-global-a...
Thanks for the reply.
I did read that article and have tried it. The problem is that when one adds the block to the page if there are required fields one has to put something into those fields and that content then shows when anyone uses the page type. They then have to delete/overwrite the defaults before entering their own content and I wanted to avoid that.
Hardcoding the block into the page is the only way I can see of avoiding having default content showing - maybe there is another way I've not found. In fact I can't get any block containing a form with required fields to work. The block does not show in edit mode
At the moment I have the block added in the way you suggest without specifying the fields as required - that works, but I do lose some control over the way the page type is used.
I did read that article and have tried it. The problem is that when one adds the block to the page if there are required fields one has to put something into those fields and that content then shows when anyone uses the page type. They then have to delete/overwrite the defaults before entering their own content and I wanted to avoid that.
Hardcoding the block into the page is the only way I can see of avoiding having default content showing - maybe there is another way I've not found. In fact I can't get any block containing a form with required fields to work. The block does not show in edit mode
At the moment I have the block added in the way you suggest without specifying the fields as required - that works, but I do lose some control over the way the page type is used.
Sorry for the delay (this somehow got lost this in my inbox)...
If the problem is that you don't want default data showing up, can you just not supply any default data? That is, the block can exist on the page defaults, but all of the fields are empty?
-Jordan
If the problem is that you don't want default data showing up, can you just not supply any default data? That is, the block can exist on the page defaults, but all of the fields are empty?
-Jordan