How to Create Bootstrap Shopify Menu Bootstrap Navbar - shopify

I would like to create a "Live Preview" button for themes in Shopify. Think about each theme as a product in Shopify and each theme product page has a "Live Preview" button that goes to the live demo page of the theme.
I would like to list all of my themes to my Shopify website with CSV ...
<div class="mainmenu-area navbar-light bg-light">
<div class="container">
<div class="row">
<div class="col-md-12">
<nav class="navbar navbar-expand-lg">
<div class="container-fluid">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
{% for link in linklists.main-menu.links %}
{% assign child_list_handle = link.title | handleize %}
{% if linklists[child_list_handle].links != blank %}
<li class="nav-item">
<a class="nav-link dropdown-toggle" id="navbarDropdown" role="button" data-bs-toggle="dropdown" href="{{ link.url }}">{{ link.title }}</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
{% for childlink in linklists[child_list_handle].links %}
<li>
<a class="dropdown-item" href="{{ childlink.url }}">{{ childlink.title | escape }}</a>
</li>
{% endfor %}
</ul>
</li>
{% else %}
<li class="nav-item">
<a class="nav-link" href="{{ link.url }}">{{ link.title }}</a>
</li>
{% endif %}
{% endfor %}
<li class="nav-item">
<a class="nav-link" href="/cart">Cart</a>
</li>
</ul>
</div>
</div>
</nav>
</div>
</div>
</div>
</div>
Here is the custom development on Shopify menus

Related

How to make boxes fields the same size

