I'm new to Umbraco and just getting started with the basics, so please forgive me if I'm asking stupid questions :)
My scenario is following:
I have a mixed Website. On the one hand, there is Umbraco with all the content etc. and on the other hand we have a rich web application with several database connections.
So far there is nothing wrong with it but now I made a custom controller that should prepare a custom model for one document type.
My doc type structure looks kinda:
de
products
news
etc.
en
Products
News
etc.
And all my paths to the contents look somehow like:
"localhost/de/products"
"localhost/en/news"
So when creating the custom "ProductsController", the only path that is working with it, is
"localhost/products"
Is there a chance to make the custom controller catch the right route?
E.g. "localhost/de/products"
Basically by inheriting from RenderMvcController and calling your controller after your doctype alias (that is for Product Doctype - ProductController), You are able to hijack the route and perform whatever custom logic required.
I suggest you read the link above and see if it makes sense to you.
Yes, I have already read the tutorial but I can't figure out how to let Umbraco route the whole path to my controller.
So I have the "ProductsController" that should be responsible for the Route "de/products",
according to my Document Type Structure:
de
products
news
etc.
But Umbraco only matches the route "/products" with my Custom Controller.
When trying to access "/de/products" I keep getting an 404 error.
Is there any additional Route Configuration that I need to implement?
Until now I have only created the document type and the ProductController that inherits from "RenderMvcController".
Not sure I follow you. Let me see if I understand your state correctly:
You have a DocType named Products.
You also have a Content Node called Products under another content called De. This content has the above document type of Products (that is both the content node as well as its document type are called Products).
You have a controller called ProductsController, that inherits from RenderMvcController that looks something along the line of:
public class HomeController : Umbraco.Web.Mvc.RenderMvcController
{
public override ActionResult Index(RenderModel model)
{
//Do some stuff here.....
}
}
Yet when you call /de/products the Index ActionResult is not triggered.
public class ProductsController : Umbraco.Web.Mvc.RenderMvcController
{
public override ActionResult Index(RenderModel model)
{
//Do some stuff here.......
}
}
Okay, i think i should expand it to it's real complexity.
I have imported a lot of content from another cms, structuring everything into Content Types for "de" and "en".
This is an excerpt from my content type structure:
So every content type's alias is for example "produktvorstellungende" or "produktvorstellungenen".
This is my content area:
"Product Presentations" is the content for "Produktvorstellungen" (The alias of Produktvorstellungen is "produktvorstellungenen" in this case)
And all of it's subnodes have the same content type "Produktvorstellungen".
So i should also have 2 Controllers, ProduktvorstellungenenController and Produktvorstellungen_deController.
My controllers look like:
public class Produktvorstellungen_enController : RenderMvcController
{
public ActionResult Show(RenderModel model)
{ // Some cool stuff here
return CurrentTemplate(newModel)
}
}
Custom Controller and Subdomains
Hey there,
I'm new to Umbraco and just getting started with the basics, so please forgive me if I'm asking stupid questions :)
My scenario is following: I have a mixed Website. On the one hand, there is Umbraco with all the content etc. and on the other hand we have a rich web application with several database connections.
So far there is nothing wrong with it but now I made a custom controller that should prepare a custom model for one document type.
My doc type structure looks kinda:
de
en
And all my paths to the contents look somehow like: "localhost/de/products" "localhost/en/news"
So when creating the custom "ProductsController", the only path that is working with it, is "localhost/products"
Is there a chance to make the custom controller catch the right route? E.g. "localhost/de/products"
Thanks for any help!
Hi,
Hope I understand your problem correctly.
What you are looking for is called Route Hijacking.
Basically by inheriting from RenderMvcController and calling your controller after your doctype alias (that is for Product Doctype - ProductController), You are able to hijack the route and perform whatever custom logic required.
I suggest you read the link above and see if it makes sense to you.
Hi,
thanks for answering :)
Yes, I have already read the tutorial but I can't figure out how to let Umbraco route the whole path to my controller.
So I have the "ProductsController" that should be responsible for the Route "de/products", according to my Document Type Structure:
But Umbraco only matches the route "/products" with my Custom Controller. When trying to access "/de/products" I keep getting an 404 error.
Is there any additional Route Configuration that I need to implement? Until now I have only created the document type and the ProductController that inherits from "RenderMvcController".
Thanks!
Not sure I follow you. Let me see if I understand your state correctly:
You have a controller called ProductsController, that inherits from RenderMvcController that looks something along the line of:
public class HomeController : Umbraco.Web.Mvc.RenderMvcController { public override ActionResult Index(RenderModel model) { //Do some stuff here..... }
}
Yet when you call /de/products the Index ActionResult is not triggered.
Am I correct ?
Sorry for the messed up code in 3, it should be:
Okay, i think i should expand it to it's real complexity. I have imported a lot of content from another cms, structuring everything into Content Types for "de" and "en".
This is an excerpt from my content type structure:
So every content type's alias is for example "produktvorstellungende" or "produktvorstellungenen".
This is my content area:
"Product Presentations" is the content for "Produktvorstellungen" (The alias of Produktvorstellungen is "produktvorstellungenen" in this case) And all of it's subnodes have the same content type "Produktvorstellungen". So i should also have 2 Controllers, ProduktvorstellungenenController and Produktvorstellungen_deController.
My controllers look like:
And i have the Template "Show"
So I don't know whether this is going to help or it's just making everything more difficult but I don't know how i can explain it in other words :)
At the moment I'm only trying to make it run with 1 controller.
is working on a reply...