Using {% if page.url == %} to point to different linklists

Highlighted
New Member
1 0 0

I want to have a landing page that point to two different sides of my business.

SHOP   and   STUDIOS

Once inside my website 

SHOP has URL shop.thefridaystudios.com   and
STUDIOS has URL thefridaystudios.com

 

I want to use...

{% if page.url =shop.thefridaystudios.com= %} use {% for link in linklists.main-menu.links %}

 {% if page.url =thefridaystudios.com= %} use {% for link in linklists.menu-studios.links %}

 

But im having trouble coding that into the site-nav.liquid page

 

Can anyone here shed some light to me?
Thanks :)

 

 

 

 

0 Likes
Highlighted
New Member
7 0 0

Ah ha, your question may have helped me with the problem of figuring out how to display the 'product types' at the top of the main product page only.  Did you figure out a solution to your question?

Below is the code I've come up with to display the 'product types,' so now I'll see if I can add your code so it only displays on the product home page and not all the individual product pages.

I've placed this code after the header in the collections.liquid page.  Now to add an 'if page.url' code and see if I can make it work:

 

<!-- Display product type up to 99 types. -->

<ul class="sidebar-module__list">

      {% for type in shop.types %}

        {% if forloop.index > 99 %} class="sidebar-module__hidden-item" {% endif %} &nbsp; &nbsp; <a{% if collection.current_type == type %} class="is-active"{% endif %} href="{{ type | url_for_type }}"> {{ type }}</a>

        {% if forloop.index > 99 %}

          {% assign viewmoreTypes = true %}

        {% endif %}

      {% endfor %}

    </ul> <br>

0 Likes
Highlighted
Shopify Expert
463 0 81

page.url would only return the part of the URL that comes after your domain if you're on a Shopify 'page'. If your page is actually a collection, you'd have to use collection.url. Looking at your current site, this would work:

{% if template contains 'page' and page.url == '/pages/the-studios' %}
  ... use studios nav
{% elsif if template contains 'collection' and collection.url == '/collections/shop' %}
  ... use shop nav
{% endif %}

I'm not sure how you're going to apply a subdomain to part of your Shopify site.

2 Likes
Highlighted
Shopify Partner
23 0 2

gina-gregory, you code gets "Liquid syntax error: Expected end_of_string but found id in "if template contains 'collection' and collection.url == '/collections/shop'""

0 Likes
Highlighted
Shopify Expert
2684 67 777

There is a typo -- elsif if should be elsif only.

Want to hire me to tweak a theme? Mail me at tairli@yahoo.com!
My post solved your problem? Like it!
I am away till Feb-15.
0 Likes
Highlighted
Excursionist
13 1 1

I have a store with 2 pages that should follow one design, and all the rest not. I have done this:

<div class="page-content rte" {% if template contains 'page' and page.url == '/pages/page-1' or page.url == 'pages/page-2' %} id="wide"{% endif %}>

This does not seem to be working.

I tried a variation of this, and did:

<div class="page-content rte" {% if template contains 'page' and page.url == '/pages/page-1' %} id="wide"{% elsif%}if template contains 'page' and page.url == 'pages/page-2' %}id="wide"{% endif %}>

This is not working either.

When I had the condition just for page 1, it worked just fine. I had done this:

<div class="page-content rte" {% if template contains 'page' and page.url == '/pages/page-1' %} id="wide"{% endif %}>

How can I add the second page into the spin?

 

For now, I have 2 if statements: 

<div class="page-content rte" {% if template contains 'page' and page.url == '/pages/page-1' %} id="wide"{% endif %} {% if page.url == 'pages/page-2' %} id="wide"{% endif %}>

0 Likes
Highlighted
Excursionist
13 1 1

I have just figured out what to do, and I am answering my own question. I just saw that comparisons are always read right to left when using multiple ands and ors. So, I had to specify page template twice, as it wasn't being read for the second page. To show you what I mean, originally I had tried:

    <div class="page-content rte" {% if template contains 'page' and page.url == '/pagespage-1' or page.url == '/pages/page-2'%} id="wide"{% endif %}>

What I needed was to put the template part in again after the or, so that I now have:

    <div class="page-content rte" {% if template contains 'page' and page.url == '/pages/page-1' or template contains 'page' and page.url == '/pages/page-2'%} id="wide"{% endif %}>

This is working beautifully. 

I hope I helped someone.

0 Likes
Highlighted
New Member
40 0 0

Hey, just want to let you know thank you so much for your solution. I have used your solution to solve my problem.

0 Likes