Support Forum

Plugin template Tags & Layout

BR Brandon
Brandon
Member

I was looking at the Plugin area and Template tags area to see how to add in the Plugin template tag info.

In Plugin Development > Template Tags.
I already started entering some info. Basically what they are, how they work and minimal info on each indivual one.

From there I would link each tag to the detailed info on it and how it works.

So basically it could go

Plugin Development > (child) Template Tags > (child) ThisParticularTag

But there is also a Plugin Development > (child) Template Files setup. I assume this page would be a list of the available plugin tags. Is the Template Files page needed if done like shown above or would you rather me go at it a different way?

You can see my saved draft revision of the Template Tags page and get an idea of what I was thinking.        

3 Answers

New Answer

MP Mr Papa
Mr Papa
Member

I think you are confusing template tags and template files…

template tags are the functions within the plugin that can be called to make things happen, ie display a button or something…

template files are really theme files for the plugin…  It dictates how to display a page for that plugin…  for example, private messaging stuff is displayed on its own page and url…  sp core has no way of knowing how to display the page for private messaging…  so the plugin provides a template file for the theme to know how to display the plugin special page…

if you look in a theme, you will see a templates directory… contains things like spHead, spFoot, spTopicView, etc…  the template files for plugins are additional theme templates…  not all plugins will need a template file – only ones that display a page outside of the normal sp core defined template files…

now, something else you need to know if you move down this path…  each plugin can provide a css file for styling its output and a template file for special page display…  if coded correctly (all of ours do this), the plugin first checks the theme directory for the css file or the template file…  if it finds it there, it uses that file…  If it does not find it, then it loads the css file or template file provided by the plugin…  this allows theme authors to provide custom/matching styles/templates for plugins…  by default plugins can only provide one css and one template file so it is not likely to match the theme in a perfect way… 

hope that is clear…  and I know I didnt answer the rest of your question… wink

probably need to see what you actually did in the draft…  but one comment…

we want to keep all template tags and probably any function (such as api calls) consistent throughout the codex…  I have already done one api function call the way I envisioned as an example…  you can see it at:

http://codex.simple-press.com/codex/simplepress-api/functions/sp_get_auth/

now I posted that back a while ago looking for feedback (can see it in this forum) but didnt receive any wink

So now would be a good time for anyone to chime in on the format I used and recommend any improvements…

BR Brandon
Brandon
Member

I think I got what you are saying. But a template file such as spHead, spFoot, spTopicView are not just for plugins but some plugins rely on them.

So in the Plugin Development > (child) Template Files is where it could be explained how they tie together and maybe how to create your own.

I like how you did the get_auth post. I will use that as an example for the plugin functions.

MP Mr Papa
Mr Papa
Member

plugins cant really rely on template files except their own… we tend to define standard ones in sp core, but a user does not have to use them when creating a theme… they could simply do it all in one or more files and just code in php and ignore the stuff we have set up… power of themes…

yes as to where to discuss… because if a plugin creates a new page, again use pm inbox as example, and does not provide a template file it, it will use the default template file… if that doesnt exist you will get a template file not found error…

might be nice to develop a template hierarchy drawing too… wp has one

http://codex.wordpress.org/Template_Hierarchy

and a new updated one though not signed off by wp yet…

http://www.chipbennett.net/themes/template-hierarchy/