More in this section

Forums / Developing with Sitefinity / Work around for sharing tags across modules?

Work around for sharing tags across modules?

2 posts, 0 answered
  1. UI Crew
    UI Crew avatar
    151 posts
    27 Sep 2012
    28 Jan 2009
    Link to this post

    I have 2 generic content based modules "Desitnations" and "Packages".

    I have a need to use tags for "towns" and have exactly the same tags in both modules - I know this is not possible at present but I have an idea but need help to understand if it is possible and if so what I can do to hook into the api to accomplishment it.

    Here is my idea:

    I am aware of the create, find, modify and delete tag methods and I was wondering if there was somewhere in the api where I could through my own class hook into the code at the right time and create, modify and delete the tags in the other module when a content manager does either of these activities on the alternate module.

    So for instance in Module A the user creates a tag called "Cairns" and as that is being fired off also create a tag in Module B with the same name and vice versa. Also do this when tags are being deleted and modified.

    Help would be greatly appreciated.


  2. Parvan
    Parvan avatar
    151 posts
    24 Sep 2012
    03 Feb 2009
    Link to this post
    Hello Seth Cleaver,

    Thank you for contacting us.

    The best place to catch the changes of the tags is in the content providers. You should have your provider classes  for the custom modules. You can override your providers's methods SaveTag and DeleteTag.
    We supply a sample code which makes synchronization between the tags of two modules. We tested this sample with News and Blogs module (see the attached files).
    To test this solution for your providers you must follow these steps:

    1. Make sure that the tags in the two modules are absolutely equal as and count,names. This is important for the proper working of synchronization. An easy way to accomplish this is to delete all the tags in the two modules.
    2. Override SaveTag and DeleteTag methods of your module's providers:
    public override void SaveTag(ITag tag)  
        string tagNewName = GetTag(tag.ID).TagName;  
        // TODO synchronize   
        SyncTagsHelper.UpdateTag(Name, tagNewName);  
    public override void DeleteTag(Guid tagID)  
        string tagToDelete = GetTag(tagID).TagName;  
        // TODO synchronize  
        SyncTagsHelper.DeletedTad(Name, tagToDelete);  
    3. Put the file SyncTagsHelper.cs in your site App_Code folder

    Note:  Each module have separate tags. It is not possible tags to be shared for two modules.
    There is only one solution, which can make tags to be used by two modules, but it will not work for all the modules. If you set Application names of two providers to be equal, the tags will be shared between them too. The application names of providers are set in the web.config:
    <cmsEngine defaultProvider="Generic_Content">   
        <clear /> 
        <add name="News" ... applicationName="/News" .../> 
        <add name="Blogs" ... applicationName="/Blogs" ... /> 

    Hope this will help you.

    Kind regards,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
2 posts, 0 answered