> For the complete documentation index, see [llms.txt](https://help.pixfizz.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.pixfizz.com/ecommerce/shopify-+-pixfizz/add-my-galleries-functionality.md).

# Add My Galleries Functionality

This guide explains how to add a My Galleries page to your Shopify store.

This guide sets up a "My Galleries" page where logged-in customers can view, create, and manage their photo galleries. Customers can upload images, browse them in a masonry grid, and view them in a full-screen lightbox.

***

#### Prerequisites

Before starting, make sure you have:

* The Pixfizz Shopify integration installed and working on your store
* The `pixfizz-setup.liquid` snippet rendering on all pages (this is part of the standard Pixfizz integration)

***

#### Step 1: Create the snippet

In your Shopify admin, go to **Online Store → Themes**, click the three-dot menu on your active theme, and select **Edit code**.

In the **Snippets** folder, click **Add a new snippet**. Name it `pixfizz-galleries.liquid`.

Paste the following code into the file:

```liquid
<style>
  .pxg-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 2rem 5rem;
  }

  /* ---- Header ---- */

  .pxg-list-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2.5rem;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    padding-bottom: 1.25rem;
  }

  .pxg-list-header h1 {
    font-size: 2rem;
    margin: 0;
    letter-spacing: -0.02em;
  }

  /* ---- Gallery card grid ---- */

  .pxg-gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
  }

  @media screen and (min-width: 750px) {
    .pxg-gallery-grid {
      grid-template-columns: repeat(3, 1fr);
    }
  }

  @media screen and (min-width: 990px) {
    .pxg-gallery-grid {
      grid-template-columns: repeat(4, 1fr);
    }
  }

  .pxg-card {
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    background: #f6f6f6;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }

  .pxg-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
  }

  .pxg-card__thumb-wrap {
    position: relative;
    padding-bottom: 75%;
    overflow: hidden;
    background: #ebebeb;
  }

  .pxg-card__thumb {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
  }

  .pxg-card:hover .pxg-card__thumb {
    transform: scale(1.04);
  }

  .pxg-card__placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #bbb;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }

  .pxg-card__info {
    padding: 0.75rem 0.9rem 0.9rem;
  }

  .pxg-card__name {
    font-weight: 600;
    font-size: 0.9rem;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* ---- Detail header ---- */

  .pxg-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    padding-bottom: 1.25rem;
    flex-wrap: wrap;
  }

  .pxg-detail-header__left {
    display: flex;
    align-items: center;
    gap: 1.25rem;
  }

  .pxg-back {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: 0.85rem;
    color: #666;
    text-decoration: none;
    flex-shrink: 0;
    transition: color 0.15s;
  }

  .pxg-back:hover {
    color: #000;
  }

  .pxg-back svg {
    width: 14px;
    height: 14px;
  }

  .pxg-detail-title {
    font-size: 1.5rem;
    margin: 0;
    letter-spacing: -0.01em;
  }

  /* ---- Upload ---- */

  .pxg-upload-progress {
    display: none;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.5rem;
    width: 100%;
  }

  .pxg-upload-progress.is-active {
    display: flex;
  }

  .pxg-upload-progress progress {
    flex: 1;
    max-width: 200px;
  }

  .pxg-upload-error {
    display: none;
    color: #c00;
    font-size: 0.82rem;
    margin-top: 0.5rem;
    width: 100%;
  }

  .pxg-upload-error.is-visible {
    display: block;
  }

  /* ---- JS column masonry ---- */

  .pxg-col-wrap {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
  }

  .pxg-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .pxg-masonry-item {
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    display: block;
  }

  .pxg-masonry-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: opacity 0.2s ease;
  }

  .pxg-masonry-item:hover img {
    opacity: 0.88;
  }

  /* ---- States ---- */

  .pxg-loading {
    text-align: center;
    padding: 4rem 0;
    color: #999;
    font-size: 0.9rem;
  }

  .pxg-loading progress {
    display: block;
    margin: 0 auto 0.75rem;
  }

  .pxg-empty {
    padding: 4rem 0;
    text-align: center;
    color: #999;
    font-size: 0.9rem;
    cursor: pointer;
  }

  /* ---- Create gallery modal ---- */

  .pxg-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 1rem;
  }

  .pxg-modal-overlay.is-open {
    display: flex;
  }

  .pxg-modal {
    background: #fff;
    border-radius: 8px;
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  }

  .pxg-modal h2 {
    margin: 0 0 1.5rem;
    font-size: 1.1rem;
    letter-spacing: -0.01em;
  }

  .pxg-modal label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    color: #444;
  }

  .pxg-modal input[type="text"] {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.95rem;
    box-sizing: border-box;
    margin-bottom: 1.5rem;
    transition: border-color 0.15s;
    font-family: inherit;
  }

  .pxg-modal input[type="text"]:focus {
    outline: none;
    border-color: #333;
  }

  .pxg-modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
  }

  .pxg-modal-error {
    color: #c00;
    font-size: 0.82rem;
    margin-bottom: 1rem;
    display: none;
  }

  .pxg-modal-error.is-visible {
    display: block;
  }

  /* ---- Lightbox ---- */

  .pxg-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.92);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 2rem 5rem;
  }

  .pxg-lightbox.is-open {
    display: flex;
  }

  .pxg-lightbox__img-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-height: 92vh;
  }

  .pxg-lightbox img {
    width: 100%;
    max-height: 92vh;
    object-fit: contain;
    display: block;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  }

  .pxg-lightbox__close {
    position: absolute;
    top: 1.25rem;
    right: 1.5rem;
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 1.75rem;
    cursor: pointer;
    line-height: 1;
    padding: 0.25rem;
    transition: color 0.15s;
  }

  .pxg-lightbox__close:hover {
    color: #fff;
  }

  .pxg-lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 50%;
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
  }

  .pxg-lightbox__nav:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
  }

  .pxg-lightbox__nav--prev { left: 1rem; }
  .pxg-lightbox__nav--next { right: 1rem; }

  .pxg-lightbox__nav svg {
    width: 20px;
    height: 20px;
    display: block;
  }

  .pxg-lightbox__counter {
    position: absolute;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.5);
    font-size: 0.8rem;
    letter-spacing: 0.05em;
  }

  .pxg-lightbox__nav[hidden] {
    display: none;
  }
</style>

<div class="pxg-wrap">

  <!-- Gallery list view -->
  <div id="pxg-list-view">
    <div class="pxg-list-header">
      <h1>My Galleries</h1>
      <button class="button" id="pxg-create-btn">New gallery</button>
    </div>
    <div id="pxg-list-loading" class="pxg-loading">
      <progress></progress>
      <span>Loading galleries&hellip;</span>
    </div>
    <div id="pxg-list-empty" class="pxg-empty" hidden>
      <p>No galleries yet. Create your first one above.</p>
    </div>
    <div id="pxg-gallery-grid" class="pxg-gallery-grid"></div>
  </div>

  <!-- Gallery detail view -->
  <div id="pxg-detail-view" hidden>
    <div class="pxg-detail-header">
      <div class="pxg-detail-header__left">
        <button class="pxg-back" id="pxg-back-btn">
          <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5">
            <path d="M10 3L5 8l5 5" stroke-linecap="round" stroke-linejoin="round"/>
          </svg>
          All galleries
        </button>
        <h2 class="pxg-detail-title" id="pxg-detail-title"></h2>
      </div>
      <div>
        <button class="button button--secondary" id="pxg-upload-btn">Upload photos</button>
        <input type="file" id="pxg-upload-input" multiple accept="image/*" style="display:none;" />
      </div>
    </div>
    <div class="pxg-upload-progress" id="pxg-upload-progress">
      <progress id="pxg-upload-bar" value="0" max="100"></progress>
      <span id="pxg-upload-label">Uploading&hellip;</span>
    </div>
    <div class="pxg-upload-error" id="pxg-upload-error">Upload failed. Please try again.</div>

    <div id="pxg-detail-loading" class="pxg-loading" hidden>
      <progress></progress>
      <span>Loading images&hellip;</span>
    </div>
    <div id="pxg-detail-empty" class="pxg-empty" hidden>
      <p>No images yet. Use the Upload photos button to add some.</p>
    </div>
    <div id="pxg-image-grid"></div>
  </div>

  <!-- Create gallery modal -->
  <div id="pxg-modal-overlay" class="pxg-modal-overlay" role="dialog" aria-modal="true" aria-labelledby="pxg-modal-title">
    <div class="pxg-modal">
      <h2 id="pxg-modal-title">New gallery</h2>
      <div id="pxg-modal-error" class="pxg-modal-error"></div>
      <label for="pxg-gallery-name">Gallery name</label>
      <input type="text" id="pxg-gallery-name" placeholder="e.g. Summer holiday" autocomplete="off" />
      <div class="pxg-modal-actions">
        <button class="button button--secondary" id="pxg-modal-cancel">Cancel</button>
        <button class="button" id="pxg-modal-submit">Create</button>
      </div>
    </div>
  </div>

  <!-- Lightbox -->
  <div id="pxg-lightbox" class="pxg-lightbox" role="dialog" aria-modal="true">
    <button class="pxg-lightbox__close" id="pxg-lightbox-close" aria-label="Close">&times;</button>
    <button class="pxg-lightbox__nav pxg-lightbox__nav--prev" id="pxg-lightbox-prev" aria-label="Previous image">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
        <path d="M15 18l-6-6 6-6" stroke-linecap="round" stroke-linejoin="round"/>
      </svg>
    </button>
    <div class="pxg-lightbox__img-wrap">
      <img id="pxg-lightbox-img" src="" alt="" />
    </div>
    <button class="pxg-lightbox__nav pxg-lightbox__nav--next" id="pxg-lightbox-next" aria-label="Next image">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
        <path d="M9 18l6-6-6-6" stroke-linecap="round" stroke-linejoin="round"/>
      </svg>
    </button>
    <div class="pxg-lightbox__counter" id="pxg-lightbox-counter"></div>
  </div>

</div>

<script>
  (function () {
    const origin = Pixfizz.Shopify.pixfizz_origin;
    let pixfizzUserId = null;

    const listView         = document.getElementById('pxg-list-view');
    const detailView       = document.getElementById('pxg-detail-view');
    const listLoading      = document.getElementById('pxg-list-loading');
    const listEmpty        = document.getElementById('pxg-list-empty');
    const galleryGrid      = document.getElementById('pxg-gallery-grid');
    const detailLoading    = document.getElementById('pxg-detail-loading');
    const detailEmpty      = document.getElementById('pxg-detail-empty');
    const imageGrid        = document.getElementById('pxg-image-grid');
    const detailTitle      = document.getElementById('pxg-detail-title');
    const backBtn          = document.getElementById('pxg-back-btn');
    const createBtn        = document.getElementById('pxg-create-btn');
    const modalOverlay     = document.getElementById('pxg-modal-overlay');
    const modalCancel      = document.getElementById('pxg-modal-cancel');
    const modalSubmit      = document.getElementById('pxg-modal-submit');
    const galleryNameInput = document.getElementById('pxg-gallery-name');
    const modalError       = document.getElementById('pxg-modal-error');
    const uploadBtn        = document.getElementById('pxg-upload-btn');
    const uploadInput      = document.getElementById('pxg-upload-input');
    const uploadProgress   = document.getElementById('pxg-upload-progress');
    const uploadBar        = document.getElementById('pxg-upload-bar');
    const uploadLabel      = document.getElementById('pxg-upload-label');
    const uploadError      = document.getElementById('pxg-upload-error');
    const lightbox         = document.getElementById('pxg-lightbox');
    const lightboxImg      = document.getElementById('pxg-lightbox-img');
    const lightboxClose    = document.getElementById('pxg-lightbox-close');
    const lightboxPrev     = document.getElementById('pxg-lightbox-prev');
    const lightboxNext     = document.getElementById('pxg-lightbox-next');
    const lightboxCounter  = document.getElementById('pxg-lightbox-counter');

    const COL_COUNT = window.innerWidth >= 990 ? 4 : window.innerWidth >= 750 ? 3 : 2;

    let currentImages  = [];
    let currentIndex   = 0;
    let currentGallery = null;

    function thumbUrl(url, size) {
      return url.replace(/thumbnail\/\d+/, 'thumbnail/' + size);
    }

    // --- Gallery list ---

    function loadGalleries() {
      listLoading.hidden = false;
      listEmpty.hidden = true;
      galleryGrid.innerHTML = '';

      fetch(origin + '/v1/galleries/_mine.json', { credentials: 'include' })
        .then(r => {
          // _mine.json redirects to /v1/users/<pixfizz user id>/galleries.json.
          // Read the Pixfizz user ID from that URL. Do not use the Shopify customer ID.
          const m = r.url.match(/\/v1\/users\/(\d+)\//);
          if (m) pixfizzUserId = m[1];
          return r.json();
        })
        .then(galleries => {
          listLoading.hidden = true;
          if (!galleries.length) { listEmpty.hidden = false; return; }
          galleries.forEach(addGalleryCard);
        })
        .catch(() => {
          listLoading.hidden = true;
          listEmpty.hidden = false;
        });
    }

    function addGalleryCard(gallery) {
      const card = document.createElement('div');
      card.className = 'pxg-card';
      card.innerHTML = '<div class="pxg-card__thumb-wrap">'
        + (gallery.preview
            ? '<img class="pxg-card__thumb" src="' + thumbUrl(gallery.preview, 600) + '" alt="' + gallery.name + '" loading="lazy" />'
            : '<div class="pxg-card__placeholder">No images yet</div>')
        + '</div>'
        + '<div class="pxg-card__info"><p class="pxg-card__name">' + gallery.name + '</p></div>';
      card.addEventListener('click', () => openGallery(gallery));
      galleryGrid.appendChild(card);
    }

    loadGalleries();

    // --- Gallery detail ---

    function buildColumns(count) {
      const wrap = document.createElement('div');
      wrap.className = 'pxg-col-wrap';
      const cols = [];
      for (let i = 0; i < count; i++) {
        const col = document.createElement('div');
        col.className = 'pxg-col';
        wrap.appendChild(col);
        cols.push(col);
      }
      return { wrap, cols };
    }

    function openGallery(gallery) {
      currentGallery = gallery;
      listView.hidden = true;
      detailView.hidden = false;
      detailTitle.textContent = gallery.name;
      loadGalleryImages(gallery);
    }

    function loadGalleryImages(gallery) {
      imageGrid.innerHTML = '';
      currentImages = [];
      detailEmpty.hidden = true;
      detailLoading.hidden = false;

      fetch(origin + '/v1/galleries/' + gallery.id + '/images.json', { credentials: 'include' })
        .then(r => r.json())
        .then(images => {
          detailLoading.hidden = true;
          if (!images.length) { detailEmpty.hidden = false; return; }

          currentImages = images;

          const { wrap, cols } = buildColumns(COL_COUNT);

          images.forEach((image, index) => {
            const item = document.createElement('div');
            item.className = 'pxg-masonry-item';
            const img = document.createElement('img');
            img.src = thumbUrl(image.preview, 800);
            img.alt = image.filename;
            img.loading = 'lazy';
            item.appendChild(img);
            item.addEventListener('click', () => openLightbox(index));
            cols[index % COL_COUNT].appendChild(item);
          });

          imageGrid.appendChild(wrap);
        })
        .catch(() => {
          detailLoading.hidden = true;
          detailEmpty.hidden = false;
        });
    }

    backBtn.addEventListener('click', () => {
      detailView.hidden = true;
      listView.hidden = false;
      currentGallery = null;
    });

    // --- Upload ---

    uploadBtn.addEventListener('click', () => uploadInput.click());

    uploadInput.addEventListener('change', () => {
      const files = Array.from(uploadInput.files);
      if (!files.length || !currentGallery) return;
      uploadInput.value = '';
      uploadFiles(files, currentGallery.id);
    });

    function uploadFiles(files, galleryId) {
      uploadError.classList.remove('is-visible');
      uploadProgress.classList.add('is-active');
      uploadBar.value = 0;
      uploadLabel.textContent = 'Uploading 1 of ' + files.length + '…';
      uploadBtn.disabled = true;

      let hasError = false;

      function uploadOne(index) {
        if (index >= files.length) {
          uploadProgress.classList.remove('is-active');
          uploadBtn.disabled = false;
          if (!hasError) loadGalleryImages(currentGallery);
          return;
        }

        const formData = new FormData();
        formData.append('data', files[index]);

        const xhr = new XMLHttpRequest();

        xhr.upload.addEventListener('progress', e => {
          if (!e.lengthComputable) return;
          const fileProgress  = e.loaded / e.total;
          const totalProgress = ((index + fileProgress) / files.length) * 100;
          uploadBar.value = totalProgress;
        });

        xhr.addEventListener('readystatechange', () => {
          if (xhr.readyState !== 4) return;
          if (xhr.status >= 400) {
            hasError = true;
            uploadError.classList.add('is-visible');
            uploadProgress.classList.remove('is-active');
            uploadBtn.disabled = false;
          } else {
            uploadLabel.textContent = 'Uploading ' + (index + 2) + ' of ' + files.length + '…';
            uploadOne(index + 1);
          }
        });

        xhr.open('POST', origin + '/v1/galleries/' + galleryId + '/images.json');
        xhr.withCredentials = true;
        xhr.send(formData);
      }

      uploadOne(0);
    }

    // --- Create gallery ---

    function openModal() {
      galleryNameInput.value = '';
      modalError.textContent = '';
      modalError.classList.remove('is-visible');
      modalOverlay.classList.add('is-open');
      setTimeout(() => galleryNameInput.focus(), 50);
    }

    function closeModal() {
      modalOverlay.classList.remove('is-open');
      modalSubmit.disabled = false;
      modalSubmit.textContent = 'Create';
    }

    createBtn.addEventListener('click', openModal);
    modalCancel.addEventListener('click', closeModal);
    modalOverlay.addEventListener('click', e => { if (e.target === modalOverlay) closeModal(); });
    galleryNameInput.addEventListener('keydown', e => { if (e.key === 'Enter') modalSubmit.click(); });

    modalSubmit.addEventListener('click', () => {
      const name = galleryNameInput.value.trim();

      if (!name) {
        modalError.textContent = 'Please enter a gallery name.';
        modalError.classList.add('is-visible');
        return;
      }

      if (!pixfizzUserId) {
        modalError.textContent = 'Could not identify your account. Please refresh and try again.';
        modalError.classList.add('is-visible');
        return;
      }

      modalSubmit.disabled = true;
      modalSubmit.textContent = 'Creating…';
      modalError.classList.remove('is-visible');

      const body = new FormData();
      body.append('gallery[name]', name);

      fetch(origin + '/v1/users/' + pixfizzUserId + '/galleries.json', {
        method: 'POST',
        credentials: 'include',
        body: body
      })
        .then(r => { if (!r.ok) throw new Error(); return r.json(); })
        .then(gallery => {
          closeModal();
          addGalleryCard(gallery);
          listEmpty.hidden = true;
        })
        .catch(() => {
          modalSubmit.disabled = false;
          modalSubmit.textContent = 'Create';
          modalError.textContent = 'Something went wrong. Please try again.';
          modalError.classList.add('is-visible');
        });
    });

    // --- Lightbox ---

    function openLightbox(index) {
      currentIndex = index;
      showLightboxImage();
      lightbox.classList.add('is-open');
      document.body.style.overflow = 'hidden';
    }

    function showLightboxImage() {
      const image = currentImages[currentIndex];
      lightboxImg.src = thumbUrl(image.preview, 1600);
      lightboxImg.alt = image.filename;
      lightboxCounter.textContent = (currentIndex + 1) + ' / ' + currentImages.length;
      lightboxPrev.hidden = currentIndex === 0;
      lightboxNext.hidden = currentIndex === currentImages.length - 1;
    }

    function closeLightbox() {
      lightbox.classList.remove('is-open');
      lightboxImg.src = '';
      document.body.style.overflow = '';
    }

    lightboxClose.addEventListener('click', closeLightbox);
    lightbox.addEventListener('click', e => { if (e.target === lightbox) closeLightbox(); });

    lightboxPrev.addEventListener('click', () => {
      if (currentIndex > 0) { currentIndex--; showLightboxImage(); }
    });

    lightboxNext.addEventListener('click', () => {
      if (currentIndex < currentImages.length - 1) { currentIndex++; showLightboxImage(); }
    });

    document.addEventListener('keydown', e => {
      if (lightbox.classList.contains('is-open')) {
        if (e.key === 'ArrowLeft'  && currentIndex > 0) { currentIndex--; showLightboxImage(); }
        if (e.key === 'ArrowRight' && currentIndex < currentImages.length - 1) { currentIndex++; showLightboxImage(); }
        if (e.key === 'Escape') closeLightbox();
      } else {
        if (e.key === 'Escape') closeModal();
      }
    });

  })();
</script>
```

Save the file.

***

#### Step 2: Create the page template

In the **Templates** folder, click **Add a new template**. Choose **page** as the type, select **Liquid** (not JSON), and name it `pixfizz-galleries`. This creates a file called `page.pixfizz-galleries.liquid`.

Replace any default content with the following:

```liquid
{% render 'pixfizz-galleries' %}
```

Save the file.

> **Tip:** If you are also setting up the Account Navigation feature, add the nav snippet above the galleries snippet:
>
> ```liquid
> {% render 'pixfizz-account-nav' %}
> {% render 'pixfizz-galleries' %}
> ```

***

#### Step 3: Create a Shopify page

Go to **Online Store → Pages** and click **Add page**.

Give the page a title, for example **My Galleries**. Leave the content area blank.

In the **Template** dropdown on the right, select **pixfizz-galleries**.

Click **Save**.

The page will be available at `/pages/my-galleries` (or whatever handle Shopify generates from your page title).

***

#### What the page does

Once installed, the page provides the following functionality for logged-in customers:

* **Gallery list**: displays all galleries belonging to the customer as a card grid with a preview thumbnail and gallery name. Galleries are loaded directly from Pixfizz using the customer's session.
* **New gallery**: a "New gallery" button opens a modal where the customer can create a new gallery by entering a name. The gallery is created in Pixfizz immediately and appears in the list without a page reload.
* **Gallery detail**: clicking a gallery card opens the image grid for that gallery, showing all uploaded images in a multi-column masonry layout.
* **Lightbox**: clicking any image opens it full-screen. Customers can navigate between images using the on-screen previous/next buttons or the left/right arrow keys on their keyboard. Pressing Escape or clicking outside the image closes the lightbox.
* **Upload photos**: an "Upload photos" button appears in the gallery detail view. Customers can select one or more images from their device. Files are uploaded directly to Pixfizz with a progress bar, and the gallery reloads automatically when complete.

***

#### Troubleshooting

* **"Something went wrong. Please try again." when creating a gallery.** Your snippet is using an older version of this code that sends the Shopify customer ID to Pixfizz. Replace the snippet with the code above. It reads the Pixfizz user ID from the gallery list response instead.
* **"Could not identify your account."** The gallery list did not load, usually because the customer is not logged in or `pixfizz-setup.liquid` is not rendering on the page. Log in and refresh.

***

#### Notes

* The template is styled to work with the **Dawn theme** out of the box. On other themes, you may need to adjust the CSS, particularly the `.button` and `.button--secondary` classes, which inherit from Dawn's stylesheet.
* Galleries and images are stored in Pixfizz, not Shopify. The page communicates with the Pixfizz API using the customer's existing Pixfizz session, which is established automatically when `pixfizz-setup.liquid` loads. No additional authentication setup is required.
* The page requires the customer to be logged in to their Shopify account. Guests will see an empty state, as they have no Pixfizz user identity associated with their session.
* This page pairs well with the My Projects page and the Account Navigation feature.
