Umbraco 9, link from one template\view to another, how?
I've become a bit confused on how to actually do this.
I have a link on my footer, which is rendered from master with a partial view. I have a CookieDeclaration.cshtml in root of my Views folder and i want to link to this from my footer.
How is the approach? I've been playing around with RenderController, but i'm unable to get it to hit my controller with:
HomeController
public class HomeController : RenderController
{
public IActionResult CookieDeclaration()
{
var vm = new CookieDeclarationViewModel(CurrentPage);
return View("/Views/CookieDeclaration.cshtml", vm);
}
Views\Partials\footer.cshtml
@Html.ActionLink("CookieDeclaration", "CookieDeclaration", "Home", new { }, null)
Or
CookieDeclarationController
public class CookieDeclarationController : SurfaceController
{
public IActionResult Index()
{
var vm = new CookieDeclarationViewModel(CurrentPage);
return View("/Views/CookieDeclaration.cshtml", vm);
}
Views\Partials\footer.cshtml
@Html.ActionLink("CookieDeclaration", "Index", "CookieDeclaration", new { }, null)
What am i doing wrong? Should i use a ViewComponenent instead, haven't tried using them before yet, though.
Can i simply link to CookieDeclaration.cshtml without a controller?
Umbraco 9, link from one template\view to another, how?
I've become a bit confused on how to actually do this.
I have a link on my footer, which is rendered from master with a partial view. I have a CookieDeclaration.cshtml in root of my Views folder and i want to link to this from my footer.
How is the approach? I've been playing around with RenderController, but i'm unable to get it to hit my controller with:
HomeController
Views\Partials\footer.cshtml
Or
CookieDeclarationController
Views\Partials\footer.cshtml
What am i doing wrong? Should i use a ViewComponenent instead, haven't tried using them before yet, though.
Can i simply link to CookieDeclaration.cshtml without a controller?
Are no one able to help me here?
Hi You shouldn't need a controller to link to a page if the page exists in umbraco as a page.
You should be able to link directly to it using the url.
/cookie-declaration/
You could have a property on your home page called
Footer Links
and you could use aMulti Url Picker
data type.Then in the content editor you can choose the links for the footer, this would include your cookie declaration page.
Next you could update your
Footer.cshtml
to read theFooter Links
property from your home page and loop through them to render them in the footer.That's how I would do it.
I hope this helps.
Paul
That was actually a pretty simple solution, didn't think of that...
Of cause, it's obvious now.
Thanks a ton.
is working on a reply...