Question

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?

Was it helpful?

Solution

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 :)

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top