Jump to content

How to change the order display of blocks on mobile version

Recommended Posts

Site URL: https://www.romivanderlinden.nl

I have been trying to change the order on the mobile version, on desktop version everything is fine. 

On phone the order is :

01. beautyboosters

03. rpd

the vertical line

02. butterfly

04. material research

More work button

-

But I would like to have: 

01. beautyboosters

02. butterfly

03. rpd

04. material research

the vertical line

More work button

 

Is there a way to fix this? I also have this issue on the following pages: 

https://www.romivanderlinden.nl/photography

https://www.romivanderlinden.nl/graphic-design

As in on desktop it is from 1, 2, 3, 4... etc.. and on mobile it is 1, 4, 7, 10 etc.. 

 

Thanks in advance! 

Link to comment
On 10/7/2021 at 5:31 PM, Romivdl said:

Site URL: https://www.romivanderlinden.nl

I have been trying to change the order on the mobile version, on desktop version everything is fine. 

On phone the order is :

01. beautyboosters

03. rpd

the vertical line

02. butterfly

04. material research

More work button

-

But I would like to have: 

01. beautyboosters

02. butterfly

03. rpd

04. material research

the vertical line

More work button

 

Is there a way to fix this? I also have this issue on the following pages: 

https://www.romivanderlinden.nl/photography

https://www.romivanderlinden.nl/graphic-design

As in on desktop it is from 1, 2, 3, 4... etc.. and on mobile it is 1, 4, 7, 10 etc.. 

 

Thanks in advance! 

Why don't you use the Gallery section that make it easier to order your title and image?

Greeting, it's BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Keyword Highlighter
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment
On 10/10/2021 at 3:47 AM, bangank36 said:

Why don't you use the Gallery section that make it easier to order your title and image?

I tried with gallery, but it didn't go specifically how I wanted it. So I added each text + image individually. Which works, only not for mobile version sadly. So if you have a solution, let me know! Thanks any how. 

Link to comment
1 hour ago, Romivdl said:

I tried with gallery, but it didn't go specifically how I wanted it. So I added each text + image individually. Which works, only not for mobile version sadly. So if you have a solution, let me know! Thanks any how. 

I may come up with a js solution for this,

Greeting, it's BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Keyword Highlighter
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment

Step 1: Home > Settings > Advanced > Code injection > footer 

<script>
  /**Create Mobile Node**/
  const section = 'section[data-section-id="613a343c224a8356765c6354"]';
  const sectionEl = document.querySelector(section);
  const imageBlocks = sectionEl.querySelectorAll(".image-block");
  const htmlBlocks = Array.from(imageBlocks).map((img) => {
      const htmlBlock = img.nextSibling;
      return htmlBlock;
  });
  /*set html and img into new array, each item in array is object with img and text block*/
  let sectionMobileList = [];
  const sectionLength = Math.min(htmlBlocks.length, imageBlocks.length);
  for (let i = 0; i < sectionLength; i++) {
      sectionMobileList.push({
          img: imageBlocks[i].cloneNode([true]),
          text: htmlBlocks[i].cloneNode([true])
      });
  }
  /* sort array with text in text block */
  sectionMobileList.sort((a, b) => {
      return parseInt(a.text.textContent.substring(0, 2)) - parseInt(b.text.textContent.substring(0, 2));
  })
  /*generate html node for mobile*/
  const htmlMobileWrap = document.createElement('div');
  htmlMobileWrap.classList.add('mobile-Wrapper');
  sectionMobileList.forEach(item => {
      const htmlItem = document.createElement('div');
      htmlItem.classList.add('mobile-item');
      htmlItem.insertAdjacentElement('beforeend', item.img);
      htmlItem.insertAdjacentElement('beforeend', item.text);

      htmlMobileWrap.insertAdjacentElement('beforeend', htmlItem)
  })
  const htmlMobileSection = sectionEl.querySelector('.content-wrapper > .content');
  htmlMobileSection.insertAdjacentElement('beforeend', htmlMobileWrap);
  /* add more work Btn */
  const workBtn = document.querySelector('#block-yui_3_17_2_1_1631737855583_9368').cloneNode([true]);

  htmlMobileWrap.insertAdjacentElement('beforeend', workBtn);
