Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Montezuma Theme (http://forum.bytesforall.com/forumdisplay.php?f=53)
-   -   Correct way to create sidebars? (http://forum.bytesforall.com/showthread.php?t=19535)

Michael4fm Feb 2, 2013 07:02 AM

Correct way to create sidebars?
 
The 'automatic' sidebar creation in Montezuma is great, but is there a 'right' way to do it consistantly? I'm using a lot of physical templates and they don't seem to automatically create the sidebars they need.

I'm currently getting around the challenge by 'creating' them in one of the virtual comments subtemplates, which I'm not actually using. Works fine, but if there's a 'proper' way, I should probably be doing that!

[If there isn't, could I suggest that my 'hack' would seem to be easy to incorporate as a 'proper' feature at a later date?]

lmilesw Feb 2, 2013 08:13 AM

What do you mean by "automatic sidebar creation"?

Michael4fm Feb 2, 2013 08:30 AM

When you use <?php dynamic_sidebar( '...name...' ); ?> in a virtual template, it automatically creates a widget area called "...name..." that you can view through Appearance | Widgets and add widgets to.

jerryc Feb 2, 2013 09:07 AM

Quote:

Originally Posted by Michael4fm (Post 95946)
When you use <?php dynamic_sidebar( '...name...' ); ?> in a virtual template, it automatically creates a widget area called "...name..." that you can view through Appearance | Widgets and add widgets to.

That sounds like the right way to me. I don't use and wouldn't recommend physical templates, but ymmv.

Michael4fm Feb 2, 2013 09:18 AM

Yeah, but if you use <?php dynamic_sidebar( '...name...' ); ?> in a physical template, they don't get created - so at the moment I'm creating them by adding a 'phantom' entry in one of the comments.php sub-template which I don't use. I'm sure that wouldn't be the 'right' way to do it, so was wondering if there is a 'proper' way I should ... or given that it seems so easy to do, suggesting as a feature that another entry in one of the sub-templates (possibly "comments" as it already works there and the template is already "bits of") be added to allow for sidebar creation.

lmilesw Feb 2, 2013 09:29 AM

I am really confused as to what you are trying to do. For instance you talk about creating a phantom entry in a comment.php sub template. Why are you not just adding the code for the new widget area to index.php for instance?

jerryc Feb 2, 2013 09:40 AM

Quote:

Originally Posted by Michael4fm (Post 95948)
... suggesting as a feature that another entry in one of the sub-templates ... be added to allow for sidebar creation.

It might be a nice feature. Until it's added, I think you have found the only workable way, without more extreme code hacking.

With the approach your'e taking, you could have an unused virtual template with unlimited sidebars, any of which could then be used in any other template(s).

Bear in mind, if you're using physical templates, if you use existing names, such as index.php, your edits will get clobbered with a theme upgrade. This doesn't happen with virtual templates.

Michael4fm Feb 2, 2013 09:52 AM

Sorry to confuse.

Creating a sidebar only works (or seems to) when you are using virtual templates. If you are using physical templates the sidebar doesn't get created. I'm therefore creating the sidebar in one of the virtual comments.php areas which I never use ... then it's there when I use the dynamic sidebar code in my physical templates.

It works .. I just wondered if there was a better / 'proper' way to do it, and was suggesting that as it works and it seems fairly easy, it might be worth considering it as a feature to add to future releases.

lmilesw Feb 2, 2013 10:30 AM

Then the question is why are you creating physical templates? As JerryC mentioned those will get overwritten with a theme upgrade.

Michael4fm Feb 2, 2013 10:46 AM

I need to use php and shortcodes which don't work in virtual templates.

Will they get overwritten? I thought physical templates, stored in ".../wp-content/themes/montezuma" were safe? Not a biggie if that's not the case, as I have copies locally I can just FTP again.

lmilesw Feb 2, 2013 01:53 PM

I believe they will get overwritten. Even if they don't I always work within theme constraints. If I wanted to include PHP I would add a widget area and use a widget that allows PHP.

jerryc Feb 2, 2013 02:01 PM

Quote:

Originally Posted by lmilesw (Post 95959)
I believe they will get overwritten. Even if they don't I always work within theme constraints. If I wanted to include PHP I would add a widget area and use a widget that allows PHP.

I agree with Larry. Have you tried this technique? It works with virtual templates.

One thing I like about snippets better than shortcodes is that every function is available to every other function. So are variables that you declare as globals (if, hopefully, your server allows them).


All times are GMT -6. The time now is 02:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.