Nested Sections!

Highlighted
New Member
3 0 0

@MaxDesign 


@MaxDesign wrote:

@asad16 Some information is lacking in your code.

Say you have a section "random-section", and you want to insert inside it a section named "video".
In your case, you should go for something like this (beware, this code goes inside a template file, not inside a section file): 

 

{% capture video_1 %}{% section 'video' %}{% endcapture %}
{% assign vid = video_1 | replace: 'class="shopify-section"', 'class="shopify-section-nested"' %}
{% capture random_section %}{% section 'random-section' %}{% endcapture %} {% assign random_section = random_section | replace: "%%insert-video-section%%", vid %}
{{
random_section }}

And then you include inside your "random-section" :

 

%%insert-video-section%%

 
Hope it makes sense,
Cheers



but can you explain (how to/where to) add  %%insert-video-section%%

in my randon section

0 Likes
Highlighted

but can you explain (how to/where to) add  %%insert-video-section%%

in my randon section

Just paste

%%insert-video-section%%

where you want the section to be, it's up to you where you need the section to appear in your other section. I presume you have knowledge in html/css, (and eventually liquid) if you want to do this by your way with little issues, else you might need to reach out to someone with more expertise.

I can't explain better here, maybe someone else would.
Best of luck,
Max 

C'est simple comme bonjour ! Ou presque.
Need some help to customize your website? Message me anytime: 5euros.com/profil/maxdesign
0 Likes
Highlighted
Shopify Partner
8 0 3

Brilliant idea. I tried this using blocks.  I've been finding a solution for a nested block for years but no luck, until I read about this yesterday.

 

The Idea is the same as what is posted here... but instead of adding the text

%%section-replacer%%

 

directly to the section file I added it using blocks and condition. This way you can sort the position of the nested section in the page

 

{% for block in section.blocks %}
    {% case block.type %}
        {% when 'your-gallery' %}
            <!-- hack that shit-->
            %%YOUR-GALLERY%%

        {% else %}
            Normal blocks code....
    {% endcase %}
 {% endfor %}

 

Here are the results in admin ;)

 

We add the nested section using blockWe add the nested section using block

 

This way we can sort the position of the nested section along with the blocks. 

 

for-post2.png

 

 

 

 

1 Like

Hi everyone,

My question is a bit more advanced. How would you use this "hack" on the home page? I need to do this with a section that can only be loaded through presets, so it's a dynamic section that is not fetched from a template file, it is only in a section file.

I'm thinking about it and I don't see a clear (nor clean) way trough.

Thank you hips,
Max

C'est simple comme bonjour ! Ou presque.
Need some help to customize your website? Message me anytime: 5euros.com/profil/maxdesign
0 Likes