Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
I fooling around with Umbraco 6 and mvc, and I'm having trouble to make an alternate template. Is this possible with mvc umbraco?
And another question, Is it possible to Create a controller that returns the content in json?
Thx
Berto
Aynone?
Alt templates should work, but there are exceptions: http://our.umbraco.org/forum/using/ui-questions/37937-What-shall-we-do-with-AltTemplate
You can create a surface controller and let that return json:
Here's a quick example:
public class JsonController : SurfaceController { [HttpPost] public ActionResult UpdateVariantAmount(int variantId, string amount) { //do stuff return Json(""); } }
$(".quotationAmount").keyup(function () { var variantId = $(this).closest("form").find("input[type=hidden]").val(); var amount = $(this).val(); $.ajax({ url: '/umbraco/Surface/Json/UpdateVariantAmount', type: 'POST', dataType: 'json', data: '{ "variantId": ' + variantId + ', "amount": "' + amount + '" }', contentType: 'application/json; charset=utf-8', success: function (data) { //do stuff } }); });
Don't forget to add the url to umbracoReservedUrls in the web.config: ,~/umbraco/Surface/Json/UpdateVariantAmount
Jeroen
Hi Jeroen,
From my experiences, alt templates aren't working, but I will confirm it.
I think that i was trying to do was to have a controller that returnet the content in json, something on the likes of this:
http://www.umbraco6.com/mysuperpage --> Returns an html page
http://www.umbraco6.com/mysuperpage/json -->Returns the data of that page in Json
Is this possible?
It should if you add some custom routing: http://our.umbraco.org/documentation/Reference/Mvc/custom-routes
Hmmm... Ok, I have to try it ;)
Thx for the help, I will give feedback :D
What Jeroen said!
Do we need to use MVCBridge in Umbraco 6 to add the view/controller in the template??
No. Just do what it says here and it should work :-). http://our.umbraco.org/documentation/reference/mvc/custom-controllers
Thanks Joroen, Its awesome.. I guess if I want to add it as a partial view, I need to do the same as we do in MVC.
I was cofused the way we adding macros and mvc view in the template, looks both have different ways now..!!
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Umbraco 6 MVC Alternate Templates
Hi,
I fooling around with Umbraco 6 and mvc, and I'm having trouble to make an alternate template. Is this possible with mvc umbraco?
And another question, Is it possible to Create a controller that returns the content in json?
Thx
Berto
Aynone?
Alt templates should work, but there are exceptions: http://our.umbraco.org/forum/using/ui-questions/37937-What-shall-we-do-with-AltTemplate
You can create a surface controller and let that return json:
Here's a quick example:
Don't forget to add the url to umbracoReservedUrls in the web.config: ,~/umbraco/Surface/Json/UpdateVariantAmount
Jeroen
Hi Jeroen,
From my experiences, alt templates aren't working, but I will confirm it.
I think that i was trying to do was to have a controller that returnet the content in json, something on the likes of this:
http://www.umbraco6.com/mysuperpage --> Returns an html page
http://www.umbraco6.com/mysuperpage/json -->Returns the data of that page in Json
Is this possible?
It should if you add some custom routing: http://our.umbraco.org/documentation/Reference/Mvc/custom-routes
Jeroen
Hmmm... Ok, I have to try it ;)
Thx for the help, I will give feedback :D
Berto
What Jeroen said!
Do we need to use MVCBridge in Umbraco 6 to add the view/controller in the template??
No. Just do what it says here and it should work :-). http://our.umbraco.org/documentation/reference/mvc/custom-controllers
Jeroen
Thanks Joroen, Its awesome.. I guess if I want to add it as a partial view, I need to do the same as we do in MVC.
I was cofused the way we adding macros and mvc view in the template, looks both have different ways now..!!
is working on a reply...