I have created my own db table in the umbraco DB. The table is very similar to the node table in umb and my question is this: is it possible to extend the nodeFactory in umbraco? perhaps by overloading some method or something similar? I need this for showing my "products nodes" to the public in a smooth jquery tree.
The nodeFactory class accesses the XML cache (umbraco.config) to return the node data. It doesn't access the database. You would usually use umbraco.cms.businesslogic.web.Document() to do that.
If your products table is similar to the umbracoNode table, then why not use that instead? Use a unique Guid in the nodeOjectType column for your Products "type". (but you probably thought of this anyway, and require extra columns?)
Could your Products not be stored as content nodes? (then they'd be cached in the XML umbraco.config - and usable by nodeFactory?)
Create your own xslt extension fetching the external data (implemented with caching) would be my way for retrieving external data. I think rewriting the nodefactory isn't allowed by the licence (as I know).
The product list is a new section where users who login to the backend see different products in the tree depending on what "company" they belong to. This is my first "big" project with umbraco and to be honest, i didnt think i could use my "products" as normal nodes when i started this but as the project whent on and i learnt more and more I now realize that it was a mistake not to implement it as normal umb Nodes.
I dont think I can store them as content nodes since i need to have the content section seperated from my products section (to confusing with both "normal" pages and product pages)
@Thomas. Creating my own xslt extension seems to be a good solution, got any good tutorials on how to accomplish this? especially the caching part?
It's easy to use I used it to have the configuration of my client tools in cache. I have a class structure which I am serializing into the file and back into the memory. To get and set the configuration from / to the cache I have written this code:
var ser = new XmlSerializer(typeof(ConfigurationRoot)); var path = umbraco.GlobalSettings.FullpathToRoot + System.IO.Path.DirectorySeparatorChar + "config" + System.IO.Path.DirectorySeparatorChar + Configfilename;
and if I change something in the configuration by code I can call afterwards this code to reflect the changes in memory:
public static void SaveConfiguration() { var ser = new XmlSerializer(typeof(ConfigurationRoot)); var path = umbraco.GlobalSettings.FullpathToRoot + System.IO.Path.DirectorySeparatorChar + "config" + System.IO.Path.DirectorySeparatorChar + Configfilename;
using (var fs = new System.IO.FileStream(path, System.IO.FileMode.Create)) { ser.Serialize(fs, Root); fs.Close(); } HttpRuntime.Cache[Cachekey] = Root; }
So, the code to set the objects intot the cache is:
HttpRuntime.Cache[Cachekey] = MYOBJECT;
and the code to get the objects from the cache is:
var myobjects = (MYTYPECASTING)HttpRuntime.Cache[Cachekey]
okej i think i understand how that would work, but for me when using a "product" - object and caching it, do i only cach the XML-file or is it in some way possible to cache functions that always return the same value? I'm thinking something like
public List<Product> GetProducts(Xml)
{
return List<Product>
}
HttpRuntime.Cache["uniqkey"] = GetProducts;
So when im creating my jQuery Tree i only need to call:
It's on you what to cache, if you are working with the list just cahce the list, if you want an xml just open an xml and cache it. It depends on you what you want to use in the frontend :-)
External source for nodeFactory
Hi all,
I have created my own db table in the umbraco DB. The table is very similar to the node table in umb and my question is this: is it possible to extend the nodeFactory in umbraco? perhaps by overloading some method or something similar? I need this for showing my "products nodes" to the public in a smooth jquery tree.
Best Regards
Marthin
Hi Marthin,
The nodeFactory class accesses the XML cache (umbraco.config) to return the node data. It doesn't access the database. You would usually use umbraco.cms.businesslogic.web.Document() to do that.
If your products table is similar to the umbracoNode table, then why not use that instead? Use a unique Guid in the nodeOjectType column for your Products "type". (but you probably thought of this anyway, and require extra columns?)
Could your Products not be stored as content nodes? (then they'd be cached in the XML umbraco.config - and usable by nodeFactory?)
All the best, Lee.
Create your own xslt extension fetching the external data (implemented with caching) would be my way for retrieving external data. I think rewriting the nodefactory isn't allowed by the licence (as I know).
hth, Thomas
Thx for the quick responses!
The product list is a new section where users who login to the backend see different products in the tree depending on what "company" they belong to. This is my first "big" project with umbraco and to be honest, i didnt think i could use my "products" as normal nodes when i started this but as the project whent on and i learnt more and more I now realize that it was a mistake not to implement it as normal umb Nodes.
I dont think I can store them as content nodes since i need to have the content section seperated from my products section (to confusing with both "normal" pages and product pages)
@Thomas. Creating my own xslt extension seems to be a good solution, got any good tutorials on how to accomplish this? especially the caching part?
Thx guys!
It's easy to use I used it to have the configuration of my client tools in cache. I have a class structure which I am serializing into the file and back into the memory. To get and set the configuration from / to the cache I have written this code:
and if I change something in the configuration by code I can call afterwards this code to reflect the changes in memory:
So, the code to set the objects intot the cache is:
and the code to get the objects from the cache is:
hth, Thomas
Making your own (caching) xslt extension is a great solution. But if you're in a hurry you might be able to use Jeser's "SQL for XSLT" package, which is very powerful. http://our.umbraco.org/projects/sql-for-xslt-%28jespercom%29
cheers,
doug.
okej i think i understand how that would work, but for me when using a "product" - object and caching it, do i only cach the XML-file or is it in some way possible to cache functions that always return the same value? I'm thinking something like
Is this possible or should i only cache the XML file?
Thank you for helping me!
EDIT: GetProducts(Xml) should not take any argument: GetProducts()
It's on you what to cache, if you are working with the list just cahce the list, if you want an xml just open an xml and cache it. It depends on you what you want to use in the frontend :-)
Thomas
is working on a reply...