</script>

Step 2: Home > Design > Custom Css

/*Mobile wrapper*/
@media only screen and (max-width: 767px) {
  section[data-section-id="613a343c224a8356765c6354"] .content-wrapper .content > .sqs-layout {
    display: none;
  }
}

@media only screen and (min-width: 768px) {
  section[data-section-id="613a343c224a8356765c6354"] .content-wrapper .content > .mobile-Wrapper {
    display: none;
  }
}

Hope work properly on your site

Support me by pressing 👍 if this useful for you

Edited by bangank36

Greeting, it's BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Keyword Highlighter
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment
On 10/15/2021 at 3:06 PM, bangank36 said:

Step 1: Home > Settings > Advanced > Code injection > footer 

<script>
  /**Create Mobile Node**/
  const section = 'section[data-section-id="613a343c224a8356765c6354"]';
  const sectionEl = document.querySelector(section);
  const imageBlocks = sectionEl.querySelectorAll(".image-block");
  const htmlBlocks = Array.from(imageBlocks).map((img) => {
      const htmlBlock = img.nextSibling;
      return htmlBlock;
  });
  /*set html and img into new array, each item in array is object with img and text block*/
  let sectionMobileList = [];
  const sectionLength = Math.min(htmlBlocks.length, imageBlocks.length);
  for (let i = 0; i < sectionLength; i++) {
      sectionMobileList.push({
          img: imageBlocks[i].cloneNode([true]),
          text: htmlBlocks[i].cloneNode([true])
      });
  }
  /* sort array with text in text block */
  sectionMobileList.sort((a, b) => {
      return parseInt(a.text.textContent.substring(0, 2)) - parseInt(b.text.textContent.substring(0, 2));
  })
  /*generate html node for mobile*/
  const htmlMobileWrap = document.createElement('div');
  htmlMobileWrap.classList.add('mobile-Wrapper');
  sectionMobileList.forEach(item => {
      const htmlItem = document.createElement('div');
      htmlItem.classList.add('mobile-item');
      htmlItem.insertAdjacentElement('beforeend', item.img);
      htmlItem.insertAdjacentElement('beforeend', item.text);

      htmlMobileWrap.insertAdjacentElement('beforeend', htmlItem)
  })
  const htmlMobileSection = sectionEl.querySelector('.content-wrapper > .content');
  htmlMobileSection.insertAdjacentElement('beforeend', htmlMobileWrap);
  /* add more work Btn */
  const workBtn = document.querySelector('#block-yui_3_17_2_1_1631737855583_9368').cloneNode([true]);

  htmlMobileWrap.insertAdjacentElement('beforeend', workBtn);
</script>

Step 2: Home > Design > Custom Css

/*Mobile wrapper*/
@media only screen and (max-width: 767px) {
  section[data-section-id="613a343c224a8356765c6354"] .content-wrapper .content > .sqs-layout {
    display: none;
  }
}

@media only screen and (min-width: 768px) {
  section[data-section-id="613a343c224a8356765c6354"] .content-wrapper .content > .mobile-Wrapper {
    display: none;
  }
}

Hope work properly on your site

Support me by pressing 👍 if this useful for you

This works absolutely perfectly! A huge thanks!! Couldn't have worked out it otherwise!! Thankyou!! 

Link to comment
  • 4 months later...
On 2/18/2022 at 10:46 PM, AndreaDube said:

hi , is there possibly a way to use this solution with buttons?  For example, https://www.spivafordcag.com/issues screenshot-www.spivafordcag.com-2022_02.18-09_45_30.thumb.png.05c987b067794ef2b0e1bdd8363c448d.png

Which order you want on mobile?

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.