Home
TeamSite
adding metadata to an html file
snair
hi
I have setmetadata to an html file using metatagger.I would like to attach the metadata to the html file itself.I would like to know whether it is possible and if so which is the simplest way to acheive that
thanks
nair
Find more posts tagged with
Comments
abhishek_gupta
Use iwmetadata.cgi to set metadata to a file. Provide a link in the File Menu, by changing the iw.cfg file.
AK
Interwoven Consultant
snair
hi
thank you for the reply
using that way only I set the metadata.Now I have to add the metadata in the meta tag of an html file.How can I do it?
Ottawa_IWOV
Hello,
I assume you want to grab the values from the Extended Attributes and bring them into the <meta>.*</meta> section of the rendered HTML.
To do this you need to use the command line tool iwextattr.
Throw together something like this...
iwextattr -g "TeamSite/Metadata/.*" $path_to_file. Get this working from the command line to you can ee exactly how it works. Remeber that the path to the file needs to be from Y:/ (Windows) or .iwmnt (Solaris)
The best way to achieve your objective is to set up a child template that simply renders the <meta>.*</meta> section of your HTML file. Then use arbitrary Perl code inside the child .tpl to call the above mentioned command line tool.
Look at the following as an example...
my $title = getEA($path, "TeamSite/Metadata/Title");
The getEA subfunction looks like this, althought it may vary...
sub getEA
{
my $file = shift;
my $eaname = shift;
my $eacmd;
my $value;
my $eaargs;
if ($eaname) {
$eaargs = '-g "'.$eaname.'" -u "'.$file.'"';
}
else{
$eaargs = "$file";
}
$eacmd = "$iwhome/bin/iwextattr $eaargs";
$value = `$eacmd`;
$value =~ s/\s*$//;
$value =~ s/\\//g; #removes back slash
$value =~ s/\s+,/,/g; #strips extra spaces
return $value;
}
Once you have the $value returned you can simply plunk that variable into your meta value...
...
<meta name="dc.title" content="{iw_value name='$title'}" />
...
That's it. Remember that all Perl code needs to go in <iw_perl>...</iw_perl> tags..
To call the child template, go to your parent template and insert
<iw_include pt="path to child tpl"/>. Remeber this should be outside of CDATA blocks (if you use them...)
Now, everytime you generate the page, the child template will be called, so if you metadata changes, it will always be reflected on your rendered HTML page...
Cheers,
Lucas Cochrane
Lucas Cochrane
lcochrane@dc.com
snair
Thank you
thriventman
Lucas,
Besides adding metadata to an html file, have you also or anyone added metadata to a pdf or word document?
Thanks Alot!
Ottawa_IWOV
No I have not dealt with this. We are strictly dealing with web content (i.e. html, shtml)
Good Luck!
Let me know if you figure anything out...
Lucas.
Lucas Cochrane
lcochrane@dc.com
thriventman
Thanks Lucas!
I most certainly will post it.
kellyrmilligan
Hello, I assumed that this would be the way to go, but haven't used child tpl's yet. if you use that child tpl does it still know the path to the dcr from the parent tpl? or do you have to pass the path to the child tpl? This would definitely be the way to go, especially when there are multiple developers building templates.