I’m fairly new to Umbraco
development and I’m stucked with a problem that I expected to be a simple task,
because I get the same ids from two different node properties.
I have a document type (name Frontpage
– alias frontpage), which contains a number of properties. Two of those
properties are content pickers that links to two internal pages with the ids
1268 and 1269.
To get the urls of the content
pickers, I have created a user control with the parameters DocTypeAlias (frontpageAlias)
and NodePropertyAlias_ContentPicker (aliasPageA or aliasPageB). When I look up
the node with the alias DocTypeAlias then I get the correct node having all the
properties as expected, but I can see that both content picker properties has
the value 1269 but both properties have the correct aliases - aliasPageA or
aliasPageB
I have checked the existence of the
properties in the table cmsContent and they both exist with the correct text
attached.
Is it wrong to use content picker
for this purpose? – and if so: What to do instead?
Your scenario sounds like one where it's a good idea to use a content picker - however it would be nice to see some of your code and if you could also let us know what version of Umbraco you're using it will make it a bit easier to give you some pointers.
Node properties have same id
Hi Umbraco People
I’m fairly new to Umbraco development and I’m stucked with a problem that I expected to be a simple task, because I get the same ids from two different node properties.
I have a document type (name Frontpage – alias frontpage), which contains a number of properties. Two of those properties are content pickers that links to two internal pages with the ids 1268 and 1269.
To get the urls of the content pickers, I have created a user control with the parameters DocTypeAlias (frontpageAlias) and NodePropertyAlias_ContentPicker (aliasPageA or aliasPageB). When I look up the node with the alias DocTypeAlias then I get the correct node having all the properties as expected, but I can see that both content picker properties has the value 1269 but both properties have the correct aliases - aliasPageA or aliasPageB
I have checked the existence of the properties in the table cmsContent and they both exist with the correct text attached.
Is it wrong to use content picker for this purpose? – and if so: What to do instead?
Hi René and welcome to our :)
Your scenario sounds like one where it's a good idea to use a content picker - however it would be nice to see some of your code and if you could also let us know what version of Umbraco you're using it will make it a bit easier to give you some pointers.
Looking forward to hearing from you.
/Jan
Hi Jan and thanks for replying
I use Umbraco 6.0.5 and here is my user control.
public string DocTypeAlias { get; set; }
public string NodeProperty_ContentPicker { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
GetUrl();
}
}
private void GetUrl()
{
Node docTypeNode = GetNodeByAlias(DocTypeAlias);
if (docTypeNode == null)
{
return;
}
Property property = (Property)docTypeNode.PropertiesAsList.Find(x => x.Alias.ToLower() == NodeProperty_ContentPicker.ToLower());
if (property != null)
{
string url = string.Empty;
string pageName = string.Empty;
try
{
int propertyId = int.Parse(property.Value);
url = umbraco.library.NiceUrl(propertyId);
Node cpValue = new Node(propertyId);
if (cpValue != null)
{
pageName = cpValue.Name;
}
}
catch (Exception)
{
//Remember to log the error...
}
hyperLink.NavigateUrl = "~" + url;
hyperLink.Text = pageName;
}
}
I solved the problem by creating a new document type carrying the two content pickers only.
By doing so my user control were able to read the properties correctly.
As far as I can see, the records in the database looks similar, so I assume this is an undocumented Umbraco feature :-)
is working on a reply...