Multipicker Relations - How to Create the Proper Form Controls
Hi,
I have uComponents installed, as well as Relation Types. Here is what I am trying to do. I have a Customer document type. Each Customer can be associated with one or more Products, Use Cases, and Industries, which are in themselves Document Types (and pages) as well, in other sections of the site. Will uComponents and Relation Types help me to create a filterable list of Customers? I want to be able, ultimately, to have a list of Customers which I can filter by Product (let me see all Customers who have used this Product), by Industry (let me see all Customers who are in this Industry), etc.
What I am having trouble with is wrapping my mind around how to create these relationships.
Let's say when you're editing a Customer, there is a set of checkboxes which represent different products which you can associate with it. How do I populate this checkbox list? I want it to be an exact reflection of the Product pages on the site (all those pages of document type "Product"). Seems like I would need a datatype that is a checkbox list populated by a Multi-Node Tree Picker, no? How can I create a form control using another datatype though? I am confused. I read everything I could about Multipicker Relations (and here) but I'm not sure how to make the original list of items to choose from (in the example's case, "colours") representative of actual content nodes. Do I even need Multipicker Relations? Or can I achieve this (complete with referencing/displaying the relationships in XSLT) with just the Multi-Node tree Picker?
What is the easiest and most logical way to associate Umbraco nodes with one another, in a one-to-many or many-to-many fashion?
Any help on this would be greatly appreciated -- I have many other such cases on my current project.
To get a CheckBoxList of Products, you could use the XPath CheckBoxList with the following XPath expression:
//Product
That will render out a checkbox item for each 'Product' node.
To create the relationship between a Customer and a Product, you could use the MultiPicker Relations datatype and configure it to watch this CheckBoxList.
The advantage of using relations is that it's then efficient, for example, to get all Customers that have selected a given Product (or vice versa):
Funny-- right after I wrote this post I tried exactly that in the CMS -- an XPath CheckBoxList using "//* [@isDoc and name() = 'Product' and string(umbracoNaviHide) != '1']" -- this works a treat, and thanks. I also see that the data is saving in a seemingly manageable way in cmsContentXml table although I am not sure whether to choose Node Ids or Node Names for storage values....
With regard to your code above -- this does NOT look like XSLT! Haha. I will need to filter the Cutomers using XSLT because I don't know to write or use a usercontrol, that's still very cryptic for me as I am normally a PHP/MySQL guy. Can I use relation types this way? Perhaps by leveraging umbraco.library:GetRelatedNodesAsXml() or umbraco.library:GetRelatedNodesAsXml()?
Hendy, you rock for getting back to me so quickly, I really appreciate it. That's GREAT news that I can use XSLT. Wiping sweat off brow.
Now, looking at the code snippet.... This all seems too easy, I have to say. Haven't had the time yet to try it out, but....
I find it hard to believe that these associated Product nodes (i.e.: the boxes I checked on a given Customer) are going to be returned by this method without even referring to the property on the Customer which holds the IDs. Seriously? How, exactly, are these related nodes? Seems like there has to be more to it, as magical as Umbraco is...
customerProducts is what the property on the Customer is called. Again, I am using am xPath CheckBoxList which is populated by selecting all Products in the system. You select one or more for each Customer. Nothing shows up with this code, however, and no errors. Am I warm or cold here? Should I just be using the Page Field customerProducts? I'm not because I want to loop through them and have access to them individually, of course.
Multipicker Relations - How to Create the Proper Form Controls
Hi,
I have uComponents installed, as well as Relation Types. Here is what I am trying to do. I have a Customer document type. Each Customer can be associated with one or more Products, Use Cases, and Industries, which are in themselves Document Types (and pages) as well, in other sections of the site. Will uComponents and Relation Types help me to create a filterable list of Customers? I want to be able, ultimately, to have a list of Customers which I can filter by Product (let me see all Customers who have used this Product), by Industry (let me see all Customers who are in this Industry), etc.
What I am having trouble with is wrapping my mind around how to create these relationships.
Let's say when you're editing a Customer, there is a set of checkboxes which represent different products which you can associate with it. How do I populate this checkbox list? I want it to be an exact reflection of the Product pages on the site (all those pages of document type "Product"). Seems like I would need a datatype that is a checkbox list populated by a Multi-Node Tree Picker, no? How can I create a form control using another datatype though? I am confused. I read everything I could about Multipicker Relations (and here) but I'm not sure how to make the original list of items to choose from (in the example's case, "colours") representative of actual content nodes. Do I even need Multipicker Relations? Or can I achieve this (complete with referencing/displaying the relationships in XSLT) with just the Multi-Node tree Picker?
What is the easiest and most logical way to associate Umbraco nodes with one another, in a one-to-many or many-to-many fashion?
Any help on this would be greatly appreciated -- I have many other such cases on my current project.
Thanks,
Garrett
Hi Garrett,
To get a CheckBoxList of Products, you could use the XPath CheckBoxList with the following XPath expression:
That will render out a checkbox item for each 'Product' node.
To create the relationship between a Customer and a Product, you could use the MultiPicker Relations datatype and configure it to watch this CheckBoxList.
The advantage of using relations is that it's then efficient, for example, to get all Customers that have selected a given Product (or vice versa):
HTH,
Hendy
Funny-- right after I wrote this post I tried exactly that in the CMS -- an XPath CheckBoxList using "//* [@isDoc and name() = 'Product' and string(umbracoNaviHide) != '1']" -- this works a treat, and thanks. I also see that the data is saving in a seemingly manageable way in cmsContentXml table although I am not sure whether to choose Node Ids or Node Names for storage values....
With regard to your code above -- this does NOT look like XSLT! Haha. I will need to filter the Cutomers using XSLT because I don't know to write or use a usercontrol, that's still very cryptic for me as I am normally a PHP/MySQL guy. Can I use relation types this way? Perhaps by leveraging umbraco.library:GetRelatedNodesAsXml() or umbraco.library:GetRelatedNodesAsXml()?
Thanks again and in advance,
Garrett
Hi Garrett,
Good to hear you've got the CheckBoxList working (I usually store the Ids rather than names - infact Ids are required if wiring it up to relations).
Yes, you can use the GetRelatedNodesAsXml() extension in XSLT, here's an example code snippet.
HTH,
Hendy
Hendy, you rock for getting back to me so quickly, I really appreciate it. That's GREAT news that I can use XSLT. Wiping sweat off brow.
Now, looking at the code snippet.... This all seems too easy, I have to say. Haven't had the time yet to try it out, but....
I find it hard to believe that these associated Product nodes (i.e.: the boxes I checked on a given Customer) are going to be returned by this method without even referring to the property on the Customer which holds the IDs. Seriously? How, exactly, are these related nodes? Seems like there has to be more to it, as magical as Umbraco is...
//Garrett
Hi again Hendy -- here's what I've got for my XSLT file which attempts to show the Products related to a Customer:
customerProducts is what the property on the Customer is called. Again, I am using am xPath CheckBoxList which is populated by selecting all Products in the system. You select one or more for each Customer. Nothing shows up with this code, however, and no errors. Am I warm or cold here? Should I just be using the Page Field customerProducts? I'm not because I want to loop through them and have access to them individually, of course.
Thanks,
Garrett
is working on a reply...