Is there a way to loop through all the tab properties from Document types? I have a document type with a tag with properties. I want to add new properties later, if I need them. So I guess I can't do that manually, since i don't want to go to template to add new properties every time I add them in document types.Do I do that with XSLT?
thx for your reply.You mentioned "If you must do this with XSLT...". Is there any other way so the new properties will be automatically added after I add them in DocumentType? THX again.
The only reason you have to hit the db is because you are retrieving the tabs.
Instead you might want to consider prefixing the properties you want to appear automatically (auto_property1, auto_property2) and then you should be able to retrieve them in XSLT without hitting the db.
If you only add new property-types infrequently, then I'd recommend using caching on your Macro ... keeps the flexibility of the code and saves it from hitting the database too often.
Loop through tab properties
Hi,
Is there a way to loop through all the tab properties from Document types? I have a document type with a tag with properties. I want to add new properties later, if I need them. So I guess I can't do that manually, since i don't want to go to template to add new properties every time I add them in document types.Do I do that with XSLT?
THX for your help.
Uros
Hi Uros,
If you must do this with XSLT, then take a look at the uComponents XSLT extension for CMS. There is one extension called "GetDocumentType":
If you did a quick dump of the XML, like this:
... then you'd have the following XML:
... then you could loop through all the <tab> nodes. (OK, my XML example above only has one <tab> node! But you get the idea?)
The corresponding <propertyType> node has an attribute for "tabId" ... so you'll need to do a little XPath mapping yourself.
If you need a fuller example, let me know. Good luck!
Cheers, Lee.
Hi, Lee,
thx for your reply.You mentioned "If you must do this with XSLT...". Is there any other way so the new properties will be automatically added after I add them in DocumentType? THX again.
Uros
Hi Uros,
Some may find doing this in C# using the API much simplier, like so:
Cheers, Lee.
Hey Lee,
Am I right in thinking both the XSLT and API will hit the database?
Rich
Hi Rich.
Yes, both approached will hit the database, its unavoidable - not sure how many times though, depends on the number of tabs/properties.
Cheers, Lee.
Uros,
The only reason you have to hit the db is because you are retrieving the tabs.
Instead you might want to consider prefixing the properties you want to appear automatically (auto_property1, auto_property2) and then you should be able to retrieve them in XSLT without hitting the db.
Rich
Good point raised by Rich!
If you only add new property-types infrequently, then I'd recommend using caching on your Macro ... keeps the flexibility of the code and saves it from hitting the database too often.
Cheers, Lee.
is working on a reply...