Reputation: 106
Currently, I am working on x-cart and as you guys know x-cart is working on smarty template engine. Now my client wants angularjs in x-cart. Have tried so many things but unable to implement it. Have surfed on google but I also didn't get anyway. Can you guys please suggest me something?
I have to serve question.
Please help me in it.
Thank you, guys.
Upvotes: 7
Views: 206
Reputation: 633
okay, i got an answer. You can not implement angularjs directly as you are implementing in other websites. so here are the answers of your questions.
Is implementing angular js in x-cart is a good idea?
: it depends on what you actually want to do with it? as you wants angularjs to load page faster, first you may check and try this article. to increase performance . if your demands can be completed from here. you don't need angularjs.
Is it possible?
: Yes, it is possible. but you can't complete entire angularjs circle like a request to ng-route and get data back.
If it is possible then how can we implement it?
: all you have to do is include angular's js file and then create one script and get data in angular scope which are coming from php.
for example: there is a product list page, data of products will come as products variable. so create a script in products_t page and get product data in angular scope. give ng-app in HTML from home.tpl file. here i am taking ProductsController.
angular.module('myApp', []).controller('ProductsController', ['$scope', function($scope){ $scope.products = {$products};
}]);
Now define productlist main div as Products controller and process further angularjs operations.
Does it affect other functionality of x-cart?
: If you will follow this structure, it will not affect any x-cart module. just define all values properly.Suggestion: still if your demands are fulfilling from above link. don't try to implement angularjs.
Upvotes: 5
Reputation: 1431
Well, I don't know x-cart at all, but looking at the x-cart 4 documentation you can add javascripts using the load_defer
smarty tags as explained here: https://help.x-cart.com/index.php?title=X-Cart:CSS_and_JavaScript_optimization
So that should answer your question on how to add Angular.
However, it makes no sense to ask how to replace Smarty with Angular. Smarty is a serverside template engine and Angular is a clientside template engine (and more).
I imagine you could end up using both in which you use Smarty mainly to render te layout and the static Angular tags and then use Angular to fill in those tags with actual content. However, ofcourse you will have to built that implementation customly.
Upvotes: 2