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)
Dynamic creation of dct
panomaat
Hello,
I want to create a dynamic dct. The dynamic thing about ist, is thet there shall be different elements for every file in a specific directory. My idea is to read the directory-structure and then create form-elements for every file.
My solution so far is calling an ipl in the datacapture.cfg that uses File::Find to determine which files are located inside a directory.
Then, I am using the filenames to create new items in the datacapture.cfg.
Example:
--- datacapture.cfg---
<container name="Damenmode">
<inline command="/iwmnt/default/main/OTTO_MULTISITE/OTTO_DE/OTTO_DE_PROD/STAGING/_system/ov-bin/banner_utils.ipl" />
</container>
--- End of datacapture.cfg---
--- banner_utils.ipl ---
#!/iw-home/iw-perl/bin/iwperl -w
use File::Find;
my $outString = "";
my $shopPageDir = "/.iwmnt/default/main/OTTO_MULTISITE/OTTO_DE/OTTO_DE_PROD/WORKAREA/MW-EM-S/SHOPSEITEN/01_Damenmode";
sub readShopPageDir{
$outString .= "<item name=\"N_".$_."\"><text required=\"f\" size=\"5\" /></item>";
}
find(\&readShopPageDir, $shopPageDir);
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <substitution>\n $outString\n </substitution>\n";
--- End of banner_utils.ipl ---
The strange thing is that I don't get a complete list of all the files in the directory.
Only some of the files seem to be recognized, others not.
Does anyone have an idea what is wrong?
Thanx a lot.
Pano
TS 5.5.3, Solaris
Find more posts tagged with
Comments
kshitiz
Have you checked the permissions for the files. May be the user who is running the script doesn't have permissions on those files which are not getting listed.
Kshitiz Sharma
BT Wholesale | CMS
Mahindra British Telecom
Adam Stoller
Is your intent to get all files and directories and subdirectories and their files, etc.?
Or just to get the files in a directory and all of its subdirectories?
Or just to get the files in a given directory and not recurse?
You might do better to write your own routine for getting the files than using File::Find - something like:
sub get_files{
my $dir = shift;
my $items = q{};
if (!opendir(DIR, "$dir")){
# error
}
my
@contents
= readdir(DIR);
closedir(DIR);
foreach(
@contents){
next if -d "$dir/$_";
my $label = $_;
$_ =~ tr|\s|_|; # generally don't want spaces in item names
$items .= join(q{},
qq{<item name="N_$_">},
qq{<label>$label</label>},
qq{<text size="5"/>},
qq{</item>\n}};
}
return $items;
}
my $shopPageDir = "......";
print join(q{\n},
qq{<?xml verision="1.0" encoding="UTF-8"?>},
qq{<substitution>},
get_files($shopPageDir),
qq{</substitution>\n});
Mind you, I have no idea how reasonable this is to do this in the first place (dynamic DCT) - but perhaps the above will help
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Migrateduser
one thing that jumps out at me is that you're using your directory path with the "/.iwmnt" designation versus "/iwmnt"...the former is a cached version...
when you say that you don't get a complete list of all files in the directory, is it possible that the files you are getting are earlier ones? that the list through the cached mount (/.iwmnt) just hasn't had time to update yet?
try it through the un-cached mount point (/iwmnt) and see if there's a difference...
cheers,
-Rori
Adam Stoller
Rori - I believe you have it backwards - /iwmnt is cached - /.iwmnt is not-cached
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
panomaat
Hello again,
first of all I thank you all for your answers.
I managed to solve the problem but I have no idea what was wrong.
I just created a counter to see if I can find an error in the find::file iteration... and suddenly it worked.
After removing the counter again it still worked fine.
The only difference was, that I created a new dcr and did not open an existing one.
The next time I have such a behaviour, I maybe should just reeboot my computer :-)
Thanx again for your help.
Pano
TS 5.5.3, Solaris
Migrateduser
doh! should have double-checked before I posted, sorry about that...guess I've been working with windows for too long LOL...
cheers,
-Rori