Comments (19)
By the way, a var_dump
shows:
array(5) {
["Primary"]=>
string(7) "Primary"
["Footer"]=>
string(6) "Footer"
["test"]=>
string(4) "test"
["hello"]=>
string(5) "hello"
["hello test"]=>
string(10) "hello test"
}
from smk-sidebar-generator.
@smartik89 can you provide any input to this issue?
from smk-sidebar-generator.
That's because Custom Metaboxes has a different array structure, shame for them.
This is how they define the options:
'options' => array(
array('name' => 'Option One', 'value' => 'standard'),
array('name' => 'Option Two', 'value' => 'custom'),
array('name' => 'Option Three', 'value' => 'none')
)
but Sidebar Generator return all sidebars in a standard array key=>value:
array(
"Default Sidebar" => "Default Sidebar",
"Sidebar Name" => "Sidebar Name",
"Sidebar Name 1" => "Sidebar Name 1",
"Sidebar Name 2" => "Sidebar Name 2"
)
Try this code, I haven't tested but hope it works. This is first what came in my mind(I know it can be better.):
$all_sidebars = SidebarGenerator::get_all_sidebars();
foreach ($all_sidebars as $key => $value) {
$my_sidebars_n[]['name'] = $key;
$my_sidebars_v[]['value'] = $value;
}
$my_sidebars = array();
if( isset($my_sidebars_n) && is_array($my_sidebars_n) && isset($my_sidebars_v) && is_array($my_sidebars_v) ) {
$my_sidebars = array_merge_recursive($my_sidebars_n, $my_sidebars_v);
}
from smk-sidebar-generator.
@smartik89 thanks for your help! I think your idea is close, but it produces this:
<select name="_sidebar" id="_sidebar">
<option value="">Primary</option>
<option value="">Footer</option>
<option value="">test</option>
<option value="">hello</option>
<option value="">hello test</option>
<option value="Primary"></option>
<option value="Footer"></option>
<option value="test"></option>
<option value="hello"></option>
<option value="hello test"></option>
</select>
It seems to not be placing the value and option together
from smk-sidebar-generator.
@teamcrisis , just to let you know. I'm working now to an update for this Sidebar Generator, it will be 2.0 and will have more options, you'll not have to worry anymore about custom metaboxes. To add suport for a page or post type, you'll have to call only a class with some arguments. BTW, I will write docs on how to use. It should be available very soon. It's about 80% ready. ;)
from smk-sidebar-generator.
If you want to propose something, have an idea, let me know here and I will see if it's poosible to add.
#7
from smk-sidebar-generator.
@smartik89 this is very good to hear. Thank you for making it better. As long as it's possible to integrate into https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress I will be happy. I'm already using custom metaboxes for various other page options and want to add an option to allow a user to select what sidebar they want to use on any particular page.
from smk-sidebar-generator.
@teamcrisis I'm going to implement a special metabox, so you don't need to create your or use a framework like this metioned by you. It will allow you to define how many sidebar a particular page support and besed on this it will display select boxes with all sidebars available. I think this is better. Anyways, be ready to test it yourself in the very soon.
from smk-sidebar-generator.
https://github.com/Smartik89/Wordpress-Sidebar-Generator/tree/2.0b 2.0 Beta is available. Working to the demo theme.
@teamcrisis, let me know if you test it.
from smk-sidebar-generator.
@smartik89 I have just tested it and so far I'm rather impressed. I think you did a very good job here. I still need to integrate into a theme before I can give more info, but two questions right now:
- Why did you make this a plugin? It seems it's rather useless if it's not integrated into a theme, right? And if it needs to be integrated into a theme, that makes it theme dependant and therefore a bit unless as a portable plugin, right? Maybe you have future plans with this that I'm not aware of?
- Could you work on some documentation and flesh out the demo theme a bit so I can get a bit better idea about how to use it?
Anyway, so far I like it. Good job!
from smk-sidebar-generator.
I made it as a plugin because this way is better. The user can choose to use it or not. Also, in case you want to use it in themes on themeforest, this is a requirement to include the functionallity in plugins. Job done. :)
I will make sure to escape all classes and functions, so it will be possible to include in themes if you don't want to use it as a plugin.
I will make a demo theme using a grid system to show how to add support for themes. And of course will write some docs.
I don't have too much free time, but I hope to finish all this soon.
from smk-sidebar-generator.
@smartik89 How exactly do I integrate into a theme?
When I try this:
smk_sidebar('');
It displays nothing.
But when I do this:
smk_sidebar('test2');
It displays the sidebar.
How do I display selection instead of explicitly set name?
from smk-sidebar-generator.
This version doesn't use the sidebar name, it uses the IDs. Previous version used names and this caused conflicts when the sidebar name has non-english characters.
Today I will upload the demo theme.
from smk-sidebar-generator.
@smartik89 ok, looking forward to it. I can get sidebars to display when using names and ids, but I can't figure out how to display the sidebar when I don't know the name or id ahead of time.
from smk-sidebar-generator.
@smartik89 any progress on the demo? I still can't figure out how to call the sidebar based on the user selection on the page metabox. It seems to only work when I hard code the sidebar name in the theme code. But doing that isn't dynamic based on the user selection then. Any help is appreciated.
from smk-sidebar-generator.
I think it's possible to display sidarbar for example adding code like this in sidebar.php template file:
ID, 'smk_sbg_1', true)); Info about sidebar of post(page) is in post meta data. One can view it in the database: FROM `wp_postmeta` WHERE post_id =post(page) number Relevant meta data are: 1096 1149 smk_sbg_align left 1097 1149 smk_sbg_1 smk_sidebar_3from smk-sidebar-generator.
I wonder how to apply align for sidebar to allow to display sidebar left, right or not to display at all.
from smk-sidebar-generator.
@smartik89 indeed <?php dynamic_sidebar(get_post_meta($post->ID, 'smk_sbg_1', true));
does what I need. Is this the best way to go about this? Any better alternative?
from smk-sidebar-generator.
As I said in another post metabox is not finished. The best for now is to get all sidebars in your metabox framework and then get the data like you do when you need a value of a metabox.
from smk-sidebar-generator.
Related Issues (20)
- How to get the sidebar to display when page is published HOT 3
- $page parameter in SMK_Sidebar_Metabox class
- change wp_enqueue source HOT 1
- Cannot add new sidebar after deleting all existing sidebars HOT 3
- Customizing widget output HOT 1
- Updated to 3.0 today and now sidebars don't work HOT 1
- Issue after installation HOT 1
- Fatal Error After Activating Plugin HOT 1
- Custom Post Type not work HOT 1
- Blank page when using on the latest version of wordpress HOT 7
- Sidebars disappear when clicking this combo
- Auto Generate Sidebar
- Categories
- Where are the docs? HOT 2
- Warning: Illegal string after a sidebar creed
- PHP 7.3 Error HOT 1
- [Bug] Single Post Conditions will always fail HOT 2
- [BUG] Term-Archive Sidebars not showing HOT 2
- PHP v8.x HOT 2
- Refactoring to a newer more robust generator HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smk-sidebar-generator.