Meta Box
Support Forum
Support › MB Blocks › Alignment doesn't worksResolved
I am using metabox block through mb views. i allow alignment center/left/right in mb custom field
i have the option in gutenberg but what ever i do, there is no change in code on front end.
what am i missing ?
Hello,
You need to add the align attribute to the block template and create some custom CSS code to style the content with the align selection. For example:
align
<p class="{{ align }}">{{ block_description }}</p>
screenshots https://imgur.com/a/wMpKA5b
and please follow the documentation https://docs.metabox.io/extensions/mb-blocks/#render_callback
ok thx
i am using views to code the block, and {{ align }} seems to get nothing
If you use the View template, you can access the align attribute via the attributes variable. Here is an example:
attributes
Print attributes: {{ attributes.align }}
Hi peter, thanks : where can i see that in doc ?
Here you go https://docs.metabox.io/extensions/mb-blocks/#using-mb-views Notice the sample code:
<div {{ mb.get_block_wrapper_attributes() }}> <img class="testimonial__image" src="{{ attributes.image.full_url }}"> <div class="testimonial__body"> <div class="testimonial__content" style="min-height: 50px;"> <InnerBlocks /> </div> <div class="testimonial__author">{{ attributes.name }}</div> </div> </div>
thanks !