Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Populate Select Field by directory
jaylaw
Is there a way to populate a select field in a datacapture.cfg file by reading a directory and inserting those values as the values of the options within the select tag? I was told it can be done using the inline tag, but cant find any documentation on how to do this.
Find more posts tagged with
Comments
Adam Stoller
If you do it via an inline tag - then the information contained in the drop-down list could change from one day to the next (this may be desirable, or it may not)
The documentation for the inline tag is in the FormsPublisher Developer's Guide.
Documentation for writing a inline script is scattered about within examples in the manual, examples shipped with the product, and various posts in these forums - there's many ways that one could write such a script - but ultimately that's your (or someone you hire) responsibility.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
jaylaw
I was looking for an example that someone here could provide. Your reply doesnt really get me any where. Thanks anyway
jbonifaci
If you do not know how to create inline scripts or do other TeamSite related development, I would suggest taking some training.
This is a fairly simple script to write. You just need to create an inline that reads the contents of a directory and returns it to the DCT. Once you have tried to do this and are having problems, please post your script and let us know what is going wrong. However, we will not do your work for you.
~Jeff
Adam Stoller
Okay - let's try this as a response then:
1 - Read the documentation
2 - Take training
3 - Search the installed directories for existing examples of such code
4 - Search the forums for existing examples of such code
5 - Search the rest of the site for existing examples of such code
6 - Try figuring it out yourself based on the above and if you run into problems, post your code and explain what's happening (or not happening) and folks here will try to help you - but don't ask others to do your work for you.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
XML_ACK.rptdesign
xmls.zip
Multi.PDF
Ack.jpg
jaylaw
never asked anyone to do it for me, asked if anyone had any examples i could look at, and yes i've read the documentation, but no, training is not available for me to take. Anyways, any examples that are available i would need to just take the theory of that and apply it to the projects that i am working on. Now if i explicitly gave values and data and said make this work then i would be out of line. But pointing me to resources that show high level uses doesnt help. Also anyone else who may be looking for this type of help could make good use of everyones expertise as well.
jbonifaci
Assuming you are using 6.5, the TeamSite FormsPublisher Developer's Guide tells you how to add an inline to your DCT and tells you the format of the xml it has to return on page 50. Please use this information to create your inline script and if you are still having issues, post your script with the problems you are having.
~Jeff
jaylaw
i'm looking forsomething that will make the select drop down to be populated by a directory list while in the dcr not in the pt. Almost like using the iterate but in the dcr form.
So its
<select>
{{some iw value or perl to read directory and generate <option value="" label="">filename</option>}}
</select>
jbonifaci
That's exactly what an inline does. You can not add the code to the DCT to do this, you must add an <inline> element, which references a script. This script must then output xml, as described on page 50 of the TeamSite FormsPublisher Developer's Guide.
~Jeff
jaylaw
right i know how to do that, but thats only for the DCT not the DCR (datacapture.cfg). That would mean that only after the value was selected in the dcr and then that dcr was generated to a page would the inline command run. I want the drop down that is in the DCR to read a directory..not what is generated by the PT
jbonifaci
I am not talking about Presentation Templates. I am talking about Datacaputure Templates. An inline command is used to return xml to be part of the datacapture.cfg when a DCR is opened via a DCT. The most common use of an inline command is to return option xml to the datacapture.cfg. Unless you are explaining yourself poorly, this is what you are asking for. Please take the time to read the documentation and experiment with the examples. If you are still having problems, post your inline script and we will try to help.
~Jeff
nipper
& he says he cannot take training.....
Migrateduser
If you still need help to solve this check this web-site
http://www.teamsitehelp.com/index.shtml
.
jbonifaci
Did you actually look at that site before making your post? I don't believe that site ever got off the ground, it has absolutely no content on it. DevNet is definitely the best place to go for TeamSite related help.
~Jeff
Migrateduser
Yes I did take a look at the site and I think if "jaylaw" devnet poster sends a message to "jason@teamsitehelp.com" he might write the script for him. I know you, Fish aka Adam has already explaind him the solution three times and he keeps asking the same question again.
jbonifaci
He hasn't worked on the site in over 4 years, I would be surprised if he still uses that email address.
And even if it is, I doubt he would be willing to write the script for him, unless of course jaylaw is willing to pay for it. In which case, there would be several people here who would be willing to spend 5-10 minutes of their time to write the script for the right price.
~Jeff
Migrateduser
Yes thats what I am suggesting to "jaylaw" to pay someone to write the script, probally to you or fish, andy, me ...
jed
Example:
DCT Entry:
<item name="default_locale">
<label>Default Locale</label>
<replicant min="1" max="20">
<item name="locale">
<label>Locale</label>
<select required="t">
<inline command='/app/suncom/iw-home/local/config/dct/find-all-locales.sh' />
</select>
</item>
</replicant>
</item>
Inline Command Invoked:
#!/bin/ksh
# find any of the following:
# xx
# xx_XX
# this will only work in the KSH shell
LOCALES=`ls -d /iwmnt/default/main/*/web_site/
@([a-z]
?_[A-Z]?|[a-z]?)/ | awk -F/ {'print $7'} | sort -u `
echo "<substitute>"
for locale in $LOCALES ; do
echo "<option value=\"$locale\" label=\"$locale\" />"
done
echo "</substitute>"
Example Output from command:
<substitute>
<option value="tr_TR" label="tr_TR" />
<option value="uk" label="uk" />
<option value="uk_UA" label="uk_UA" />
<option value="yi" label="yi" />
<option value="zh" label="zh" />
<option value="zh_CN" label="zh_CN" />
<option value="zh_TW" label="zh_TW" />
</substitute>
--
Jed Michnowicz
jedm@sun.com
Content Management Engineering
Sun Microsystems
Migrateduser
Attached is the files that will do the desired functionality you are looking for
jbonifaci
I'm curious as to why you provided a solution, when you originally were pointing him to other sources. What changed your mind?
Also, just a few comments on your script:
1) You are declaring
@files
and pushing files to it, yet you are not using it anywhere. You would likely want to remove this.
2) You should not be using die, if you can't open the directory, it should return a friendly error message to the user.
3) You are not checking to see if the nodes returned by readdir are directories or files. It sounds like he only wants files. He would probably also want the files witthin any directories listed out as well.
There are a few other things as well, but they are not as important. Number 2 is likely the most important of the three things I mentioned, as it will break the DCT if it can't open the directory.
~Jeff
jbonifaci
Jed,
You are of course assuming that jaylaw is on solaris, which is likely a coin flip. I believe there is more than enough information in the documentation to create this simple script from scratch. Anyone that can't, probably shouldn't be doing development work without taking additional training. Not to mention there are plenty of inline examples floating around for someone to look at.
~Jeff
Migrateduser
Hi Jeff,
Once you said it’s going to take only 5-10 minutes of time, I taught I can write the solution and see if other have any pointer that will improve my skills.
I think you could have done lot better that me in the same time and appreciate the suggestions that you pointed out in the solution. I did try to fix the list of things that you suggested in your previous post but not sure if I did address all of them.
How can I sort the filelist so that all the files are sorted by filename and depth? (Do I need to write my own sort sub-routine.)
Thanks for the input Jeff.
~ batasari.
jbonifaci
I'm glad you took the suggestions in a positive way, some people get offended when others critique their work. The way I see things, anything that helps you become a better developer is a good thing.
As far as the sorting goes, yes you would probably have to write your own sort routine. Another solution would be to do your sorting as you recursively read in sub directories.
~Jeff