Menu

Custom Themes - Updating Custom Links To Reflect Private/Published State

The new Custom Page feature adds the concept of private (visible to only logged in users) to Custom Links that are linked to a Custom Page. Themes prior to V1.5.1, if using Custom Pages with private pages, can update their theme manually using the following instructions.


New variables added to the CustomLink variable: is_public - this is a boolean variable that indicates whether the link should be seen by any user or just those that are logged in.


In Snippets/header_left_menu, assuming you have not changed anything, replace the code with the following:

 

{% comment %}
  These are your custom links that appear on the left side of the header.
  These links can be defined by clicking the "Custom Links" menu option on the
  left hand side of the dashboard.
{% endcomment %}
{% if site.has_custom_left_links %}
  {% for link in site.custom_left_links %}
    {% if link.is_public %}
      <li class="header-nav__item">
        <a href="{{ link.formatted_url }}" target="{{ link.target }}" class="header-nav__link">{{ link.formatted_text}}</a>
      </li>
    {% else %}
      {% if site.current_user.signed_in %}
        <li class="header-nav__item">
          <a href="{{ link.formatted_url }}" target="{{ link.target }}" class="header-nav__link">{{ link.formatted_text}}</a>
        </li>
      {% endif %}
    {% endif %}
  {% endfor %}
{% endif %}

 

In Snippets/header_right_menu, assuming you have not changed anything, replace the code with the following:


 

{% comment %}
  These are your custom links that appear on the right side of the header.
  These links can be defined by clicking the "Custom Links" menu option on the
  left hand side of the dashboard.
{% endcomment %}
{% if site.has_custom_right_links %}
  {% for link in site.custom_right_links %}
    {% if link.is_public %}
      <li class="header-nav__item">
        <a href="{{ link.formatted_url }}" target="{{ link.target }}" class="header-nav__link">{{ link.formatted_text}}</a>
      </li>
    {% else %}
      {% if site.current_user.signed_in %}
        <li class="header-nav__item">
          <a href="{{ link.formatted_url }}" target="{{ link.target }}" class="header-nav__link">{{ link.formatted_text}}</a>
        </li>
      {% endif %}
    {% endif %}
  {% endfor %}
{% endif %}

 

If you have changed either of the files, you will need to manually update the code to test if the link is public and/or there is a current user logged in.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.