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)
-   -   PHP Functions available in MZ specifcally Custom Fields and ShortCodes (http://forum.bytesforall.com/showthread.php?t=19504)

shocka Jan 29, 2013 03:48 PM

PHP Functions available in MZ specifcally Custom Fields and ShortCodes
 
Hey all,

Where can i find a list of the 60 or so PHP functions available in MZ virtual templates. I looking for a way to incorporate custom fields into the template.

Since get_post_meta I thought about creating a custom shortcode but do_shortcode is not available either. Imagine if we could use do_shortcode the functionality of this theme is just endless.

Any suggestions or help, other than creating a physical template, which is my last option here.

-Shocka

lmilesw Jan 29, 2013 03:55 PM

The codes are listed in the Limited PHP Codes drop down.

jerryc Jan 29, 2013 05:45 PM

Quote:

Originally Posted by shocka (Post 95737)
Where can i find a list of the 60 or so PHP functions available in MZ virtual templates.

Dashboard > Appearance > MZ options > gray dropdown tab at upper right

Quote:

I looking for a way to incorporate custom fields into the template.
Check this post.

Quote:

Since get_post_meta I thought about creating a custom shortcode but do_shortcode is not available either. Imagine if we could use do_shortcode the functionality of this theme is just endless.
I was thinking that a php shortcode plugin might work, too, but I haven't explored that. If you find a good one that works, please post it. Like you say, with php shortcode, the possibilities for this theme become even more amazing.

shocka Jan 29, 2013 06:34 PM

Thanks Larry and Jerry - i cannot believe I missed that drop down!

Jerry - I tried the widget idea but with the widget styling it threw everything off. Maybe there is an idea here I am missing? Perhaps you can setup variables in the widget so it never outputs anything and use those variables with printf? Just a thought but seems messy with useless HTML being outputted.

As for the shortcodes I use http://wordpress.org/extend/plugins/shortcode-exec-php/ and prefer to use this method for PHP code since all my PHP sits in one spot. Right now I am thinking of using a physical template with shortcodes.

jerryc Jan 29, 2013 07:09 PM

Any PHP Anywhere Update
 
This Has Been Tested and It Does Wonders

This technique takes the Any PHP Anywhere concept to a whole new level.

Update: With this technique, you can use php in posts and pages, outside of sidebars.

Update: Here's an example of conditional widgets.

Quote:

Originally Posted by shocka (Post 95747)
Jerry - I tried the widget idea but with the widget styling it threw everything off. Maybe there is an idea here I am missing?

You can add custom css and override the widget css to look however you want.

Quote:

Perhaps you can setup variables in the widget so it never outputs anything and use those variables with printf? Just a thought but seems messy with useless HTML being outputted.
Here's what worked for me, using php in widgets (which can be anywhere) and snippets. The widget has a function call:

HTML Code:

<echo custom_fill_widget();>
This calls a function declared in a snippet:

PHP Code:

function custom_fill_widget()
{
ob_start(); // keep the_title() from being echoed to screen
the_title();
$title ob_get_clean();    // make value of the_title() into a variable, clean and stop buffer

if ($title == "Home")
$html "home page html code and text...";

elseif (
$title == "About")
$html "about page html code and text...";

else
$html "default html code and text...";

return 
$html;


There are probably more elegant ways of doing this. I only do pretty simple procedural coding. If I were really doing a lot of this, I'd probably use arrays.

Other things besides the page title could be used as conditions. For example, a restaurant could post the soup of the day in a widget with code such as:

PHP Code:

if (date("D") == "Mon")
$soup "Chicken Noodle";

elseif (
date("D") == "Tue")
$soup "Beef Barley";

...

return 
$soup

If you use any of the limited mz php code that outputs text as a condition, such as the_title() in the example, use output buffering. Otherwise, the output will be echoed when you test the condition, probably where you don't want it to appear.

Also, instead of just being, essentially, a string table, this function could call other functions, or even include files.

As far as a little extra html and css to use the widgets, my take on that is that WP outputs so much more bloat code than we would if we were writing code from scratch in notepad or something. So, what's a few more grains of sand on the beach? As long as whatever it outputs is consistent, we can style it so it looks fine to the user.

Quote:

As for the shortcodes I use http://wordpress.org/extend/plugins/shortcode-exec-php/
The shortcode didn't seem to have the continuity of being able to reuse code from one to another like the snippets. With snippets, all the code is activated and accessible. Maybe I'm just used to it.

I couldn't get other things to work like I wanted in pages or templates (outside of sidebars.) I tried the ezphp plugin and even tried filtering (although I haven't tried filtering with output buffering yet), but they didn't work like I wanted, either.

Remember, you can even make your entire content area a sidebar if you needed to. I've tried it, and it works. A sidebar can also replace the footer or the header.

Quote:

and prefer to use this method for PHP code since all my PHP sits in one spot.
That's why I like the snippet plugin, and I like the same concept for custom css.

Quote:

Right now I am thinking of using a physical template with shortcodes.
With that plugin, can you put the shortcode into the virtual templates?


Please post your results. Thanks.


All times are GMT -6. The time now is 12:43 PM.

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