Override module xml
Moderator: General Support Moderators
Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
-
- Joomla! Apprentice
- Posts: 7
- Joined: Sun Oct 02, 2011 1:28 pm
Override module xml
Is there anyway to overrride a default module xml file?
I want to add some custom fields to mod_articles_news, but to avoid messing with the core I'd ideally like to store my customised mod_articles_news.xml within my template directory.
I tried storing it at the following location, but it doesn't appear to work:
templates/mytemplate/html/mod_articles_news/mod_articles_news.xml
Any pointers would be very helpful!
thanks
I want to add some custom fields to mod_articles_news, but to avoid messing with the core I'd ideally like to store my customised mod_articles_news.xml within my template directory.
I tried storing it at the following location, but it doesn't appear to work:
templates/mytemplate/html/mod_articles_news/mod_articles_news.xml
Any pointers would be very helpful!
thanks
Last edited by toivo on Thu Dec 13, 2018 3:18 pm, edited 1 time in total.
Reason: mod note: locked topic on request
Reason: mod note: locked topic on request
-
- Joomla! Apprentice
- Posts: 33
- Joined: Sat Oct 03, 2009 8:22 pm
Re: Override module xml
I broke my head over this question, but it seems it's not possible to override the xml.
I bypassed the problem cloning the module (mod_custom in my case): I'm quite satisfied with this solution, even if the procedure is a bit complicated and I have to pay attention to joomla upgrades.
if you are interested I can give you the procedure I followed.
bye
ruggero
I bypassed the problem cloning the module (mod_custom in my case): I'm quite satisfied with this solution, even if the procedure is a bit complicated and I have to pay attention to joomla upgrades.
if you are interested I can give you the procedure I followed.
bye
ruggero
-
- Joomla! Apprentice
- Posts: 7
- Joined: Sun Oct 02, 2011 1:28 pm
Re: Override module xml
Thanks ruggero - I ended up doing the same
-
- Joomla! Ace
- Posts: 1460
- Joined: Sat Jan 21, 2006 8:42 pm
Re: Override module xml
This is sadly the only solution for this, what is a pain when you need an extra field to more than one module
-
- Joomla! Apprentice
- Posts: 33
- Joined: Sat Oct 03, 2009 8:22 pm
Re: Override module xml
yes it is! as regards mod_custom, the only arrangement is to create a custom module with many parameters, all that you think you may need in future, and then override it time by time. in Italy we say (literal translation): "in the more stays the less".
- jackrabbit
- Joomla! Ace
- Posts: 1473
- Joined: Thu May 21, 2009 3:12 am
- Location: Florida
- Contact:
Re: Override mod_footer.xml
Just wanted to revive this topic in search of a solution to dynamically add fields to a specific module xml. Specifically add pretext and posttext textarea fields to collect content for frontend display in mod_footer.
I created a plugin which does what I need but does so for every installed module and I only want to target the mod_footer.
This is the plugin
Then to add textarea fields, the fieldlist.xml file included in the plugin directory is
What can I add to the function to make this add the fields only to mod_footer?
I created a plugin which does what I need but does so for every installed module and I only want to target the mod_footer.
This is the plugin
Code: Select all
jimport('joomla.plugin.plugin');
jimport('joomla.html.parameter');
jimport( 'joomla.form.form' );
class plgSystemAdd_Xml_Fields extends JPlugin {
var $_params;
var $_pluginPath;
public function __construct($subject, $config) {
parent::__construct($subject, $config);
$this->_plugin = JPluginHelper::getPlugin('system', 'add_xml_fields');
$this->_params = new JParameter($this->_plugin->params);
}
public function onContentPrepareForm($form, $data) {
if ($form->getName()=='com_advancedmodules.module' || $form->getName()=='com_modules.module') {
JForm::addFormPath(JPATH_PLUGINS.'/system/add_xml_fields/');
$form->loadFile('fieldlist', false);
}
}
}
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="params">
<fieldset name="advanced">
<field type="spacer" hr="true" />
<field name="pretext" type="textarea" default="" cols="40" rows="5" label="Pre Text" filter="raw" description="Text before" />
<field name="posttext" type="textarea" default="" cols="40" rows="5" label="Post Text" filter="raw" description="Text after" />
</fieldset>
</fields>
</form>
Reset Joomla super user password and username simply | http://cmsenergizer.com/website-energy- ... d-remotely
- jackrabbit
- Joomla! Ace
- Posts: 1473
- Joined: Thu May 21, 2009 3:12 am
- Location: Florida
- Contact:
Re: Override module xml
Does anyone have any idea how to isolate a module for field insertion? The fields shown in the image appear in all modules but I want the post and pretext to be assigned to just mod_footer
You do not have the required permissions to view the files attached to this post.
Reset Joomla super user password and username simply | http://cmsenergizer.com/website-energy- ... d-remotely
-
- Joomla! Fledgling
- Posts: 4
- Joined: Fri Jul 23, 2010 6:41 am
Re: Override module xml
I was solved this:jackrabbit wrote:Does anyone have any idea how to isolate a module for field insertion? The fields shown in the image appear in all modules but I want the post and pretext to be assigned to just mod_footer added-fields.jpg
In my case I put in XML option to choose the modules, the xml file names and the custom location of the XML
Code: Select all
<fields name="params">
<fieldset name="basic">
<field name="themodules" type="text" label="MODULES" description="MODULES_DESC" default="mod_articles_latest" />
<field name="filenames" type="text" label="FILES" description="FILES_DESC" default="" />
<field name="thepath" type="list" label="PATH" description="PATH_DESC" default="plugins">
<option value="plugins">PLUGINS</option>
<option value="template_override">TEMPLATE_OVERRIDE</option>
</field>
</fieldset>
</fields>
Code: Select all
jimport('joomla.plugin.plugin');
jimport('joomla.html.parameter');
jimport('joomla.form.form');
class plgSystemAdd_xml_fields extends JPlugin
{
var $_params;
var $_pluginPath;
public function _construct($subject, $config)
{
parent::_construct($subject, $config);
$this->plugin = JPluginHelper::getPlugin('system', 'add_xml_fields');
$this->params = new JParameter($this->plugin->params);
}
public function onContentPrepareForm($form, $data)
{
$app = JFactory::getApplication();
$pieces = explode(",", $this->params->get('filenames'));
$themodules = explode(",", $this->params->get('themodules'));
if ((($form->getName() == 'com_advancedmodules.module') || $form->getName() == 'com_modules.module')) {
if ($this->params->get('thepath') == 'plugins') {
JForm::addFormPath(JPATH_PLUGINS . '/system/add_xml_fields/');
}
if ($this->params->get('thepath') == 'template_override') {
foreach ($themodules as $key => $themodule) {
if ($data->module == $themodule) {
$db = JFactory::getDBO();
$query = "SELECT template FROM #__template_styles WHERE client_id = 0 AND home = 1";
$db->setQuery($query);
$defaultemplate = $db->loadResult();
JForm::addFormPath(JPATH_SITE . '/templates/' . $defaultemplate . '/html/' . $themodule . '/');
}
}
}
foreach ($themodules as $key => $themodule) {
if ($data->module == $themodule) {
foreach ($pieces as $k => $piece) {
$form->loadFile($pieces[$key], false);
}
}
}
}
}
In my case, each module name separated by commas loads the respective xml file name separated by commas. On by One.
But, now I have a new problem. The module is not saving the params in the database.
Please, someone, have a solution.