Closed nathangross closed 1 year ago
Yeah, I personally create a method for each piece of data that I want to display in the view. Keeps it nice and clean. I find adding that logic inside of my views is not ideal as I usually require more logic alongside my get_field()
such as a default value, type-checking, handling the example/preview data, etc.
Hi! I'm just starting to dig into ACF Composer (and ACF Builder). When I create a block, I'm a bit unclear on the 'best practice' to access the field data in the view.
Let's say I'm creating a button that has a label. I'd like to show that label in the wp editor preview.
When I create a new block (
wp acorn acf:block Button
) the Button class has a function calleditems()
Is this just part of the boilerplate—since there is an items field? Would I create a function for each piece of data I'd like to display in the view?
Or is it better to just access the field data in the view with
get_field()
or even@field()
with Sage Directives?