From 3401a46992dae122fb9e35d51e1147559865e872 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 2 May 2013 16:57:32 -0700 Subject: [PATCH] Shortcode Wrappers etc. --- Preparing-your-v1.x-plugins-for-v2.x.md | 39 ++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/Preparing-your-v1.x-plugins-for-v2.x.md b/Preparing-your-v1.x-plugins-for-v2.x.md index 577bc65..742bd65 100644 --- a/Preparing-your-v1.x-plugins-for-v2.x.md +++ b/Preparing-your-v1.x-plugins-for-v2.x.md @@ -10,15 +10,52 @@ As a quick reference: * Html `` which use the class 'fcaption' on `
`, change the `` to ``. Using the `forumheader3` in the *admin area* is obsolete and can be removed. ### Templates +#### Loading Templates e107 v2.x uses a new template loading system. Plugin templates should be stored in **e107_plugins/yourplugin/templates/** by default. -The template file should contain a variable with the same name as your template file. +The template file should contain a variable with the same name as your template file. +Instead of including the template, below is the difference: + + require_once(e_PLUGIN."myplugin/templates/myplugin_template.php"); // v1.x + $MYPLUGIN_TEMPLATE = e107::getTemplate('myplugin'); // v2.x + +..and then you can parse it the same way: + + $text = $tp->parseTemplate($MYPLUGIN_TEMPLATE['start'], false, $my_shortcodes); + + +#### Declaring the HTML Template eg. If your file is called **myplugin_template.php** , within this file you might see something like this: $MYPLUGIN_TEMPLATE['start'] = "
"; $MYPLUGIN_TEMPLATE['end'] = "
"; +#### Shortcode Wrappers. + +In v1.x you might create a wrapper around a shortcode (only when there is data returned) using the following code in your template: + + $sc_style['CONTACT_PERSON']['pre'] = "".LANCONTACT_14."
"; + $sc_style['CONTACT_PERSON']['post'] = "
"; + +In v2.x there are two methods to add wrappers around your shortcodes. +The way to declare them differs slightly from v1 in that we use a kind of 'shortcode-wildcard' `{---}`. + +##### Global Shortcodes + +A global shortcode wrapper. ie for shortcodes which are available site-wide. (for example those registered globally for use in menus or found in e107_core/shortcodes/single/) + example: + + $SC_WRAPPER['CONTACT_PERSON']= "".LANCONTACT_14."
{---}
"; + +##### Template-Specific Shortcodes + +A template-specific shortcode wrapper. ie. as used on a single page of your site. +example: + + $CONTACT_WRAPPER['form']['CONTACT_PERSON'] = "".LANCONTACT_14."
{---}
"; + + ## Admin-Area The admin area of v2.x uses a special new admin handler (admin-ui).