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

Pods Template Conditionals #3191

Open PodsBot opened 8 years ago

PodsBot commented 8 years ago

Discussion on replacing current Template Tags [if][else][/if], etc. with a non-shortcode style and adding Comparison operators to the if conditionals. Add additional items to include in this feature as we find them. Also close and reference any other issues that are similar to this request here.

Basic operators

Conditionals:

Comparison operators (numeric or compare another field): http://php.net/manual/en/language.operators.comparison.php

Logical Operators (with no nesting support): http://php.net/manual/en/language.operators.logical.php

Additional things to be figured out:

Special tags to add into field():

sc0ttkclark commented 8 years ago

Follow-up, see what Metaplate can do with it's templating, how much of this can it do?

https://calderawp.com/downloads/caldera-metaplate/

codente commented 8 years ago

+1

oldrup commented 7 years ago

Those comparison operators would be very useful when creating pods templates. +1

jimtrue commented 6 years ago

This format and design sounds more like Twig/Timber Templating support: https://www.upstatement.com/timber/

GaryJones commented 6 years ago

This format and design sounds more like Twig/Timber Templating support: upstatement.com/timber

Agreed.

One extreme option, if BC is going to break anyway, would be to pull Timber in as a dependency, and just pass the Pods Template content through Timber::render() (or whatever is needed) instead. Twig is far more established as a templating language than the Pods Template language, and may also ease adoption.

Maybe allow Pods Templates to choose which templating engine it should use, so that existing sites aren't forced to update the contents of their templates, and could switch over templates one at a time when they wanted to make use of the more advanced features?

jimtrue commented 6 years ago

@GaryJones Great idea! We would definitely want to put a "freeze" on the current iteration of Template Language handling and provide the Timber as a smoother transition path with better handling for loops and conditionals for those people that still don't want to use PHP.

The setting could either be at a Pods Admin, Settings level or on a template by template basis possibly.

Do you know if the CodeMirror library we currently use has 'code assist and syntax highlighting' for Twig/Timber templating?

quasel commented 6 years ago

Anything that improves the Templates would be great - important thing to keep in mind is that the template/magic tag stuff is used in shortcodes - and one other thing - how does Gutenberg play into all of it - https://wordpress.org/gutenberg/handbook/templates/ ?

GaryJones commented 6 years ago

Do you know if the CodeMirror library we currently use has 'code assist and syntax highlighting' for Twig/Timber templating?

I assume it's this: https://codemirror.net/mode/twig/. I'm not sure if Timber adds any more Twig-like syntax on top, which may miss the syntax highlighting.

Related reading: https://notlaura.com/the-twig-for-timber-cheatsheet/ by @laras126 who I recently met at WCEU and who may know the answer to the above :-)

jimtrue commented 6 years ago

Templates in Gutenberg are basically pre-configured 'content blocks'. Our implementation of Templates, whether Auto Templates are placed by Shortcodes would be identical. Improvements on the process would be to identify Pods Templates based on Post Type and providing them as Template blocks to drop based on Content Type.

fivehead commented 5 years ago

+1 for this functionality.

abednaseri commented 3 years ago

+1