I'm using HTML and TWIG.
I have different boxes with different fields filled with data retrieved from a php call. The problem is I don't know how to make those fields (and consequently boxes) the same size.
The size of each field should be the tallest one of the group. So far I got this
As you can see, Contratto, JSer and Azienda are fine (usually always on a single line, so it shouldn't be a problem).
The problem is Note: as you can see, it goes well for single box, but having more ones just break the visualization. I'd like all fields to be the same size in their own group:
every Contratto the size of the biggest one;
every JSer the size of the biggest one;
every Azienda the size of the biggest one
and of course, the important one, every Note the size of the biggest one
Here's the code I'm using, with Bootstrap 3.3.7
{% if alerts|length > 0 %}
<div class="box box-danger">
<div class="box-header with-border">
<h3 class="box-title" style="color: #ff000f"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> I TUOI AVVISI ({{ alerts|length }})</h3>
</div>
<div class="box-body">
{% for alert in alerts %}
<div class="col-lg-3 col-md-4 col-sm-6">
<div class="shadow-box">
<div class="box-header with-border">
<h3 class="box-title" style="color: #ff000f">Avviso</h3>
</div>
<div class="box-body">
<p><b>Contratto</b>: {{ alert.getJob().getContratto().getRiferimento() }}</p>
<p><b>JSer</b>: {{ alert.getJob().getJobStationer().getNome() }} {{ alert.getJob().getJobStationer().getCognome() }}</p>
<p><b>Azienda</b>: {{ alert.getJob().getAzienda().getNome() }}</p>
<p><b>Note</b>: {{ alert.getJob().getNote() }}</p>
</div>
{% if alert.getUtente() is not null %}
<div class="box-footer" style="text-align: left">
<p><b>Modificato da</b> {{ alert.getUtente().getNome() }} {{ alert.getUtente().getCognome() }} <b>il</b> {{ alert.getDataModifica()|date('d/m/Y') }}</p>
</div>
{% endif %}
<div class="box-footer">
<a href="{{ path('job_dettaglio', { 'id_job': alert.getJob().getId(), 'dettaglio': 1 }) }}"class="link-avviso">
Vai al dettaglio <i class="fa fa-angle-right" aria-hidden="true"></i>
</a>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% endif %}
EDIT: this is the code version with columns and rows
{% if alerts|length > 0 %}
<div class="box box-danger">
<div class="box-header with-border">
<h3 class="box-title" style="color: #ff000f"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> I TUOI AVVISI ({{ alerts|length }})</h3>
</div>
<div class="box-body">
{% for alert in alerts %}
<div class="col-lg-3 col-md-4 col-sm-6">
<div class="shadow-box">
<div class="box-header with-border">
<h3 class="box-title" style="color: #ff000f">Avviso</h3>
</div>
<div class="box-body">
<div class="row">
<div class="col-sm-12">
<b>Contratto</b>: {{ alert.getJob().getContratto().getRiferimento() }}
</div>
</div>
<div class="row">
<div class="col-sm-12">
<b>JSer</b>: {{ alert.getJob().getJobStationer().getNome() }} {{ alert.getJob().getJobStationer().getCognome() }}
</div>
</div>
<div class="row">
<div class="col-sm-12">
<b>Azienda</b>: {{ alert.getJob().getAzienda().getNome() }}
</div>
</div>
<div class="row">
<div class="col-sm-12">
<b>Note</b>: {{ alert.getJob().getNote() }}</p>
</div>
</div>
</div>
{% if alert.getUtente() is not null %}
<div class="box-footer" style="text-align: left">
<p><b>Modificato da</b> {{ alert.getUtente().getNome() }} {{ alert.getUtente().getCognome() }} <b>il</b> {{ alert.getDataModifica()|date('d/m/Y') }}</p>
</div>
{% endif %}
<div class="box-footer">
<a href="{{ path('job_dettaglio', { 'id_job': alert.getJob().getId(), 'dettaglio': 1 }) }}"class="link-avviso">
Vai al dettaglio <i class="fa fa-angle-right" aria-hidden="true"></i>
</a>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% endif %}
Any suggestion?
EDIT ANSWER:
After few tries, I normalized the single row instead of single fields...single fields would not be the same height, but the row will, so this is actually fine for my final result. Here's the answer:
//CSS in head
.alertProperties {
padding-left:0px !important;
}
//Code
{% if alerts|length > 0 %}
<div class="box box-danger">
<div class="box-header with-border">
<h3 class="box-title" style="color: #ff000f"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> I TUOI AVVISI ({{ alerts|length }})</h3>
</div>
<div class="box-body">
{% for alert in alerts %}
{% if loop.index % 5 == 0 or loop.first %}
<div class="row">
{% endif %}
<div class="col-lg-3 col-md-3 col-sm-3">
<div class="box-header with-border"><h3 class="box-title" style="color: #ff000f">Avviso</h3></div>
<div class="box-body" style="border-left: 1px solid #00ACDF !important">
<div class="col-sm-12 alertProperties">
<b>Contratto</b>: {{ alert.getJob().getContratto().getRiferimento() }}
</div>
<div class="col-sm-12 alertProperties">
<b>JSer</b>: {{ alert.getJob().getJobStationer().getNome() }} {{ alert.getJob().getJobStationer().getCognome() }}
</div>
<div class="col-sm-12 alertProperties">
<b>Azienda</b>: {{ alert.getJob().getAzienda().getNome() }}
</div>
<div class="col-sm-12 alertProperties">
<b>Note</b>: {{ alert.getJob().getNote() }}</p>
</div>
{% if alert.getUtente() is not null %}
<div class="box-footer" style="text-align:left;">
<div class="col-sm-12 alertProperties">
<b>Modificato da</b> {{ alert.getUtente().getNome() }} {{ alert.getUtente().getCognome() }} <b>il</b> {{ alert.getDataModifica()|date('d/m/Y') }}
</div>
</div>
{% endif %}
<div class="box-footer">
<div class="col-sm-12">
<a href="{{ path('job_dettaglio', { 'id_job': alert.getJob().getId(), 'dettaglio': 1 }) }}" class="link-avviso">
Vai al dettaglio <i class="fa fa-angle-right" aria-hidden="true"></i>
</a>
</div>
</div>
</div>
</div>
{% if (loop.index % 4 == 0 or loop.last) %}
</div>
{% endif %}
{% endfor %}
</div>
{# </div> #}
</div>
{% endif %}
You can truncate text of the note section by forcing text on the same line with the white-space:none
p{
width:400px;
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
}
However if you wanna truncate it to more than one line you can read it more on chris coyier's article here

Adding code for Comment Boxes on Shopify Blog post in article.liquid

Im trying to add code back into shopify to allow for a comments box at the bottom of blog posts.
from my investigating, the code should exist in article.liquid, however it looks like the original developer deleted it.
I have tried entering code from Shopifys example https://shopify.github.io/liquid-code-examples/example/comment-list which produced no changes (Also I can't see there being an option to 'moderate' the comments, ideally we want to check them before they're posted on site.
Also tried a code from Github https://github.com/Shopify/Timber/blob/master/templates/article.liquid, which resulted in the below image. This code mentions 'moderate', but it didn't work.
github code error
Has anyone experience similar issue?
this is the current article.liquid code:
<div class="small-12 columns">
<article class="single-article">
<div class="article__title">
<h1 class="impact alpha">{{ blog.title }}</h1>
<h3 class="impact gamma">
<time pubdate datetime="{{ article.published_at | date: '%Y-%m-%d' }}">{{ article.published_at | date: '%b %d, %Y' }}</time> | {{ blog.title }}
</h3>
</div>
<div class="article__feature-image">
<img src="{{ article.image.src | img_url: '1024x1024' }}" alt="{{ article.image.alt }}">
</div>
<div class="article__content">
<div class="row">
<div class="small-12 medium-8 medium-offset-2 columns rte">
{{ article.content }}
</div>
</div>
</div>
<div class="article__paginate">
{% if blog.next_article or blog.previous_article %}
<div class="row">
<div class="small-12 medium-8 medium-offset-2 columns rte">
<p class="clearfix">
{% if blog.next_article %}
<span class="left impact epsilon">{{ '← Next Post' | link_to: blog.next_article }}</span>
{% endif %}
{% if blog.previous_article %}
<span class="right impact epsilon">{{ 'Previous Post →' | link_to: blog.previous_article }}</span>
{% endif %}
</p>
</div>
</div>
{% endif %}
</div>
<div class="article__author">
<div class="row">
<div class="small-12 medium-8 medium-offset-2 columns">
<div class="row">
<div class="author-image small-12 medium-3 columns">
<img src="http://www.gravatar.com/avatar/{{ article.user.email | md5 }}?s=100" />
</div>
<div class="author-details small-12 medium-9 columns">
<h4 class="impact epsilon">Written by {{ article.author }}</h4>
<p>{{ article.user.bio }}</p>
</div>
</div>
</div>
</div>
</div>
<div class="article__social clearfix">
<div class="row">
<div class="small-12 medium-8 small-centered columns">
<h4 class="epsilon impact">Share This</h4>
<br>
{% include 'snippets_share' %}
</div>
</div>
</div>
</article>
</div>

Logout button don't appear after login in django

I am trying to make a Django login form, my problem is when the user logged in with his user name and password the login button(inside my navbar) is not changing into the logout button, but it should change to the logout button. Here logout features do not appear anytime. and this system always stays in the logged in the situation. How to enable the logout option to complete the login form?
in views.py:
#login_required
def user_logout(request):
logout(request)
return HttpResponseRedirect(reverse('index'))
def user_login(request):
if request.method == "POST":
username = request.POST.get('username')
password = request.POST.get('password')
user = authenticate(username=username, password=password)
if user:
if user.is_active:
login(request, user)
return HttpResponseRedirect(reverse('index'))
else:
return HttpResponse("Account is not active")
else:
print("Some try to login and failed")
print("Username: {} & password: {}".format(username,password))
return HttpResponse("Invilide login details supplied")
else:
return render(request, 'app27/login.html',{})
#login_required
def special(request):
return HttpResponse("You are loged in")
in HTML:
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="{% url 'index' %}">Django</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="{% url 'index' %}">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'app27:register' %}">Register</a>
</li>
{% if user.is_authenticate %}
<li class="nav-item">
<a class="nav-link" href="{% url 'app27:logout' %}">Logout</a>
</li>
{% else %}
<li class="nav-item">
<a class="nav-link" href="{% url 'app27:user_login' %}">Login</a>
</li>
{% endif %}
<li class="nav-item">
<a class="nav-link" href="{% url 'admin:index' %}">Admin</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
my login form's HTML is:
<form class="" action="{% url "app27:user_login" %}" method="post">
{% csrf_token %}
<label for="username">Username:</label>
<input type="text" name="username" placeholder="Enter username">
<label for="password">Password:</label>
<input type="text" name="password" placeholder="Enter password">
<input type="submit" class="btn btn-primary" name="" value="Login">
</form>
the urlpartterns was:
path('register/', views.register, name='register'),
path('user_login/', views.user_login, name='user_login'),
path('admin/', admin.site.urls),
path('', views.index, name='index'),
path('basic_app/', include('app27.urls')),
path('logout/', views.user_logout, name='logout'),
path('special/', views.special, name='special'),
please help me to complete this login and logout functions? and where is the error?
You have written user.is_authenticate instead of user.is_authenticated in your HTML file.
Incorrect: {% if user.is_authenticate %}
It should be like This,
correct: {% if user.is_authenticated %}

