Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add $format_value parameter for @field and @sub #43

Closed
vburlak opened this issue Aug 16, 2020 · 0 comments · Fixed by #97
Closed

Add $format_value parameter for @field and @sub #43

vburlak opened this issue Aug 16, 2020 · 0 comments · Fixed by #97
Labels
enhancement New feature or request

Comments

@vburlak
Copy link

vburlak commented Aug 16, 2020

Hey @Log1x. Thanks for one more awesome plugin, I appreciate all of your hard work!

I have an idea related to @field and @sub directives.

Original ACF the_field(), the_sub_field() allows optional $format_value param, which I found extra useful, when

  • you need to disable data formatting for specific field when it's not needed,
  • you want to avoid disabling acf_the_content filter for that field or all fields.

Issue with @field and @sub directives

Default ACF Example: I'm using the wysiwyg field and I could disable formatting on its value by passing false as a third param:

the_field('headline', false, false); // $selector, $post_id, $format_value

But sage-directives use different params logic within an additional feature, which helps to add an array key as a second parameter. (I found it very useful too!).

@field('headline', false, false); // $selector, $key, $post_id

Possible solution

The only solution I can see there to follow existing directive format — add expression to check for fourth/third expression here https://github.com/Log1x/sage-directives/blob/master/src/Directives/ACF.php#L50-L61

So the actual full param structure might be:

  • $selector (mixed)
  • $key (string)
  • $post_id (int)
  • $format_value (boolean)

The directive call to disable formatting might look like:

@field('headline', false, false, false);

I think my suggested solution not super clean and it needs a few extra tricks at logic to check all combinations within an additional $key param. But I would like to hear any of your thoughts/ideas on this?

P.S.: with the @sub — everything the same, but excluding $post_id param.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants