Help with Background Field
- This topic has 7 replies, 3 voices, and was last updated 3 years, 4 months ago by
Qu1nt.
-
AuthorPosts
-
August 8, 2018 at 1:22 AM #10914
tsquez
ParticipantHi there,
I need some help understanding how the
background field
works.I have it implemented, and it shows up the way it's supposed to and holds all the values it's supposed to....great!
However I am having a hard time outputting the information from the
background field
. I have read the documentation here: https://docs.metabox.io/fields/background/ but I just can't seem to wrap my head around it.Could you possibly provide an example of what to do, maybe just a small tutorial on how to use the
background field
and apply the information from the field to a simplediv
?I think this would be a great addition to the tutorial section.
Any help is greatly appreciated. Thanks in advance.
August 8, 2018 at 2:07 PM #10917Anh Tran
KeymasterHi Thomas,
The background field saves details into an array. If you use the helper function
rwmb_meta()
to get its value - you'll get an array.To get the generated CSS for the background, please use the function
rwmb_the_value()
.This is the sample code:
$bg = rwmb_meta( 'field_id' ); echo $bg['color']; // Output a single background attribute // Get CSS for background $css = rwmb_the_value( 'field_id', '', '', false ); echo $css;
August 8, 2018 at 8:25 PM #10927tsquez
ParticipantHi Anh,
Wow, I thought you would try and explain a little bit more than repeating what is already in the docs located here https://docs.metabox.io/fields/background/
I'm sorry I forgot to mention that I did try both of those methods.
So again I ask, maybe you can do a little tutorial and show me and others how to add a background image to a container. Nothing fancy, something super duper easy.
Trust me, it's very confusing.
Yes No?
August 8, 2018 at 8:49 PM #10929tsquez
ParticipantOr maybe this: A tutorial on how to actually use
rwmb_meta()
andrwmb_the_value()
.Like how would I actually use:
$css = rwmb_the_value( $field_id, '', '', false ); echo '';
(taken from the background field documentation...doesn't seem to work properly though) and use it to show a background image for div.
I tried using the code I pasted from the
background field
docs and it doesn't even work. In the example given the css is supposedly wrapped in adiv
but it doesn't work.August 10, 2018 at 12:02 PM #10965Anh Tran
KeymasterHi Thomas,
I'll create a tutorial and video to demonstrate how those helper functions work and what is the difference between them. Please wait a little.
Thanks,
AnhAugust 10, 2018 at 9:33 PM #10974tsquez
ParticipantOh yeah most def. Sorry if I seem overly excited but I have reached a certain point in this project and I'd like to get it done and move on to the next part...again sorry.
I think you should do this for all the fields: Make a tutorial or a video or both. I know this would make your site even more AWESOME.
Thanks again for the help. I appreciate it.
August 13, 2018 at 10:30 AM #10988Anh Tran
KeymasterHi Thomas, here is the video tutorial:
Please pay attention to the text I wrote in the video :).
Hope you like it.
AnhDecember 14, 2021 at 9:29 AM #32587Qu1nt
ParticipantHi Anh,
How would I attach the background to an existing div in a template in Oxygen builder?
Thanks,
Quint
-
AuthorPosts
- You must be logged in to reply to this topic.