The addrulepath and addfield path missing from menu parameter xml #169

Closed
opened 2017-11-04 07:29:42 +00:00 by kevincam3 · 7 comments
kevincam3 commented 2017-11-04 07:29:42 +00:00 (Migrated from github.com)

So I manually added the validate attribute to my xml file and added my custom rule to the rule folder and it works fine for the config options and the view, but it breaks in the menu item xml because it's missing the addrulepath and addfield path

I think they should probably be added here:
image

So I manually added the validate attribute to my xml file and added my custom rule to the rule folder and it works fine for the config options and the view, but it breaks in the menu item xml because it's missing the addrulepath and addfield path I think they should probably be added here: ![image](https://user-images.githubusercontent.com/870934/32403460-19c2abd4-c121-11e7-8e2e-f9e41c21c876.png)

I have great news on this feature request, please watch this tutorial.

Just a heads-up if you want to use the rule on a view (menu) the implementation is basically the same.

I have great news on this feature request, please [watch this tutorial.](https://www.youtube.com/watch?v=Z6-ggKtX35o&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE) Just a heads-up if you want to use the rule on a view (menu) the implementation is basically the same.
kevincam3 commented 2017-11-08 12:07:41 +00:00 (Migrated from github.com)

Thanks for the tutorial, I learned a few things that I hadn't added to my implementation, like the BOM thing. But the only way I was able to get it to work with my menu item was to add a rule path to the field in the xml. Without that it wasn't able to find the path to the rule. I discovered this by stepping through the code in the IDE. Adding this path fixed the problem because all the xml files have the path except the default.xml file.

image

Thanks for the tutorial, I learned a few things that I hadn't added to my implementation, like the BOM thing. But the only way I was able to get it to work with my menu item was to add a rule path to the field in the xml. Without that it wasn't able to find the path to the rule. I discovered this by stepping through the code in the IDE. Adding this path fixed the problem because all the xml files have the path except the default.xml file. ![image](https://user-images.githubusercontent.com/870934/32548229-1d976990-c46c-11e7-9757-ce1fff456a2b.png)

Okay I see... I will add it to the next update, so the default will also have it.

Okay I see... I will add it to the next update, so the default will also have it.

For now the fix will be to add a few lines in the interpreter file at line 1352
replace

$xml .= PHP_EOL."\t\t\t".'addfieldpath="/administrator/components/com_'.$this->fileContentStatic['###component###'].'/models/fields">';

with

$xml .= PHP_EOL."\t\t\t".'addrulepath="/administrator/components/com_'.$this->fileContentStatic['###component###'].'/models/rules"';
$xml .= PHP_EOL."\t\t\t".'addfieldpath="/administrator/components/com_'.$this->fileContentStatic['###component###'].'/models/fields">';

This should add the rule path to the default view option as well.

For now the fix will be to add a few lines in the interpreter file at [line 1352](https://github.com/vdm-io/Joomla-Component-Builder/blob/master/admin/helpers/compiler/e_Interpretation.php#L1352) replace ``` $xml .= PHP_EOL."\t\t\t".'addfieldpath="/administrator/components/com_'.$this->fileContentStatic['###component###'].'/models/fields">'; ``` with ``` $xml .= PHP_EOL."\t\t\t".'addrulepath="/administrator/components/com_'.$this->fileContentStatic['###component###'].'/models/rules"'; $xml .= PHP_EOL."\t\t\t".'addfieldpath="/administrator/components/com_'.$this->fileContentStatic['###component###'].'/models/fields">'; ``` This should add the rule path to the default view option as well.

In Fact here is the whole function, so just update the whole function in the file:

public function setCustomViewMenu(&$view)
{
	$xml = '';
	// build the file
	$target = array('site' => $view['settings']->code);
	$done = $this->buildDynamique($target,'menu');
	if ($done)
	{
		// set the lang
		$lang = ComponentbuilderHelper::safeString('com_'.$this->fileContentStatic['###component###'].'_menu_'.$view['settings']->code, 'U');
		$this->langContent['adminsys'][$lang.'_TITLE'] = $view['settings']->name;
		$this->langContent['adminsys'][$lang.'_OPTION'] = $view['settings']->name;
		$this->langContent['adminsys'][$lang.'_DESC'] = $view['settings']->description;
		//start loading xml
		$xml = '<?xml version="1.0" encoding="utf-8" ?>';
		$xml .= PHP_EOL.'<metadata>';
		$xml .= PHP_EOL."\t".'<layout title="'.$lang.'_TITLE" option="'.$lang.'_OPTION">';
		$xml .= PHP_EOL."\t\t".'<message>';
		$xml .= PHP_EOL."\t\t\t".'<![CDATA['.$lang.'_DESC]]>';
		$xml .= PHP_EOL."\t\t".'</message>';
		$xml .= PHP_EOL."\t".'</layout>';
		if (isset($this->hasIdRequest[$view['settings']->code]) || isset($this->hasCatIdRequest[$view['settings']->code]))
		{
			
			$xml .= PHP_EOL."\t".'<!--'.$this->setLine(__LINE__).' Add fields to the request variables for the layout. -->';
			$xml .= PHP_EOL."\t".'<fields name="request">';
			$xml .= PHP_EOL."\t\t".'<fieldset name="request"';
			$xml .= PHP_EOL."\t\t\t".'addrulepath="/administrator/components/com_'.$this->fileContentStatic['###component###'].'/models/rules"';
			$xml .= PHP_EOL."\t\t\t".'addfieldpath="/administrator/components/com_'.$this->fileContentStatic['###component###'].'/models/fields">';
			if (isset($this->hasIdRequest[$view['settings']->code]) && ComponentbuilderHelper::checkArray($this->hasIdRequest[$view['settings']->code]))
			{
				foreach($this->hasIdRequest[$view['settings']->code] as $requestFieldXML)
				{
					$xml .= PHP_EOL."\t\t\t".$requestFieldXML;
				}
			}
			if (isset($this->hasCatIdRequest[$view['settings']->code]) && ComponentbuilderHelper::checkArray($this->hasCatIdRequest[$view['settings']->code]))
			{
				foreach($this->hasCatIdRequest[$view['settings']->code] as $requestFieldXML)
				{
					$xml .= PHP_EOL."\t\t\t".$requestFieldXML;
				}
			}
			$xml .= PHP_EOL."\t\t".'</fieldset>';
			$xml .= PHP_EOL."\t".'</fields>';
		}
		if (isset($this->frontEndParams) && isset($this->frontEndParams[$view['settings']->name]))
		{
			// first we must setup the fields for the page use
			$params = $this->setupFrontendParamFields($this->frontEndParams[$view['settings']->name],$view['settings']->code);
			// now load the fields
			if (ComponentbuilderHelper::checkArray($params))
			{
				$xml .= PHP_EOL."\t".'<!--'.$this->setLine(__LINE__).' Adding page parameters -->';
				$xml .= PHP_EOL."\t".'<fields name="params">';
				$xml .= PHP_EOL."\t\t".'<fieldset name="basic" label="COM_'.$this->fileContentStatic['###COMPONENT###'].'"';
				$xml .= PHP_EOL."\t\t\t".'addrulepath="/administrator/components/com_'.$this->fileContentStatic['###component###'].'/models/rules"';
				$xml .= PHP_EOL."\t\t\t".'addfieldpath="/administrator/components/com_'.$this->fileContentStatic['###component###'].'/models/fields">';
				$xml .= implode("\t\t\t",$params);
				$xml .= PHP_EOL."\t\t".'</fieldset>';
				$xml .= PHP_EOL."\t".'</fields>';
			}
		}
		$xml .= PHP_EOL.'</metadata>';
	}
	return $xml;
}
In Fact here is the whole function, so just update the whole function in the file: ``` public function setCustomViewMenu(&$view) { $xml = ''; // build the file $target = array('site' => $view['settings']->code); $done = $this->buildDynamique($target,'menu'); if ($done) { // set the lang $lang = ComponentbuilderHelper::safeString('com_'.$this->fileContentStatic['###component###'].'_menu_'.$view['settings']->code, 'U'); $this->langContent['adminsys'][$lang.'_TITLE'] = $view['settings']->name; $this->langContent['adminsys'][$lang.'_OPTION'] = $view['settings']->name; $this->langContent['adminsys'][$lang.'_DESC'] = $view['settings']->description; //start loading xml $xml = '<?xml version="1.0" encoding="utf-8" ?>'; $xml .= PHP_EOL.'<metadata>'; $xml .= PHP_EOL."\t".'<layout title="'.$lang.'_TITLE" option="'.$lang.'_OPTION">'; $xml .= PHP_EOL."\t\t".'<message>'; $xml .= PHP_EOL."\t\t\t".'<![CDATA['.$lang.'_DESC]]>'; $xml .= PHP_EOL."\t\t".'</message>'; $xml .= PHP_EOL."\t".'</layout>'; if (isset($this->hasIdRequest[$view['settings']->code]) || isset($this->hasCatIdRequest[$view['settings']->code])) { $xml .= PHP_EOL."\t".'<!--'.$this->setLine(__LINE__).' Add fields to the request variables for the layout. -->'; $xml .= PHP_EOL."\t".'<fields name="request">'; $xml .= PHP_EOL."\t\t".'<fieldset name="request"'; $xml .= PHP_EOL."\t\t\t".'addrulepath="/administrator/components/com_'.$this->fileContentStatic['###component###'].'/models/rules"'; $xml .= PHP_EOL."\t\t\t".'addfieldpath="/administrator/components/com_'.$this->fileContentStatic['###component###'].'/models/fields">'; if (isset($this->hasIdRequest[$view['settings']->code]) && ComponentbuilderHelper::checkArray($this->hasIdRequest[$view['settings']->code])) { foreach($this->hasIdRequest[$view['settings']->code] as $requestFieldXML) { $xml .= PHP_EOL."\t\t\t".$requestFieldXML; } } if (isset($this->hasCatIdRequest[$view['settings']->code]) && ComponentbuilderHelper::checkArray($this->hasCatIdRequest[$view['settings']->code])) { foreach($this->hasCatIdRequest[$view['settings']->code] as $requestFieldXML) { $xml .= PHP_EOL."\t\t\t".$requestFieldXML; } } $xml .= PHP_EOL."\t\t".'</fieldset>'; $xml .= PHP_EOL."\t".'</fields>'; } if (isset($this->frontEndParams) && isset($this->frontEndParams[$view['settings']->name])) { // first we must setup the fields for the page use $params = $this->setupFrontendParamFields($this->frontEndParams[$view['settings']->name],$view['settings']->code); // now load the fields if (ComponentbuilderHelper::checkArray($params)) { $xml .= PHP_EOL."\t".'<!--'.$this->setLine(__LINE__).' Adding page parameters -->'; $xml .= PHP_EOL."\t".'<fields name="params">'; $xml .= PHP_EOL."\t\t".'<fieldset name="basic" label="COM_'.$this->fileContentStatic['###COMPONENT###'].'"'; $xml .= PHP_EOL."\t\t\t".'addrulepath="/administrator/components/com_'.$this->fileContentStatic['###component###'].'/models/rules"'; $xml .= PHP_EOL."\t\t\t".'addfieldpath="/administrator/components/com_'.$this->fileContentStatic['###component###'].'/models/fields">'; $xml .= implode("\t\t\t",$params); $xml .= PHP_EOL."\t\t".'</fieldset>'; $xml .= PHP_EOL."\t".'</fields>'; } } $xml .= PHP_EOL.'</metadata>'; } return $xml; } ```

Please test and let me know

Please test and let me know
kevincam3 commented 2017-11-08 12:46:48 +00:00 (Migrated from github.com)

Tested it and it works. Thanks.

Tested it and it works. Thanks.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: joomla/Component-Builder#169
No description provided.