Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Begginer questoin: DB Link to a datacapture.cfg
mishka
Hi there,
Could someone provide an example how to populate an item values list from a DB
for example: ms sql DB name testserver, DatabaseName: MyDB, country table with a country_code and country_name field, which should go into
<item name="Countries">
<checkbox required="f">
<option value="US" label="United States" />
<option value="CA" label="Canada" />
............
<option value="Country_Code" label="Country_Name" />
</checkbox>
</item>
Thanks in advance,
Misha.
P.S. Presumably that would require a Perl calling or something, but I don't know much about them. If you can guide me, where I can get Advanced Template Development documentation, that will be really much appreciated!
Find more posts tagged with
Comments
Michael
Hi Misha
You most likely will want to use the inline element. There is documentation on this in the TeamSite templating manual -- in my 5..5.2 pdf it starts on page 54.
Your inline element will call a script -- generally a perl script -- which returns XML which includes your option elements.
If you search in the forum you will probably also find examples of the perl code other people have used for this.
I hope this helps.
Cheers, Michael
Migrateduser
If you don't need the data to be instantly dynamic you might want to consider having a scheduled process that caches this data to an XML file so that each time a user loads a DCT it doesn't fork Perl and open a connection to the database, both of which are relatively expensive operations and can cause the DCT to fail completely if the database is unavailable. Then your DCT can use inline to call a shell (or Windows command) script to just cat (or type) the cached file, which will be much faster (especially if you have many inlines in a single DCT). You could have this shell script check the age of the file - if it is too old, then call the process that updates the file.
mishka
Hi Michael,
Thanks for your answer, could you tell me where I can find/download (or perhaps you can send it to me) the .pdf you mentioned in your reply?
Thanks again,
Misha.
mishka
Hi John,
that sounds like a really good idea, even though there will be another item, which, I'm pretty sure, should be a dynamic. So it looks like I'm better off implementing the both ways: dynamic SQL query and a cached XML extract query. The further question I have for you now is (presumably to convert a table to an xml file is not a big deal): how can I read from an xml file (assuming that I have an xml parser already) to an item in the cfg file?
Thanks again,
Misha.
P.S. a small item example with a pretty high level of an abstraction should fine.
Migrateduser
If you can't control the XML format then you will have to parse it (maybe with XML::XPath) or XSL it before sending it back to TeamSite. If you can, extract the XML in the format that Interwoven requires. Here's a Perl example:
print '<substitution>'. "\n";
my ${selected} = ' selected="t"';
foreach my ${key} ( sort( keys( %{workareas} )))
{
print '<option label="' . ${key} . '" ' . ${selected} . '/>' . "\n";
${selected} = '';
}
print "</substitution>\n";
In this case the first option is selected by default and the options have values that are the same as the labels - you can add value attributes if yours are different (which usually means you have a hashtable where the keys are the values and the values are the labels).
Then your inline script can just type/cat this extract file. If you don't go with the file, if your inline script just prints this XML to STDOUT it will get substituted into the DCT where it is called.
Michael
Hi Miska
All the TeamSite documentation is avaiable from the Interwoven
support site
.
Once you have logged on go to Downloads->Documentation. The pdf in question was the TeamSite Templating developers guide.
Cheers, Michael
mishka
John,
thanks for your help! I will try that.
Final question (for today) :-) :
Is there a pretty good source of advanced templating documentation/ perhaps a particular pdf file, the only thing I could find was templating2002.pdf, which doesn't say much about the advanced templating technics?
Regards,
Misha.
mishka
Hi Michael,
I will try that.
Thanks,
Misha.
Migrateduser
I think this one has the most detail:
https://support.interwoven.com/library/manuals/templating/pdf/tst.552.dev.pdf
Also check in the examples folder on your server.
mishka
John,
you are the saviour ;-) !!!
Misha.