Prevent remove blocks from template - wordpress

First of all i'm using acf to create gutenberg blocks (i think it's important to say about it).
I made custom post type for my restaurant menu, where i want to force exactly the same layout for each
posts.
I made background block to can adding blocks inside there.
<div class="background">
<div class="background-color" style="background-color: <?php echo $background ?>"></div>
<InnerBlocks />
</div>
To get similar layout to each posts i set template parametr in my cpt
'template_lock' => 'all',
'template' => [
['acf/background', ['className' => 'meal_description', 'data' => ['admin_section_name' => 'Meal description']], [
['core/paragraph', ['align' => 'center', 'placeholder' => __('Your block there', 'restaurant')]],
]],
];
Unfortunately when i set template_lock to all i cant add block in my 'inner_blocks" called background.
I'm looking for solution in which admin could add some block only in predefined blocks.

Have you tried adding templateLock="false" to the InnerBlocks element?
E.g. <InnerBlocks templateLock="false"/>
templateLock is passed down to child elements, so setting the value on the InnerBlocks should overwrite the parent value.
https://github.com/WordPress/gutenberg/tree/master/packages/block-editor/src/components/inner-blocks#templatelock
If locking is not set in an InnerBlocks area: the locking of the
parent InnerBlocks area is used.

Related

Symfony 4 - Organize layout of fields

Using Symfony 4, I wonder if there a simple way to organize the layout of how display my fields.
For now, I template everything in my views (to have 2 columns for example) :
<div class="row">
<div class="col-md-6">
{{ form_row(form.name) }}
</div>
<div class="col-md-6">
{{ form_row(form.company) }}
</div>
</div>
{{ form_rest(form) }}
But, I don't want to do this, I just want to render whole form in my view, and manage the template in my FormBuilder. I would like to write something like :
$builder
->add('<div class="row"><div class="col-md-6">', HtmlType::class)
->add('name', TextType::class, [
'label' => 'Nom'
])
->add('</div><div class="col-md-6">', HtmlType::class)
->add('company', TextType::class, [
'label' => 'Société cliente'
])
->add('</div></div>', HtmlType::class);
I looked at the documentation, but it's pretty poor, it shows how to inerhit from existing fields.
Is there a way to create this HtmlType to just handle simple Html tags ? or a better way ?
You should be able to do something like that :
$builder->add('your_field', YourFieldClass::class, [
'attr' => ['class' => 'your css class'],
]);
The best solution would be to create a custom form theme. Reference to the documentation is here. I haven't done this myself for creating custom grid but I guess you can create some custom type options using the OptionResolver that will tell your template how to organize your fields and then based on that you can organize your custom form theme however you want.

Concrete5 advanced Grid

My customer wants to maintain their own grid so that they can fully design their design like they want. Problem in this is when i add a Bootstrap grid in concrete5 that it defaults created a col-md-6 for example.
Problem is that i have a design with 2 options, mobile or desktop. In my setup on default i have it like this:
<div class="row">
<div class="col-sm-6">A</div>
<div class="col-sm-6"><img></div>
</div>
<div class="row">
<div class="col-sm-6"><img></div>
<div class="col-sm-6">B</div>
</div>
The problem over here is that this should be the layout for the "desktop" version instead so i'd need to use the col-lg instead. Fo all smaller devices (col-md and below) the rows should be fullscreen so it should look like:
A
B
How can i achieve that in concrete5? The other problem i have is that if i make this responsive the design would show it in this order for mobile:
Text
Photo
Photo
Text
Where the customer wants it like where the col-push would come in.
How can i do that if even possible with Concrete5? I ofcourse can set it all manually and make the inside block as content but by doing that it is not flexible at all.
Thanks
This should be possible with the theme area layout presets (which are defined in the page_theme.php).
The downside is you'll have to define all possibilities.
Example:
public function getThemeAreaLayoutPresets(){
$presets = array(
array(
'handle' => '2_columns_no_push',
'name' => '2 Columns no push',
'container' => '<div class="row"></div>',
'columns' => array(
'<div class="col-lg-6 col-md-12"></div>',
'<div class="col-lg-6 col-md-12"></div>'
)
)
);
return $presets;
}
Developers documentation : http://documentation.concrete5.org/developers/designing-for-concrete5/adding-complex-custom-layout-presets-in-your-theme

how to change a comment structure in wordpress

i am working on my wordpress theme, and comment time/date are showing up in one continuous timestamp tag:
<time datetime="2015-12-21T19:09:49+00:00"> december 21st, 2015 on 19:09 </time>
i would like to have the time of day be wrapped in a span tag, so i can style it with css. the comment.php file on my theme uses this to list the comments, and there's no way to edit the timestamp here:
<ol class="comment-list">
<?php
wp_list_comments( array(
'style' => 'ol',
'format' => 'html5',
'short_ping' => true,
) );
?>
</ol>
i tried looking at my theme's functions.php, as well as wordpress' include files: comment.php and comment-template.php. none of them deal with the actual tag structure of the time-stamp, so there was nothing there for me to play with.
does anyone have any idea how i can do this? obviously, i'd rather do it in my theme's functions.php than alter the wp inc stuff..
thanks!
Usually the comment date stamp is defined by :
.comment-metadata a, .pingback .comment-edit-link
Search for something like this in style.css and you can style them.

Yii2: How to make position:none for kartik timepicker?

I need to apply css3 properties to kartik time picker widget tried with
<div style=" position: none;">
<?php echo $form->field($model, 'checkin_time')->widget(TimePicker::classname(), [] )->label(false); ?>?>
</div>
But not able to get it, is there any way so to apply css3 properties?
I think you should use containerOptions is the array that set the HTML attributes for the main widget container
<?php echo $form->field($model, 'checkin_time')->widget(TimePicker::classname(),
['containerOptions' => ['style' => 'position:none;']] )->label(false); ?>

Override form using PHPTemplate

I was wondering how I should override the way a form looks in Drupal 7 using PHPTemplate. I have some difficulties displaying all the information on my page.
I have a page with a form and some miscellaneous information.
I have tried:
foo.module
function foo_add_form($form, &$form_state, $foo) {
...
$form['#theme'] = 'foo_add';
return $form;
}
function foo_theme($existing, $type, $theme, $path) {
return array(
'foo_add' => array(
'template' => 'foo-add',
'render element' => 'form',
),
);
}
foo-add.tpl.php
<?php
// First form
print drupal_render_children($form);
?>
<!-- Miscellaneous information -->
<div id="links">
<ul>...</ul>
<form action="#" method="post" id="second-form">
<fieldset id="i-want">
...
</fieldset>
...
</form>
</div>
At the moment the form and miscellaneous information are being displayed. However, the 2nd form (id="second-form") is being removed somehow. I can see it in the source, but when I inspect the element with chrome/firefox, I can no longer see the form element. I can see the div, ul and fieldset tags though.
Has anybody done this before?
Typically, you wouldn't add to the form at the theme layer. Instead, you'd use a custom module, implementing hook_form_alter to modify the form.

Resources