I tried your codes but with no luck :( and got the following errors:
Ian's
CS1061: 'Umbraco.Web.Models.RenderModel' does not containI a definition for 'NodeById' and no extension method 'NodeById' accepting a first argument of type 'Umbraco.Web.Models.RenderModel' could be found (are you missing a using directive or an assembly reference?)
Ali's
System.NullReferenceException: Object reference not set to an instance of an object.
CS0234: The type or namespace name 'NiceUrl' does not exist in the namespace 'Umbraco' (are you missing an assembly reference?)
Line 10 if (!String.IsNullOrEmpty(nodeId))
Line 11: {
Line 12: var publishedContent = Umbraco.NiceUrl(Convert.ToInt32(nodeId)); Line 13: if (!String.IsNullOrEmpty(publishedContent) && publishedContent != "#")
Line 14: {
Get URL of Content Picker in v6
Any ideas?
Hi Jamie,
The content picker returns the node ID of the content item selected.
To get the URL we just need to do a quick check on the node ID returned.
var strURL = Model.NodeById(propertyAlias).Url;
'propertyAlias' is the alias given to the content picker in the document type.
Hope that helps,
Ian.
try this
Umbraco.TypedContent(Model.Content.GetPropertyValue<int>("propertyAlias")).Url
Thanks Ian and Ali.
I tried your codes but with no luck :( and got the following errors:
Ian's
CS1061: 'Umbraco.Web.Models.RenderModel' does not containI a definition for 'NodeById' and no extension method 'NodeById' accepting a first argument of type 'Umbraco.Web.Models.RenderModel' could be found (are you missing a using directive or an assembly reference?)
Ali's
System.NullReferenceException: Object reference not set to an instance of an object.
I reckon if v6 changes the api to get Node.
try this, first you need to check if the propertyAlias has value then you can use the api to retrieve the Url.
Assuming your using Razor here's a little snippet:
Cheers,
Ian.
Hi Ian,
I have tried your snippet and had an error:
CS0234: The type or namespace name 'NiceUrl' does not exist in the namespace 'Umbraco' (are you missing an assembly reference?)
Line 10 if (!String.IsNullOrEmpty(nodeId)) Line 11: { Line 12: var publishedContent = Umbraco.NiceUrl(Convert.ToInt32(nodeId)); Line 13: if (!String.IsNullOrEmpty(publishedContent) && publishedContent != "#") Line 14: {
Could you try:
Hi Jamie and Ian
Umbraco.NiceUrl is for the old API.
as I mentioned before you can use new API which is much faster and when you upgrade to newer version will not break.
did you get any luck with this?
is working on a reply...