4

Is it possible to assign different field source for the different language?

For example, I have a sample template in with samplefield.

  • samplefield has a field source as /sitecore/content/Home-en for English.
  • samplefield has field source as /sitecore/content/Home-ot for Other Languages.

If not, how can we achieve this?

0
4

You can achieve the requirement by either implementing a custom field or a custom token. I would tend to use the custom token

Custom Token

Below is the code snippet you can use to implement the custom token

public class CustomTokenReplacer : ExpandInitialFieldValueProcessor
{
    private const string Token = "$customtoken";

    public override void Process(ExpandInitialFieldValueArgs args)
    {
      Assert.ArgumentNotNull(args, "args");

      // TODO: Add your own custom token replacement logic here...
    }
}

Then you patch the newly created token via the config file

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <pipelines>
      <expandInitialFieldValue>
        <processor type="YourNamespace, YourAssembly" patch:after="processor[@type='type=Sitecore.Pipelines.ExpandInitialFieldValue.ReplaceVariables, Sitecore.Kernel']"/>
      </expandInitialFieldValue>
    </pipelines>
  </sitecore>
</configuration>

Note that in the datasource on your template, you should use the token you defined. Example: $customtoken

More information is available here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.