shopify bootstrap 3 navbar-right collapse issues

I was designing a web in shopify and trying to using bootstrap navbar, but the navbar-right was not collapsing correctly, the right navbar should collapse under the main manu, but it appears at the right of the main manu
The navbar-right collapse like this
Here is my code
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">Shancha</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-left en-nav-li">
<li>HOME</li>
<li>OUR STORY</li>
<li>PRODUCTS</li>
<li>BEAUTY OF CAMELLIA</li>
<li>MEMBERSHIP</li>
<li>EXPLORER</li>
<li>HEALTHY RECIPES</li>
<li>CONTACT US</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
{% if shop.customer_accounts_enabled %}
{% if customer %}
<span class="glyphicon glyphicon-user"></span>
{% else %}
<span class="glyphicon glyphicon-user"></span>
{% endif %}
{% endif %}
</li>
<li>
<a href="/cart" >
{% include 'icon-cart' %}
<span class="visually-hidden">{{ 'layout.cart.title' | t }}</span>
<span class="icon__fallback-text">{{ 'layout.cart.title' | t }}</span>
{% if cart.item_count > 0 %}
<div id="CartCount" class="site-header__cart-count">
<span>{{ cart.item_count }}</span>
<span class="icon__fallback-text medium-up--hide">{{ 'layout.cart.items_count' | t: count: cart.item_count }}</span>
</div>
{% endif %}
</a>
</li>
</ul>
</div>

