2

I have a category with keywords which in their tern have metadata schema. That schema consist of two fields and each of them is category. Very simple structure, but during publishing it resolves those metadata keyword fields into wrong tcm uris instead of title of the keyword, like the following:enter image description here

2) Content of the deployer package

    <tcmc:Topic rdf:about="tcm:10-11325-1024">
      <rdfs:label>Analytics and optimization</rdfs:label>
      <rdfs:comment>Analytics and optimization</rdfs:comment>
      <tcmt:key>Analytics and optimization</tcmt:key>
      <tcmt:isAbstract>false</tcmt:isAbstract>
      <tcmt:isRoot>true</tcmt:isRoot>
      <tcmt:metadata rdf:parseType="Literal">
      <Metadata xmlns="uuid:a30b06d3-b6c5-4c2e-a53b-2b88771370ed"> 
        <Divisions xlink:title="cma" xmlns:xlink="http://www.w3.org/1999/xlink"         xlink:href="tcm:0-17737-1024">cma</Divisions>
        <InterestProfile xlink:title="CMAAnalytics" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="tcm:0-11175-1024">CMAAnalytics</InterestProfile> 
      </Metadata>
    </tcmt:metadata>
   </tcmc:Topic>

3) In code where I query Tridion it returns these uris:

    TaxonomyFactory taxonomyFactory = new TaxonomyFactory();
    TKeyword taxonomy = taxonomyFactory.GetTaxonomyKeywords(“tcm_of_the_category”);
    if (taxonomy != null && taxonomy.KeywordChildren != null)
    {
        foreach (var item in taxonomy.KeywordChildren) //keyword metadata contains tcm uri with zero instead of title
        {
           Keyword keywordChildren = item as Keyword;
           if (keywordChildren != null)
           {
               . . . 
           }
        }
    }

Does anyone have any ideas what might cause such an issue?

Nuno Linhares
  • 10,214
  • 1
  • 22
  • 42
beardeddev
  • 565
  • 1
  • 5
  • 15

2 Answers2

3

At a glance, my guess is that the internal template used to transform the categories is reading the metadata field data directly from the DB (or near enough in the BL layer) and not applying any blueprinting rules to it (likely for performance).

If you look at TCM Uris in content, when stored in the database, they all use 0 as their publication ID, and this ID is modified at "read" time.

Your call: You can call this a defect, ask Tridion to fix it, and it will degrade the performance of publishing a category, or you can deal with it in the delivery side - you know the publication Uri is 0, and you know you need to replace it with the current publication ID if you intend to use it for any purpose.

EDIT

So I went back and did some quick hacking. Indeed you can't load the keyword's content because, according to Tridion, the "Value" of field "Divisions" is the keyword URI. No way around that.

Quick way around this: load the keyword in question:

TaxonomyFactory tf = new TaxonomyFactory();
Keyword taxonomy = tf.GetTaxonomyKeywords("tcm:5-369-512");
if(taxonomy != null && taxonomy.KeywordChildren != null)
{
    foreach (Keyword item in taxonomy.KeywordChildren)
    {
        NameValuePair key = (NameValuePair) item.KeywordMeta.NameValues["Field1"];
        string correctUri = key.Value.ToString().Replace("tcm:0-", "tcm:5-");
        Keyword theOtherKeyword = tf.GetTaxonomyKeyword(correctUri);
        string title = theOtherKeyword.KeywordName;
    }
}

Now... you probably want to be a bit smarter than me on that creative publication ID rewrite :)

Nuno Linhares
  • 10,214
  • 1
  • 22
  • 42
  • Thank you for reply, Nuno. So in other words with current implementation of Tridion I cannot get titles of the keywords in KeywordMeta dictionary, can I? Will KeywordMeta property always contain tcm uri with zero as publication in keyword fields? – beardeddev Feb 27 '13 at 14:09
  • Not sure I follow you. The title is there in the metadata. If you want more control on this you'll have to write your own template that publishes this information as a page, for instance. Short example here: http://nunolinhares.blogspot.com/2010/04/outputting-keyword-hierarchy-in-xml.html – Nuno Linhares Feb 27 '13 at 14:15
  • Sorry, let me clarify that. When I access ((NameValuePair)((Keyword)item).KeywordMeta.NameValues["InterestProfile"]).Value it equals to tcm uri (e.g. tcm:0-17786-1024) and I would like to have title instead of it. Is that possible? – beardeddev Feb 27 '13 at 15:24
  • Got it. Not sure, I'll have to try it out later today. – Nuno Linhares Feb 27 '13 at 16:12
  • Thank you for the code example, but honestly saying I've already created similar fix. The most weird that it used to work on our dev environment some time ago (I mean the keyword resolved into title). It might be because of HR1 update but I am not sure. Anyway this answer is acceptable. – beardeddev Feb 28 '13 at 08:52
1

You can see the field as a Component Link, you link to a specific Keyword item (object). Therefor you primarily get the URI, and I don't think that it resolves automatically to the Value property.

So the next step would be to obtain the Keyword object using the URI, and possibly construct the URI to include the right publication context.

Arjen Stobbe
  • 1,684
  • 9
  • 15