pods-framework / pods

The Pods Framework is a Content Development Framework for WordPress - It lets you create and extend content types that can be used for any project. Add fields of various types we've built in, or add your own with custom inputs, you have total control.
https://pods.io/
GNU General Public License v2.0
1.07k stars 264 forks source link

Advanced template builder component #921

Closed DavidCramer closed 6 years ago

DavidCramer commented 11 years ago

I have pushed my first component. Its a prototype, so please be kind. Am still new to Pods, so things wont be perfect until I learn more about the Pods API. There are comments explaining its use and purpose in the main Advanced-Templates.php file.

It's set to Developer Mode: on for previewing.

pglewis commented 11 years ago

Toys! I'll definitely be looking at this, a nice feature set for sure.

sc0ttkclark commented 11 years ago

How do you call PHP blocks from the HTML tab?

DavidCramer commented 11 years ago

The PHP codebox is for custom functions you want to use in your template. So define a function as you normally would, then in the html, you can call the custom function as normal by wrapping in <?PHP ?>

sc0ttkclark commented 11 years ago

Any way we can simplify that to something like %%function_name:arg1|arg2|arg3|arg4%% or similar? So it'd be limited to calling functions like that? Would just like to limit usage of eval() and provide an alternative if someone wants to disable the PHP tab altogether.

DavidCramer commented 11 years ago

Agreed. If you click the help button, you'll see a few code tags I've already put in to simplify coding. Though not all implemented yet.

sc0ttkclark commented 11 years ago

I have to say, this really blew Phil and me away, you did an awesome job on this and the UI.

DavidCramer commented 11 years ago

Wow, thanks. I'll refine the code more as I work it, it's mostly guess work while learning pods API. I'll probably get back on it tomorrow when I get back to work.

sc0ttkclark commented 11 years ago

For the slug field, try using echo PodsForm::field( 'field_name', $value, 'slug' ); and that will output a slug field, which enforces specific characters like spaces to be converted to dash. For the underscore equivalent, try echo PodsForm::field( 'field_name', $value, 'db' );

DavidCramer commented 11 years ago

Sweet thanks. I'll take a look. I still have a lot of work to do.

pglewis commented 11 years ago

Yeah, I was pretty much gushing over the utility of this in chat last night. As a temporary real-world example, I setup a FAQ list:

http://pods2.sundco.com/advanced-template-faq-list/

Implemented entirely with a simple pod, a single advanced template, and the WP page itself.

You can set it up in minutes and all the related pieces for the implementation are stored and saved together (also handy for maintenance IMO, when you come back to it a year or more later).

Sure, there are edges to smooth out, but this is immediately useful. It's like Pods swallowed jsfiddle.

pglewis commented 11 years ago

One quick question, is there a way to set dependencies by handle? I usually already have jQuery queued on sites and it's just a matter of setting the dependency in my enqueue_script(). To get things working I just shotgunned it and created a library entry pointing to a CDN copy.

DavidCramer commented 11 years ago

Wow, I'm glad you're finding it worthy. and yes jsfiddle may have inspired me a little. Just wait till I get the live preview working :) I'm going to add dependencies to the libraries. For now though you can drag the order around for a rudimentary way.