Reputation: 1250
I use N2CMS version 2.9.6.8 and let's say I opened the account/login page, then I want to click on the subscribe link below the login form.
So, how to get the url of the subscribe page to build the ahref tag correctly?
The website has many languages and if I want to build the href tag this way:
<a href="@Url.Action("Index", "Subscription")">Wanna subscribe?</a>
I will get http://mysiteweb.com/Subscription/Index which will give a 400 not found page instead of something like http://mywebsite.com/en/subscription (with the language id).
The Subscription page has been published through the admin panel so I guess it is possible to create an href on it without any hard coding?
Hope we have a N2CMS fan around..
Thank for any help,
David
Upvotes: 0
Views: 149
Reputation: 1250
I finally found the answer. You will be able to get the complete URL using the API given with the CMS.
For instance, imagine you have a control called ChangePasswordViewModel which inherits from ContentItem then you have the associated controller. You will be able to get the full URL no matter the current language by doing this:
@{
var item = Find.Items
.Where.Type.Eq(typeof(ChangePasswordViewModel)).And.State.Eq(ContentState.Published)
.Select().SingleOrDefault();
}
And then <a href="@item.Url">Change password</a>
To conclude, don't forget to add the ChangePasswordViewModel control in the admin panel section and everything will work fine using the API.
David
Upvotes: 0