I just started working with Umbraco recently and have got to say, I love it. I'm using to develop a website at work and also for some personal goodies.
Along those lines though, I've been learning XML, XSLT, ASP, and general Umbraco Layout so I can design a great website. It's been slow going over the last two days though and I figured I'd see what you guys thought.
I want to making a recipe DataType (to help in making tasty food). Ideally, I want it structured where the DataType will store a list of Ingredients that you can define in the DataType section. Then in the Content section it will list those ingredients and give an option to add them with a corresponding amount. That way the database will store the predefined data, and XML can handle the actual recipe (to utilize Umbraco and some XSLT for future tools).
I'm stuck though. I was using Tim Geyssens tutorial to get started, along with Warren's wonderful CWS (nice work guys=d> ). I can get data into my database, but I can't seem to find a way to get it back out. Does anyone know the syntax for pulling multiple rows out of SQL and tossing them in an array / enum / anything? I modified Tim's Configuration method as follows, (it's a tad bit ugly, the array format has to go).
[code]
public string[] Configuration
{
get
{
string[] values = new string[100];
int dtdefid = _datatype.DataTypeDefinitionId;
string command = "select value from cmsDataTypePreValues where datatypenodeid = '" + dtdefid + "'";
IRecordsReader reader = SqlHelper.ExecuteReader(command, new IParameter[0]);
try {
int i = 0;
while (reader.Read()) {
values[i] = reader.GetString("value");
i++;
}
}
catch {
throw;
}
[/code]
is there a better way of going about this?
Once I can read from the database I want to be able to send that to a DropDownList that's tied to a Button and TextBox which will add an Ingredient with a set amount to my Recipe DocumentType content pages. I'm not too sure how that will be handled, but I need to get past the database part first. I don't know how to interface with Umbraco's database tools.
Thanks for reading through, I hope to learn Umbraco fast so I can start giving back to the project. The whole ASP.NET CMS thing is kinda sexy.
I am not an umbraco expert, but have been working with it for a while. I found your thread searching for information in achieving a similar result to your recipe-maker (if I may).
I think in your case the data-type is perhaps not the best umbraco component for the task, not alone anyway.
You could, as you mention, use data-types for pre-defined lists of ingredients, units, and amounts.
But I think the final solution will involve the use of these data-types by Umbraco Macros for generating the final recipe. The macro could access a .NET User Control or an Xsl Transform, either of which would be capable of retrieving from the macro the individual criteria, and returning an informative string.
I see a couple complications that suggest the macro in a richtext editor approach. First, you most likely want the user creating the recipe--as content, and using the umbraco content gui--to be able to define any number of ingredients, not a pre-ordained count. You can't easily create a Document Type that would be able to add properties to itself, so to allow this flexibility I suggest macros that can be repeatedly inserted.
You could probably create a datatype based on a rich-text editor in some manner, that did not display the edit-box, but only the Insert Macro button (i'm really speculating now, but you maybe had something like this in mind all along).
A macro with parameters of your custom dropdown or checklist datatypes, when called by the user, would provide the user a series of control-renderings as a data-entry form your macro logic could parse into a recipe ingredient-amount.
Whew.
So, just some thoughts!
EDIT: Oh yeah, I don't know from the database, or how to easily access it. There is a datalayer component of the umbraco solution, but I don't know how well documented it is or how well it integrates seamlessly with the different db server types. It really could be just me, but I try to achieve everything without touching the DB directly. How to get the same lists in your drop-down data-types and, for whatever reason, in your xslt or c# would be another whole reply. Media of type file, or content that is just xml data are two approaches I would consider over working with the DB.
Need Help Making a DataType
Hello fellow Umbracians,
I just started working with Umbraco recently and have got to say, I love it. I'm using to develop a website at work and also for some personal goodies.
Along those lines though, I've been learning XML, XSLT, ASP, and general Umbraco Layout so I can design a great website. It's been slow going over the last two days though and I figured I'd see what you guys thought.
I want to making a recipe DataType (to help in making tasty food). Ideally, I want it structured where the DataType will store a list of Ingredients that you can define in the DataType section. Then in the Content section it will list those ingredients and give an option to add them with a corresponding amount. That way the database will store the predefined data, and XML can handle the actual recipe (to utilize Umbraco and some XSLT for future tools).
I'm stuck though. I was using Tim Geyssens tutorial to get started, along with Warren's wonderful CWS (nice work guys=d> ). I can get data into my database, but I can't seem to find a way to get it back out. Does anyone know the syntax for pulling multiple rows out of SQL and tossing them in an array / enum / anything? I modified Tim's Configuration method as follows, (it's a tad bit ugly, the array format has to go).
[code]
public string[] Configuration
{
get
{
string[] values = new string[100];
int dtdefid = _datatype.DataTypeDefinitionId;
string command = "select value from cmsDataTypePreValues where datatypenodeid = '" + dtdefid + "'";
IRecordsReader reader = SqlHelper.ExecuteReader(command, new IParameter[0]);
try {
int i = 0;
while (reader.Read()) {
values[i] = reader.GetString("value");
i++;
}
}
catch {
throw;
}
[/code]
is there a better way of going about this?
Once I can read from the database I want to be able to send that to a DropDownList that's tied to a Button and TextBox which will add an Ingredient with a set amount to my Recipe DocumentType content pages. I'm not too sure how that will be handled, but I need to get past the database part first. I don't know how to interface with Umbraco's database tools.
Thanks for reading through, I hope to learn Umbraco fast so I can start giving back to the project. The whole ASP.NET CMS thing is kinda sexy.
-Jason
Hi,
I am not an umbraco expert, but have been working with it for a while. I found your thread searching for information in achieving a similar result to your recipe-maker (if I may).
I think in your case the data-type is perhaps not the best umbraco component for the task, not alone anyway.
You could, as you mention, use data-types for pre-defined lists of ingredients, units, and amounts.
But I think the final solution will involve the use of these data-types by Umbraco Macros for generating the final recipe. The macro could access a .NET User Control or an Xsl Transform, either of which would be capable of retrieving from the macro the individual criteria, and returning an informative string.
I see a couple complications that suggest the macro in a richtext editor approach. First, you most likely want the user creating the recipe--as content, and using the umbraco content gui--to be able to define any number of ingredients, not a pre-ordained count. You can't easily create a Document Type that would be able to add properties to itself, so to allow this flexibility I suggest macros that can be repeatedly inserted.
You could probably create a datatype based on a rich-text editor in some manner, that did not display the edit-box, but only the Insert Macro button (i'm really speculating now, but you maybe had something like this in mind all along).
A macro with parameters of your custom dropdown or checklist datatypes, when called by the user, would provide the user a series of control-renderings as a data-entry form your macro logic could parse into a recipe ingredient-amount.
Whew.
So, just some thoughts!
EDIT: Oh yeah, I don't know from the database, or how to easily access it. There is a datalayer component of the umbraco solution, but I don't know how well documented it is or how well it integrates seamlessly with the different db server types. It really could be just me, but I try to achieve everything without touching the DB directly. How to get the same lists in your drop-down data-types and, for whatever reason, in your xslt or c# would be another whole reply. Media of type file, or content that is just xml data are two approaches I would consider over working with the DB.
is working on a reply...