I have a question about hidden templates, embeds, and script calls. Basically, I have a .NET web service that I need to call from EE1 to populate available markets being maintained by a third party business source. In order to do this efficiently, I wrote a simple PHP file that handles the information transaction. Something like this:
<?php
$marketBitmask = isset($_POST['marketBitmask'])?$_POST['marketBitmask']:NULL;
$client = new SoapClient("https://webAddress/MarketingData.asmx?WSDL");
$result = $client->TheWsdlMethod(array(
'marketBitmask'=>$marketBitmask
));
$return[] = $result;
echo json_encode($return);
?>
Then I process that through a jQuery AJAX call like:
var market = $(".ddl_productList").attr('title');
var marketBitmask = '';
switch(market){
case 'Appraiser':
marketBitmask = 2;
break;
default:
marketBitmask = 'NULL';
break;
}
$.post("services/.products", { marketBitmask: marketBitmask.toString() }, function(data){
// Populate Results on Return
$.each(data, function(n, val){
var products = val.ProductsResult.Products;
var result = val.ProductsResult.Result;
var resultDescription = val.ProductsResult.ResultDescription;
if(result!='Success'){
// Post Error
$(".noError").hide();
$("#ggspr_result").val(result).css('color','red');
$("#ggspr_resultDescription").val(resultDescription).css('color','red');
return;
}else{
// Populate Results
$(".noError").show();
$.each(products.Product, function(i, product){
$("#ddl_productList").append("<option value='"+product._ProductId+"'>"+product._Name+"</option>");
});
return;
}
});
}, "json");
The problem I am running into is that I would like to keep the services template group set as a hidden template type so that no-one can hit them directly, but I need to be able to call them from a script like shown above.
I can use the hidden templates as embeds such as:
{embed="services/.products"}
But that doesn’t help… 😉
Thanks guys!
Brian