Updated Answer:
After your explanations I see what you are after.
Indeed you can do this during the installation of your module. Since the module is intented for the backend and you only going to need 1 instance of it, setting the module chrome during the installation does make some sense.
In your module's install.php
you can update the module that is created during installation with a postflight
function:
function postflight($type, $parent)
{
// check if it's the first time the module is installed.
if($type == 'install')
{
$db = JFactory::getDBO();
$module_name = 'your_module_name';
// get module id that is created during installation
$query = 'SELECT `id`' .
' FROM `#__modules`' .
' WHERE module = ' . $db->quote($module_name);
$db->setQuery($query);
try
{
$moduleid = $db->loadResult();
}
catch (Exception $e)
{
$moduleid = '';
}
// Do we have a module?
if (!empty($moduleid) )
{
// Get Modules' JTable
$module = JTable::getInstance('module');
// Load the module instance by id
$module->load($moduleid);
$params = array(
'style' => 'System-none',
'cache' => 0
);
// Set Module's properties
$module->set('title', (string) 'This is my title');
$module->set('position', (string) 'New Position');
$module->set('params', json_encode($params));
// Store in the database
$module->store();
}
}
}
Here you can find more info about including an installation script with your module:
Creating Simple Module/ Adding Install-unintall-update script.
Initial Answer:
As said in my comment above, it's not clear what you are asking or your actual problem is. So I am going to make a guess that you have developed a module for which you would prefer to not showing anything around it when it's installed and set to show on a module position, so you are looking for a piece of code inside your module, that would somehow do this? (is this what you are talking about ???).
Module Chrome though, isn't something that is controlled on the module level, rather than it is a Template Feature. It defines a "layout"/html markup of a module position on a template, it happens outside of the module and it's not something that any module instance knows anything about it or care. Module Chrome isn't something that a module developer would have to think.
Programatically, it can be set to a default choice, for each module position, but this is done by the template when module positions are defined in it.
This is how it's done:
<jdoc:include type="modules" name="position-1" style="none" />
<jdoc:include type="modules" name="position-2" style="xhtml" />
Something that of course can be overriden by the end-user when creating and assigning any module on any position.
cpanel
position. Ideally I would like to setcpanel
as the position and module chrome tonone
automatically. I've never seen a module appear with a module position, but I assume there is a way to do this. Perhaps in the post processing part of install?