Forum Discussion

tmarshall's avatar
tmarshall
Advisor
9 years ago

Community Structure - Common Pages - Localization

Hi,

 

I've been speaking with lithium gurus, and they suggest that I post my scenarios here for others to comment and get feedback about possible approaches.

 

We have two brands, purple which all the purple branding and imagery, and a second brand green, with all is branding and associated images/buttons. Our community is going to start localizing into 5 languages (German, French, Spanish ...) for both brands. What sort of structure is best and most efficient? What have others done?

 

Scenario 1 - Language(s) -> Brand(s)

A problem we have found is that if we structure by Language -> Purple Brand and Green Brand that the common pages (i.e. search results or my profile page), that are shared do not know what skin to use? If we apply no skin to language one is picked for us. Do other apply cookies in this scenario to apply the appropriate brand to the common page? If so how does that work and do you have access to the core components to apply cookie code?

 

Scenario 2 - Brand(s) -> Language(s)

The alternative scenario is to put Purple brand -> Language with 5 the languages live under that brand, and setup a Green Brand with all the languages under it. This uses out of the box functionality, but reporting is not as holistic. Yes, we could run two reports, and the common page problem is resolved in the first scenario.

 

Ideally, we would want scenario 1 Language -> Brand, but do not see a work around since we do not have access to allow cookie code to the common pages. I'm hoping to get what others have done to apply specific branding across all pages in a localized language.

 

Appreciate the feedback.

Thanks,

Tim

 

Below is a mock up of a structure in each scenario.

  • tmarshall - Add this code to the header and this should change the skin according the last page which user was on, i.e. if the user searched from green brand, the search page will have green skin and vice versa. Keep on adding the page names in line 2 and you can proceed with Scenario 1.

     

    <!-- The variable sticky_on_pages is contains all the pages where the "sticky skin" logic must apply -->
    
    <#assign sticky_on_pages = [ "MyProfilePage", "SearchPage" ] />
    
    <!-- If the current page has a name (should always be the case) and it is in the sticky_on_pages list, then apply the sticky skin logic. --> 
    <#if (page.name)?has_content && sticky_on_pages?seq_contains(page.name)>
    
      <#if http.session.getAttribute("skin")??>
        <#assign skin_id = http.session.getAttribute("skin") />    
        <#if utils.logs.name.common_init.debugEnabled>
          ${utils.logs.name.common_init.debug("setting skin to ${skin_id}")}
        </#if>    
        ${skin.set(skin_id)}
      </#if>  
    <#else>
       <#if coreNode.settings.name.get("skin.id")??>
        <#assign skin = coreNode.settings.name.get("skin.id")/>
        
        <#if utils.logs.name.common_init.debugEnabled>
          ${utils.logs.name.common_init.debug("storing skin ${skin}")}
        </#if>
              
        ${http.session.setAttribute("skin", skin)}
      </#if>  
    </#if>

     

    I hope this helps.

