Jump to content

Plugin Hook for Settings


Yarnell

Recommended Posts

First, be aware that the implementation of HOOK_TAB_CONTENT and PLUGIN_TABS is not consistent (yet). See:

https://github.com/cubecart/v6/issues/3254

Working specifically with the Store Settings in admin, the skin template 'settings.index.php' has only the HOOK_TAB_CONTENT capability. That means additional content is brought in using separate template HTML files (Smarty code is allowed), by specifying the filepath, that are located elsewhere - typically in a 'plugin' extension folder, but can be located anywhere PHP can access.

Note that HOOK_TAB_CONTENT typically contains the content of sections of the page (inclusive of the <div> tags), all sections being hidden except for the 'active' section. But, for Store Settings, the place in that template where the 'element.hook_form_content.php' sub-template gets included (in turn, includes HOOK_TAB_CONTENT) means additional HTML can be inserted into the template that is visible at all times, that is, not a hidden <div class="tab_content"> block. In the admin /source/ file 'settings.index.inc.php',  at the end, is the statement that sends the array of filepaths to the template structure.

Adding a new hidden section of content will then need an admin tab to control its visibility. Together, that is accomplished by:

For a simple example:

In your custom code:
$GLOBALS['smarty']->assign('FOO_TAB_CONTENT_TITLE',"Foo!");
$GLOBALS['main']->addTabControl("Foo", "tab_content's id attribute: foo");
// Can be located anywhere PHP can access, but needs the 'file:' prefix
$GLOBALS['hook_tab_content']=array_push('file:'.CC_ROOT_DIR.'/modules/plugins/My_Plugin/skin/div_sections/section_foo.tpl');

In the file 'section_foo.tpl':
<div id="foo" class="tab_content">
  <h3>{$FOO_TAB_CONTENT_TITLE}</h3>
  <fieldset>
    <div><span><textarea name="config[foo_data]" id="foo_content" class="textbox">{$CONFIG.foo_data}</textarea></span></div>
  </fieldset>
</div>

These PHP statements will be part of the PHP code that creates the tab content's computed data to show. The PHP code that creates and assigns this data to the associated template generally is executed via a triggered hook (code snippet).

Note: there are no hookloaders directly associated with Store Settings. However, all form elements having the name 'config[]' in Store Settings are saved in the overall 'config' array.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...