Now that we’ve got the basics out of the way, we’ll look into more advanced examples. Starting with the ability to use the powerful Option builder that is part of CBOX Classic.
What is the Options Builder?
The Options Builder allows you to quickly add various amounts of theme options to your CBOX Classic theme. You create these options through the .ini files you’ve gotten used to by know. By using simple human readable directives you can create a huge amount of theme options really easily. When you’re done creating your options you can then output the option values inside your theme either through hooks (cleanest) or by inserting a bit of code into a forked template inside your CBOX Classic Child Theme.
What type of options can I create using options.ini?
Currently there are the following option types available:
Infinity Option Type Documentiation
It goes outside of the scope of this Getting Started guide to go into detail about all of these options. If you look at the .ini files in the CBOX Classic Parent Theme you’ll get a good idea of how the various option types are being put to use. On our Gists page you’ll also find a growing list of gists containing code examples to help you get started building your options!
Creating new sections for your options
All of the theme options are put into nearly organised sections that can be clicked on in the expanding accordeon on the “Options” Dashboard Page. Every accordion item is called a “section”. You can create these sections using sections.ini in your child theme.
Creating a section is really easy:
Add to sections.ini in your Child Theme
[new-section] title = "New Section"
Your new section will not show up until you put an option under that section. To do this you would add an option through options.ini where you told the option to be put under your freshly created “new-section”.
Add to options.ini in your Child Theme
[super_cool_option] section = "new-section" title = "Awesome Level" description = "Who is more awesome?" type = "select" default_value = "bowe" field_options[] = "bowe=Bowe" field_options[] = "marshall=Marshall"
Here’s the result of those two snippets
Outputting Option values into templates
When you’ve added your options there a few different ways to put your new options to good use. It’s completely up to you how you would like to utilize them. Here’s a few ideas to get your creative juices flowing:
-
- Let students fill in something about themselves in the theme dashboard and output it in their blogs sidebar
Create an “upload” option where students upload a picture of themselves and output that in the sidebar.
- Add new options to customize the CSS of your theme.
- Show or hide certain content based on a checkbox or radio button
When you’ve enabled Developer Mode every theme option in your Theme Dashboard shows you an example tab with how you could use an option:
Use the example to your advantage and start playing around with the theme options. It goes outside of the scope of the guide to dive into all of the possible use cases of Theme Options, but if you ever run into issues or have questions about them, feel free to ask in our CBOX Classic Developer Forums.
Congratulations, you are now a CBOX Classic Theme Expert!
That feels good doesn’t it? If you’ve went through all this documentation to learn how to theme with CBOX Classic, I’m sure you must be working on something awesome! If you run into issues, find bugs or would simply let to get in touch with us, drop by the Theme Development forums on the PressCrew community site. This is where we (PressCrew) hang out daily, and we’ll gladly help you get started!