10 Replies

  • tmarshall - Add this code to the header and this should change the skin according the last page which user was on, i.e. if the user searched from green brand, the search page will have green skin and vice versa. Keep on adding the page names in line 2 and you can proceed with Scenario 1.

     

    <!-- The variable sticky_on_pages is contains all the pages where the "sticky skin" logic must apply -->
    
    <#assign sticky_on_pages = [ "MyProfilePage", "SearchPage" ] />
    
    <!-- If the current page has a name (should always be the case) and it is in the sticky_on_pages list, then apply the sticky skin logic. --> 
    <#if (page.name)?has_content && sticky_on_pages?seq_contains(page.name)>
    
      <#if http.session.getAttribute("skin")??>
        <#assign skin_id = http.session.getAttribute("skin") />    
        <#if utils.logs.name.common_init.debugEnabled>
          ${utils.logs.name.common_init.debug("setting skin to ${skin_id}")}
        </#if>    
        ${skin.set(skin_id)}
      </#if>  
    <#else>
       <#if coreNode.settings.name.get("skin.id")??>
        <#assign skin = coreNode.settings.name.get("skin.id")/>
        
        <#if utils.logs.name.common_init.debugEnabled>
          ${utils.logs.name.common_init.debug("storing skin ${skin}")}
        </#if>
              
        ${http.session.setAttribute("skin", skin)}
      </#if>  
    </#if>

     

    I hope this helps.

  • tmarshall's avatar
    tmarshall
    Advisor
    9 years ago

    VarunGrazitti

     

    Thank you very much for your reply. I'll try it out. A colleague asked me to validate this approach with Lithium to confirm if it is an official API that is supported and will not be something that Lithium may deprecate or change without any notice. KristinaV can you please validate this one ;)

  • tmarshall's avatar
    tmarshall
    Advisor
    9 years ago

    Hey VarunGrazitti

     

    I tried out the code today, and put copy/paste it in the "Page Head Top Content or "Page Header Bottom Content" in the wrapper on both the green skin and the purple skin. I then applied the appropriate skin to the category (i.e. the purple skin to Purple Brand category, and the green skin to the Green Brand category). I did not change the skin in the parent category "French" - I left the green skin applied to the language.

     

    Below is the code I used which is slightly updates with more pages, but when I click on profile when from purple categories it flips to the incorrect.

     

    <!-- The variable sticky_on_pages is contains all the pages where the "sticky skin" logic must apply -->
    
    <#assign sticky_on_pages = [ "MyProfilePage", "SearchPage", "ViewProfilePage", "FaqPage"] />
    
    <!-- If the current page has a name (should always be the case) and it is in the sticky_on_pages list, then apply the sticky skin logic. --> 
    <#if (page.name)?has_content && sticky_on_pages?seq_contains(page.name)>
    
      <#if http.session.getAttribute("skin")??>
        <#assign skin_id = http.session.getAttribute("skin") />    
        <#if utils.logs.name.common_init.debugEnabled>
          ${utils.logs.name.common_init.debug("setting skin to ${skin_id}")}
        </#if>    
        ${skin.set(skin_id)}
      </#if>  
    <#else>
       <#if coreNode.settings.name.get("skin.id")??>
        <#assign skin = coreNode.settings.name.get("skin.id")/>
        
        <#if utils.logs.name.common_init.debugEnabled>
          ${utils.logs.name.common_init.debug("storing skin ${skin}")}
        </#if>
              
        ${http.session.setAttribute("skin", skin)}
      </#if>  
    </#if>

    As a test, I went to the "French" category and applied "none" as skin, then whatever 'default' skin is applied to "Top Level Community" will be applied. The sticky code does not appear to be working, but then again I might not be applying it correctly. Thanks again for your help, and appreciate if you can go into a bit more detail on if I missing something.

     

    Thanks,

    Tim 

  • tmarshall's avatar
    tmarshall
    Advisor
    9 years ago

    I put the code in "Page Initialization" under Advanced and it worked. Thanks for your help.

  • satya's avatar
    satya
    Expert
    8 years ago

    Hi VarunGrazitti

     

    That was a great solution you have provided. I have a similar requirement and I used the code snippet which you mentioned and placed in Page initialization. But I got an issue i.e., I have two categories category A and category B, I have opened two categories (category A first and then category B next) and then I opened the MyProfile page from category A I am able to see the category B Skin as it is loaded last. Is there any code change or workaround for this scenario.

     

    Thanks,

    Srujana Satya Datla.

  • tmarshall's avatar
    tmarshall
    Advisor
    8 years ago

    satyaIt should work. My only suggestion is to make sure you have the page name identified.

     

    Here are all the pages I identified that are common. Hope this helps. If you find more let me know ;)


    <#assign sticky_on_pages = [ "MyProfilePage", "SearchPage", "ViewProfilePage", "FaqPage", "MobileCategoryPage", "MobileSearchPage"] />

  • tmarshall's avatar
    tmarshall
    Advisor
    8 years ago

    Hey @VarunGrazitti , 

     

    Hope you are well and making great communities! The code for making the skins apply to common pages has worked great the last 2ish years. Now, we are moving to responsive skins but the sticky code appears to no longer be recognized in our testing? Have you experienced this issue? Not clear why it is working prior and not any more? Any additional advice would be great!

     

    Thanks,

    Tim 

  • VarunGrazitti's avatar
    VarunGrazitti
    Boss
    8 years ago
    Hi tmarshall - Yes, we continue to expand and make great communities.

    Coming to your question - I'd like some additional details, have you changed the community structure/ id's etc. Otherwise, that shouldn't have any issues. Also, when the code was migrated, make sure everything was exported, both from the studio and admin. Moreover, since you can see the errors, try to debug them and see what are the missing links. That should help you nail down the issue.

  • tmarshall's avatar
    tmarshall
    Advisor
    8 years ago

    Hi VarunGrazitti , 

     

    No we have not changed the structure - the IDs are the same on stage as in production. Any tips on debugging since it is on the page initialization page I do not want to lock myself out.