Linking categories to external urls in the "Copenhagen theme", stopped working

11 Comentarios

  • Simon Celen

    Hi Andreas,

    It seems there's an error in the script.js file of your theme. Near the bottom there is a line commented out that includes a critical Javascript construct:

    /*  $('footer.footer').before('<div class="footer-social"><div>... snip ...</div></div>');
    });
    */

    That last }); is needed for the whole script to function.

    Change it to:

    /* $('footer.footer').before('<div class="footer-social"><div>... snip ...</div></div>');
    */
    });

    ... and things will start working again.

    1
  • Brett Bowser
    Zendesk Community Team

    Hey Andreas,

    Could you provide the code you're using to link your Category to an external URL? Additionally, the link you provided doesn't appear to be working for me. Is there another link I should be accessing?

    0
  • Andreas Ribbfors

    The code I'm using for that is the following:

    //In the script file
    document.getElementById('cat-360002138560').href = 'https://www.soluno.se/driftinformation';

     

    and in the home_page:

    <a href='{{url}}' class="blocks-item-link" id="cat-{{id}}">

    The link is directed to https://helpcenter.soluno.se/hc/sv

    0
  • Andreas Ribbfors

    Lovely, you are terrific! :D

    0
  • Donna Fairhurst

     

    Ifra Saqlain

    I am trying to link category block to an external url but using what is shared is not working and not sure why

    Added this to my home_page.hbs:
    {{#each categories}}
    {{#if ../has_multiple_categories}}
    <li class="blocks-item">
    <a href='{{url}}' class="blocks-item-link" id="cat-{{id}}">

    In script.js I have added:

    // CUSTOM: override category links
    document.getElementById('cat-200150087').href = 'https://support.gradecam.com/tutorial_cate/teachers/';
    }
    });

    It is still directing to https://gradecam.zendesk.com/hc/en-us/categories/200150087-Teacher-Account-Support-

    Any help would be appreciated.

    Thank you,
    ~Donna

    0
  • Trapta Singh
    Community Moderator

    Hi Donna Fairhurst,

    You can replace the below line in your code:

    <a href='{{url}}' class="blocks-item-link" id="cat-{{id}}">

    with

    <a href='{{#is id 200150087}} https://support.gradecam.com/tutorial_cate/teachers/ {{else}} {{url}} {{/is}}' class="blocks-item-link" id="cat-{{id}}">

    You don't have to add any custom script code to do so. Let us know how it goes for you.

    Thanks

    0
  • Ifra Saqlain
    Community Moderator

    Hi Donna,

    Your category isn't redirecting to external webpage because you have add AN extra bracket. YOUR CURRENT SCRIPT CODE -

    // CUSTOM: override category links
    document.getElementById('cat-200150087').href = 'https://support.gradecam.com/tutorial_cate/teachers/';
    }    //It's a extra bracket which must be remove to work
    });

     

     

    See I'm doing..

     

    Just add it single line,

    document.getElementById('cat-200150087').href = 'https://support.gradecam.com/tutorial_cate/teachers/';

     

    });   --  //It's my closing tag and already added because we always write JS code inside the DOM function.

     

    See you have also closing tag in your script code, only copy that single line and paste inside this closing tag and then test well.

     

    and your console is showing an error for setTimeout() may be that's the issue your category not redirecting if you are doing right as I told above to add just single line code of  'document.getElementById('cat-200150087').href = 'https://support.gradecam.com/tutorial_cate/teachers/';'

     

    OR you have another way to redirect your specific category to external webpage-

     

    You have currently this code on your home_page.hbs

     {{#each categories}}
    {{#if ../has_multiple_categories}}

    <li class="blocks-item">
    <a href='{{url}}' class="blocks-item-link" id="cat-{{id}}">
    <span class="blocks-item-title">{{name}}</span>
    <span class="blocks-item-description">{{excerpt description}}</span>
    </a>
    </li>

    {{else}}
    {{#each sections}}
    <li class="blocks-item">
    <a href='{{url}}' class="blocks-item-link">
    <span class="blocks-item-title">
    {{name}}
    </span>
    <span class="blocks-item-description">{{excerpt description}}</span>
    </a>
    </li>
    {{/each}}
    {{/if}}
    {{/each}}

     

    Find for this line in the given code  <a href='{{url}}' class="blocks-item-link" id="cat-{{id}}">

    So now check your category ID with the {{#IS}} condition.

     

    Meanwhile, remove it -

    <a href='{{url}}' class="blocks-item-link" id="cat-{{id}}">

     

    and add this code -

    <a href='{{#is id 200150087}} https://support.gradecam.com/tutorial_cate/teachers/ {{else}} {{url}} {{/is}}' class="blocks-item-link" id="cat-{{id}}">

     

    If any bug let know :);

     

    Thanks

    0
  • Donna Fairhurst

    Ifra Saqlain

    Thank you thank you!!

    OK got one to work!! yea but have 4 categories.  When I try to add three more it makes my category boxes go super weird sizes.

    This is what I have and this link works but I need to link 3 more categories:

    {{#each categories}}
    {{#if ../has_multiple_categories}}
    <li class="blocks-item">
    <a href='{{#is id 200150087}} https://support.gradecam.com/tutorial_cate/teachers/ {{else}} {{url}} {{/is}}' class="blocks-item-link" id="cat-{{id}}">
    <span class="blocks-item-title">{{name}}</span>
    <span class="blocks-item-description">{{excerpt description}}</span>
    </a>
    </li>

     

    When I did this didn't work so I am assuming I need to add between each one? - see bold:

    {{#each categories}}
    {{#if ../has_multiple_categories}}
    <li class="blocks-item">
    <a href='{{#is id 200150087}} https://support.gradecam.com/tutorial_cate/teachers/ {{else}} {{url}} {{/is}}'

    <a href='{{#is id 202704978}} https://support.gradecam.com/tutorial_cate/administrators/ {{else}} {{url}} {{/is}}' class="blocks-item-link" id="cat-{{id}}">

      <a href='{{#is id 202700727}} https://support.gradecam.com/videos-webinars/ {{else}} {{url}} {{/is}}' class="blocks-item-link" id="cat-{{id}}">

    class="blocks-item-link" id="cat-{{id}}">

    <span class="blocks-item-title">{{name}}</span>
    <span class="blocks-item-description">{{excerpt description}}</span>
    </a>
    </li>

    ~Donna

     

    0
  • Ifra Saqlain
    Community Moderator

    Hi Donna, 

    Please do like this then definitely your all categories will be redirect to external webpages.

        <a href='{{#is id 4404022102548}} https://support.gradecam.com/tutorial_cate/teachers/ {{else}} 
    {{#is id 4404022102548}} https://google.com/ {{else}}
    {{#is id 360004039672}} https://twitter.com/ {{else}}
    {{#is id 360003781212}} https://www.facebook.com/ {{else}}
    {{#is id 360002539551}} https://instagram.com/ {{else}}
    {{url}}
    {{/is}}{{/is}}'{{/is}} {{/is}}{{/is}} class="blocks-item-link" id="cat-{{id}}">

     

    Screenshot for the same:

     

    There would be single anchor tag under '<li class="blocks-item">' and check the category IDs with multiple {{#is....}} and  {{else}}.

    Now the syntax is:

    <a href='

    {{#is id 4404022102548}} https://support.gradecam.com/tutorial_cate/teachers/ {{else}}
    {{#is id 4404022102548}} https://google.com/ {{else}}
    {{#is id 360004039672}} https://twitter.com/ {{else}}
    {{#is id 360003781212}} https://www.facebook.com/ {{else}}
    {{#is id 360002539551}} https://instagram.com/ {{else}} {{url}} {{is}}{{is}}{{is}}{{is}}>{{is}}'  >

     

     

    You have added multiple

    <a href="....."></a>

    <a href="....."></a>

    <a href="....."></a>

    <a href="....."></a>

    so your block look weird, there would be single <a href="....."></a> with multiple category IDs under {{# id 111111}}.

     

    If any confusion let me know :)

    Thanks

    Ifr

    0
  • Donna Fairhurst

    Thanks - I entered this and then it was asking me to remove the {{each}} and {{if}} and now error showing

    Not sure if you can see into my account on my home_page.hbs

    now missing my Teacher tutorial box

    I apologize for my lack of expertise on this but appreciate your help.

    I have tried to start over with a new Copenhagen theme but it just duplicates this one and I don't want it to. I thought if I just start over some of these issues my be fixed but can't get a whole new Copenhagen theme to be created.

    ~Donna

    0
  • Ifra Saqlain
    Community Moderator

    Donna, your code have  '>' before anchor closing tag means remove '>' beside {{url}} {{/is}} {{/is}} {{/is}} {{/is}}

    your code should be like:

    <a href='{{#is id 4404022102548}} https://support.gradecam.com/tutorial_cate/teachers/ {{else}} 
    {{#is id 4404022102548}} https://google.com/ {{else}}
    {{#is id 360004039672}} https://twitter.com/ {{else}}
    {{#is id 360003781212}} https://www.facebook.com/ {{else}}
    {{#is id 360002539551}} https://instagram.com/ {{else}}
    {{url}}
    {{/is}}{{/is}}{{/is}} {{/is}}{{/is}}' class="blocks-item-link" id="cat-{{id}}">

     

    Currently your code is:

    <a href='{{#is id 4404022102548}} https://support.gradecam.com/tutorial_cate/teachers/ {{else}} 
    {{#is id 4404022102548}} https://google.com/ {{else}}
    {{#is id 360004039672}} https://twitter.com/ {{else}}
    {{#is id 360003781212}} https://www.facebook.com/ {{else}}
    {{#is id 360002539551}} https://instagram.com/ {{else}}
    {{url}} {{/is}}{{/is}}{{/is}} {{/is}}{{/is}}' > class="blocks-item-link" id="cat-{{id}}">

     

    Remove this > beside {{url}} {{/is}} {{/is}} {{/is}} {{/is}} {{/is}}

    0

Iniciar sesión para dejar un comentario.

Tecnología de Zendesk