Forum has moved to another host, some things may be broken or shaky for a little while
Wordpress Themes - WP Forum at BFA
Click Here To DONATE! Support the theme development, get more attention and additional benefits based on your donation level. Your forum name will be highlighted.

Wordpress Themes - WP Forum at BFA » WordPress Themes » Montezuma Theme »

PHP Functions available in MZ specifcally Custom Fields and ShortCodes


Build custom WP THEMES, without
coding.
Click here for THEMEFRAME

From the author of Atahualpa, the #1 most
downloaded (700,000+) theme @ wordpress.org
  #1  
Old Jan 29, 2013, 03:48 PM
shocka
 
11 posts · May 2009
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
  #2  
Old Jan 29, 2013, 03:55 PM
lmilesw's Avatar
lmilesw
 
10,080 posts · Jul 2009
Central New York State USA
The codes are listed in the Limited PHP Codes drop down.
__________________
~Larry (CNY Web Designs)
This site should be a membership site since it so full of good stuff.
Please consider donating which gives you access to even more good stuff.
  #3  
Old Jan 29, 2013, 05:45 PM
jerryc
 
367 posts · Oct 2012
Florida
Quote:
Originally Posted by shocka
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.
  #4  
Old Jan 29, 2013, 06:34 PM
shocka
 
11 posts · May 2009
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.
  #5  
Old Jan 29, 2013, 07:09 PM
jerryc
 
367 posts · Oct 2012
Florida
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
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.

Last edited by jerryc; Mar 22, 2013 at 03:02 PM. Reason: Better Coding

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Suggestion: Use the WordPress core functions for custom header images Knut Sparhell Atahualpa 3 Wordpress theme 0 Nov 3, 2011 07:14 PM
custom shortcodes css styling help needed kirks Atahualpa 3 Wordpress theme 1 Mar 13, 2011 10:06 PM
preset bfa custom fields (bfa_ata_option meta fields) Douglas Center area post/pages 2 Jan 3, 2011 04:36 PM
Need help with custom fields. webservant7 Center area post/pages 1 Feb 20, 2010 02:43 PM
Best location for custom hook functions twola Plugins & Atahualpa 0 Oct 10, 2009 07:39 PM


All times are GMT -6. The time now is 05:26 AM.


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