How to apply cycle to this div's

Since there is no modulus (%) in django templates So how to apply
cycle at this
{% for story in data %}
{{forloop.counter}}
when forloop.counter%4==1 then this should be executed
<div class="thumb">
<img src="{{ STATIC_URL }}images/thumb.jpg" width="185" height="185" />
</div>
<div class="thumbFooter">
<span class="view">
{{ story.views }}
</span>
<span class="like">
{{ story.likes }}
</span>
</div>
</li>
when forloop.counter%4==2 or 3 then this should be executed
<li>
<div class="thumb">
<img src="{{ STATIC_URL }}images/thumb.jpg" width="185" height="185" />
</div>
<div class="thumbFooter">
<span class="view">
{{ story.views }}
</span>
<span class="like">
{{ story.likes }}
</span>
</div>
</li>
when forloop.counter%4==0 of for loop this should be executed
<li class="omega">
<div class="thumb">
<img src="{{ STATIC_URL }}images/thumb.jpg" width="185" height="185" />
</div>
<div class="thumbFooter">
<span class="view">
{{ story.views }}
</span>
<span class="like">
{{ story.likes }}
</span>
</div>
</li>
<div class="clear"></div>
{% endfor %}
You can build your own custom filter
In the templatetags directory of your Django, add a file named 'mod.py'. In that file add the following code:
from django import template
register = template.Library()
def mod(value, arg):
if value % arg == 0:
return True
else:
return False
register.filter('mod', mod)
In your template use the mod filter like this:
...
{% load mod %}
...
<tr bgcolor="{% if forloop.counter|mod:2 %}#cccccc{% else %}#ffffff">
...
I think you want class='omega' on each 4th li of forloop. Use django Cycle in template in this way,
{% for story in data %}
<li {% cycle '' '' '' 'class="omega"' %}>
<div class="thumb">
<img src="{{ STATIC_URL }}images/thumb.jpg" width="185" height="185" />
</div>
<div class="thumbFooter">
<span class="view">
{{ story.views }}
</span>
<span class="like">
{{ story.likes }}
</span>
</div>
</li>
{% cycle '' '' '' '<div class="clear"></div>' %}
{% endfor %}
Or you could use the divisibleby filter. You can also use the add filter to adjust for all your conditions:
when forloop.counter%4==1 then this should be executed
{% if forloop.counter|add:"-1"|divisibleby:"4" %}
when forloop.counter%4==2 or 3 then this
{% if forloop.counter|add:"-2"|divisibleby:"4" or forloop.counter|add:"-3"|divisibleby:"4" %}
And without using add for the ones divisible by 4:
when forloop.counter%4==0 of for loop this should be executed
{% if forloop.counter|divisibleby:"4" %}