c# - Sitecore - Programatically modify the source field of a template -


currently, templates have created have source fields path string.

e.g. :

"sitecore/content/test"

now if want move test folder

sitecore/content/shared/tags/test 

the links broken. if manually change use guid (using build option), :

datasource={62cf8494-b148-4b2e-9d36-52ec4cd75e13}&database=master 

if move test folder around, links remain is.

i wanted write routine runs through tree , updates source fields templates (in particular folder only), contain guid , db name. possible?

i tried doing in process method of class inherits publishitemprocessor , added appropriate entry in web.config. method called, source property of field read , cannpt modified. ideas? in advance.

the best/most efficient option here use sitecore powershell extensions modify items.

this reference point: https://sitecorepowershell.gitbooks.io/sitecore-powershell-extensions/content/working-with-items.html

you in code.

you need write routine (code or spe) starts /sitecore/templates/user defined or whatever root folder is.

recurse thru tree , items have template: template field. can check value of the source field. if 1 want change, update value , save item.

remember publish templates tree after updating values.


Comments