htmlBurger
Forum Replies Created
-
Forum: Plugins
In reply to: [Carbon Fields] Sidebar on the flyHi @knath632,
Do you see the sidebar ID? It is
about-sidebarormy-new-sidebar. You can use it in thedynamic_sidebar()andis_active_sidebar()functions, as in the example we’ve posted above.However we feel you want to dynamically choose a sidebar which to display. If that is the case, you should do the following:
1. Create a container (for example theme options). Example and docs: http://carbonfields.net/docs/containers-theme-options/
2. Add a Sidebar field, namedcustom_sidebar: http://carbonfields.net/docs/fields-sidebar/
3. Go to the admin and select your sidebar in that field. You can create new ones, if you wish.
4. Use the following code to display that dynamic sidebar (assuming your field is in a Theme Options container and is namedcustom_sidebar):<?php $sidebar = carbon_get_theme_option( 'custom_sidebar' ); ?> <?php if ( is_active_sidebar( $sidebar ) ) : ?> <ul class="sidebar"> <?php dynamic_sidebar( $sidebar ); ?> </ul> <?php endif; ?>Hope that answers your question.
Forum: Plugins
In reply to: [Carbon Fields] Sidebar on the flyHey @knath632,
Yes, the Sidebar Manager is a completely usable feature that allows you to create, manage and render dynamic sidebars.
The custom sidebars that are created on-the-fly are intended to be used with the Sidebar field: http://carbonfields.net/docs/fields-sidebar/
This field allows you to create new sidebars, or to select any sidebar (either created on-the-fly, or registered in the code), and then in your templates you can use the value of that field in the
dynamic_sidebar()function. This will display sidebar that is selected in the field.Also, in case you want to retrieve all existing sidebars (as you asked), you can do it the following way:
$sidebars = apply_filters( 'carbon_custom_sidebars', get_option( 'carbon_custom_sidebars', array() ) );Please, let me know if you have any other questions.
Forum: Plugins
In reply to: [Carbon Fields] Sidebar on the flyHowdy @knath632,
Sidebars registered with Carbon Fields’s sidebar manager are registered with a slug version of the provided sidebar name. The slug version is generated by the
sanitize_title()built-in WordPress function, which is also used to generate the slugs of the posts/pages.So for example if your sidebar is called
Test Sidebar, its autogenerated slug will betest-sidebar.In order to render that sidebar in your code, consider the following code:
<?php if ( is_active_sidebar( 'test-sidebar' ) ) : ?> <ul class="sidebar"> <?php dynamic_sidebar( 'test-sidebar' ); ?> </ul> <?php endif; ?>Please, don’t hesitate to ask if you have any other questions.
Forum: Plugins
In reply to: [Carbon Fields] Image Gallery Field?Any contributions to the project are very welcome and greatly appreciated. In case you wish to propose a solution for a gallery field, the Github repo is wide open for suggestions. Thanks! 🙂
Forum: Plugins
In reply to: [Carbon Fields] Line-break and shortcode on rich editorHi Eric,
We’re constantly working on improving the documentation. Such support tickets are helping us in finding out what we need to fix and polish. So thank you 🙂
And good luck with your project 🙂
Forum: Plugins
In reply to: [Carbon Fields] Line-break and shortcode on rich editorHey Eric,
The data from Carbon Fields is returned in raw format, so developers can handle it in their preferred way. This means you should prepare it for displaying.
So, instead of just:
echo carbon_get_the_post_meta('content');you should use the following:
echo apply_filters( 'the_content', carbon_get_post_meta( get_the_ID(), 'content' ) );Please, let us know if you’re having further issues.
Forum: Plugins
In reply to: [Carbon Fields] Line-break and shortcode on rich editorHi Eric,
We’re unable to reproduce this issue.
But we really want to help you, so can you please send us a screencast of it, so we can assist you with fixing it?
Thanks in advance.
Forum: Plugins
In reply to: [Carbon Fields] Image Gallery Field?Hey Dalton,
Glad you like our plugin 🙂
Concerning an Image Gallery field: nope, we don’t have one yet. But we have a quick alternative for it, and a hidden feature that will probably be helpful for you.
For image galleries you can currently use the Complex field. Within a complex field, if you have an image field, you can use the WordPress Media modal to select multiple images. This will automatically create multiple Complex field entries with these images populated. It should make things easy for you.
You can find information about how to initialize and use Complex fields in our documentation.
Also, we’ve open a GitHub issue for a new Image Gallery field type – we’ll consider implementing one in the future. You can track its progress here in the GitHub repo of the plugin: https://github.com/htmlburger/carbon-fields/issues/18
Good luck with your project.
Cheers 🙂
Forum: Plugins
In reply to: [Carbon Fields] Inserting values via Gravity FormsHowdy @tomwhita,
Sure you can. But it is not the right place to do so.
Due to ww.wp.xz.cn forum’s policy (https://codex.ww.wp.xz.cn/Forum_Welcome) we’re not allowed to discuss any commercial work here, nor to share our company URL.
But we’re sure you can find us and our site by searching for our ww.wp.xz.cn username. Feel free to do so.
Forum: Plugins
In reply to: [Carbon Fields] Inserting values via Gravity FormsHowdy @tomwhita,
It’s always difficult to solve a particular issue without access to some more code. I’m sure it was something minor that was missing in your code.
Good luck with your project!
Forum: Plugins
In reply to: [Carbon Fields] Inserting values via Gravity FormsHey @tomwhita,
Are you using the “Post Custom Field” field in Gravity Forms?
If you do, you might want to try the Multi Select field type in that field, as it contains multiple values and probably inserts the data in a serialized array.
If there’s no working way to insert an array of data in a custom field with Gravity Forms, some custom code will probably be necessary to insert that meta after the form submission – Gravity Forms have a lot of hooks available that you can use.
Forum: Plugins
In reply to: [Carbon Fields] Inserting values via Gravity FormsHey @tomwhita,
The way I’ve been able to create an association when submitting a form is by sending the unserialize value. Like this: ‘”post:project:’ . $post->ID . ‘”‘
You’re probably setting that as a plain text value. However, it should be set as an PHP
arraylanguage construct instead. So it basically becomes an array of multiple values in the database, thus it would get serialized.When I try to use: array( ‘post:project:$post->ID’ ) to set the field variable, it does not work.
As mentioned, you are probably doing that manually and inserting it as a plain text value. If you’re manually calling
update_post_meta()to set the value, just passingarray( 'post:project:$post->ID' )to the value will work and the value will be automatically serialized. In case you are using a plugin for inserting the data, you should be looking for a possibility to insert arrays of data into one value – this is how the association field is stored.Also, can you go one step further in the get_user_by() reference. For example, would it be get_user_by(project_users->ID)?
Once you have the ID,
get_user_by($id)will work properly and retrieve the user object. Note: association data is returned as an array, so you would probably have to call$project_users[0]['id']in theget_user_by()call.Good luck 🙂
Forum: Plugins
In reply to: [Carbon Fields] Inserting values via Gravity FormsHowdy, @tomwhita,
It appears to be an interesting project 😉 Now to your questions:
I have successfully managed to insert an association value using a gravity form but the association is not shown in the carbon fields UI in the admin. Do you know why this might happen?
This would indicate that the data is not added correctly, and probably isn’t in the expected format. You should refer to our above explanation about how the association field data should be stored in the database.
Also, how do I now retrieve data from an association field in a usable way? For example, I have associated users with the custom post type “Project”. How can I show the display name of the user on my page template?
Let’s say the association field name where you associated users is
project_users. Let’s also consider that your project ID is$project_id. In that case, you should usecarbon_get_post_meta( $project_id, 'project_users', 'association' )– this will return an array with the IDs of all selected users. Then you can use the user functions (likeget_user_by()to retrieve the user object and information about it.Forum: Plugins
In reply to: [Carbon Fields] two fields next to each otherHey @excerptquestion,
Glad you were able to find your way.
In case anyone is looking for the same answer, it is documented in Fields -> Usage, in the “Width” section: http://carbonfields.net/docs/fields-usage/
Forum: Plugins
In reply to: [Carbon Fields] Inserting values via Gravity FormsHey @tomwhita,
The association field data is serialized like this:
a:3:{i:0;s:12:"post:page:48";i:1;s:12:"post:page:10";i:2;s:11:"post:page:8";}which eventually unserializes to:
( [0] => post:page:48 [1] => post:page:10 [2] => post:page:8 )As listed in the field documentation, an association field can have more than one value, and each value can be a post type, taxonomy term, user or comment. In this example, there are 3 selected items, all of them are pages.
Basically, each value is formed like this:
{type}:{subtype}:{id}where:
1.
{type}is the data type –post,term,userorcomment.
2.{subtype}is the data subtype – which is thepost_typeif using apost, or the taxonomy if using a term,userfor users andcommentfor comments.
3.{id}is the ID of the post, term, user or comment.So, now to your case. You want to insert a valie with the ID of a project, it would consist of one selected item, a post with post type
project. If the project has ID of 123, your entry would look like this:post:project:123and in order to insert it so it properly serializes, it has to be an array, like this:
array( 'post:project:123' )Please, let us know if you have any other questions.
Regarding contribution: any kind of contribution is welcome in the GitHub repos of the project: https://github.com/htmlburger/carbon-fields and the docs: https://github.com/htmlburger/carbon-fields-docs .
In the project repo you could contribute by feature requests, bug fixes, code improvements, and even translations.
In the docs repo you can always suggest ideas for improvement and for including undocumented features. The latest release of the documentation (corresponding to the latest release of Carbon Fields) is always automatically pushed on http://carbonfields.net/
Have fun 😉