Hello,
I'm having a difficulty to come up with solution to my problem.
Basicly I wan't to use jQuery chain combo box to browse hierarchy in Products module. (after i pick "cars" from combo box, 2nd combo box appears with brands - after i pick brand from 2nd combo box, 3rd combo box appears with models....)
I have a class which uses "$this->db = cmsms()->GetDb();" in constructro to get db instance.
The issue I'm having is that whenever i call the php file, which uses object of my class, from JS script, the script can't see the cmsms function.
Is there any simple solution to that?
Accessing cmsms() in file loaded by JS
Re: Accessing cmsms() in file loaded by JS
I'm thinking this way - make php file which is being used by JS script module action.
So if i call the JS function i use redirection to module action instead of a .php file - will that work?
sorry for silly question - I'm begineer in module developing. Also looking for answer in documentation.
So if i call the JS function i use redirection to module action instead of a .php file - will that work?
sorry for silly question - I'm begineer in module developing. Also looking for answer in documentation.
Re: Accessing cmsms() in file loaded by JS
Ok so tried couple of things but still can't figure out how to solve this.
Basicly i've got defined action.gethierarchy.php inside module dir:
I need to pass URL to this function, and it'll add some $_GET parameters, process the url and get json_encode result.
Any ideas how to make it work?
Basicly i've got defined action.gethierarchy.php inside module dir:
- <?php
if (!isset($gCms))
exit;
if ($_GET['_value']) {
require_once('custom_hierarchy_queries.php');
$deb = (int) function_exists('cmsms');
$hierarchy_items = new CustomHierarchyQuery();
echo json_encode($hierarchy_items->getHierarchyArray($_GET['_value']));
} else {
$empty = array();
json_encode($empty);
}
?>
Code: Select all
$productsModuleInstance = cms_utils::get_module('Products');
//$productsModuleInstance->DoAction('gethierarchy',$id,$params,$returnid)
//"../../modules/Products/customChainComboBox.php"
//$productsModuleInstance->_load_admin();
$url = $productsModuleInstance->CreateURL($id,"gethierarchy","");
//$url = $productsModuleInstance->CreatePrettyLink($id,"gethierarchy");
if( isset( $params['target'] ) ){
$params['target']=(string)$params['target'];
echo(sprintf ('
<__script__ language="JavaScript" type="text/javascript">
$(function()
{
$("#root").chainSelect("%s","%s");
}
)
</__script>
',$params["target"]
,$url
)
);
}
Any ideas how to make it work?