- This topic has 5 replies, 3 voices, and was last updated 7 years, 12 months ago by
Jason.
-
AuthorPosts
-
-
February 11, 2014 at 5:13 pm #1368
JasonKeymasterI’m trying to wrap my mind around how the post-relate metabox type works.. and I’m lost on this line:
template => 'field'The documentation says it “Renders the ‘field’, field template”… What?
Can someone please shed some light on this? What’s a field template?
Thanks!
-
February 12, 2014 at 3:21 am #1370
MarcusMemberIt’s the html structure for laying out a particular type of field.
If you look in the demo code, there are a couple of instantiations creating a couple of field templates.So in practice, if you wanted to have a field layout almost identical to how piklist normally does it, but you want to set the class field higher in the dom, or if you wanted the ID to reflect the class name you set while creating the piklist field, you could copy a piklist template and change it how you wanted.
Here’s one from the demo:
$templates['theme_tight'] = '[field_wrapper] <div id="%1$s" class="%2$s piklist-field-container"> [field_label] <div class="piklist-field"> [field] [field_description_wrapper] <span class="piklist-field-description">[field_description]</span> [/field_description_wrapper] </div> </div> [/field_wrapper]';Marcus <– used to be a teacher, its worse than addiction. 🙂
-
February 12, 2014 at 3:36 am #1371
KevinKeymasterJason-
Marcus is right, the template field is a way to apply a template at the field level. One of my favorite things about fields in Piklist is that you are never forced to use the html that wraps your field, you can change and even create your own templates and apply them on a field by field basis or globally. You can see this working in the demos, while we have the same fields in various areas they are rendered in different ways.
We are posting more documentation on this feature and the core piklist function tomorrow, more to come then.
Thanks
Kevin
-
February 12, 2014 at 11:35 am #1378
JasonKeymasterGood stuff! I like the concept! Are templates documented anywhere, yet? It seems pretty straightforward, as a template is html with piklist shortcodes embedded into it, but it’d be great to really understand what each one does.
So where is the “field” template defined? I see ‘piklist_demo’ and ‘theme_tight’ defined, but not ‘field’.
Lastly, why use post-relate versus just doing a get_posts similar to the taxonomy example? What’s the internal benefit of using the post-relate method?
Thanks Marcus, Kevin!
-
February 12, 2014 at 9:30 pm #1389
KevinKeymasterJason-
Thanks, we are currently documenting it in more detail and it will be out shortly. In the meantime you can see the core templates for the system defined at the top of piklist/includes/class-piklist-form.php
As for post relate, its a little different. We actually have a table that we add to the database to allow us to relate posts and also to search based on whether it is a “has” or “belongs” relationship. In the coming weeks this will make more sense as we release some of the extensions we are wrapping up for related objects (hint;)
-
February 13, 2014 at 10:08 am #1394
JasonKeymasterKevin,
Thanks for the heads up! Sounds exciting! I will confess, as I’m sure you know, that as much as I like Piklist.. the documentation does leave a bit to be desired. It reads more like code comments to the devs, at times, rather than overview/specs/examples for the newcomer.
If the docs were in a wiki I’d definitely be interested in helping as I become more familiar. I come from a RAD background, so I’m thoroughly enjoying this framework.
-
-
AuthorPosts
- You must be logged in to reply to this topic.