how can I add more character space to the home page tagline in big cartel? - bigcartel

Does anyone know how to edit the CSS in a Big Cartel theme (specifically the FOUNDRY theme) to allow for more text in the home page tagline? Currently, you can only type about 100 characters. I would like to be able to write a bit more (like a small paragraph about the shop and current product overview).

The text box is limited to 100 characters, so to edit that you'll need to change the code the Advanced > Home section of the Customize Design area. Find this code at the top:
{% if theme.home_tagline != blank %}
<div class="home_tagline">
{{ theme.home_tagline }}
</div>
{% endif %}
And replace the {{ theme.home_tagline }} with your own text.

Related

Bootstrap grid content position

I have the following code for django-oscar
<ul class="row">
{% for product in products %}
<li class="col-xs-6 col-sm-4 col-md-3 col-lg-3">{% render_product product %}</li>
{% endfor %}
</ul>
it works find except on the phone.
As you can see from the screen shot, there is a weird space in the grid system when the size is reduced to the phone (it actually displays like this on the phone). On the desktop, the grid system displays correctly until the size of the browser becomes less than certain px. Is there a way to fix this? (I think I am using bootstrap3)
Grid system working well
Phone mode
what you're looking for is clearfix
Add this to the parent element, in this case the row class
If you look closely, in phone mode the In Stock is on different lines, i am assuming this is a height problem. Best solution is to use flex box . Or manually adjust the min height.

Drupal 8: List taxonomy terms with active class in twig

Let say I have a taxonomy name Flavor and the terms have Vanilla, Chocolate and Green Tea.
I also have a content type name ice-cream with flavor field under 'Flavor' taxonomy which can multiple select.
I create a ice-cream page name Baskin Robin and I tick 'Vanilla' and 'Chocolate' under flavor field.
How to list all 'Flavor' terms in node.html.twig and add a class for 'Vanilla' and 'Chocolate'?
For example:
<div class="field-item active">Vanilla</div>
<div class="field-item active">Chocolate</div>
<div class="field-item">Green Tea</div>
You need a block or a views to do that.
You can also use a hook_preprocess_node to inject all flavors in the ice-cream template.
Here the documentation to create a custom block.
Here the documentation to create a views block.
Here the documentation to place a block (custom or views).
I will explain the easiest & fastest, but most dirty one, to achieve your goal - using the hook_preprocess_node.
I recommend to use the custom block or the views for scalability & maintainability. The code below is a working example, you could use it in a custom block.
Here the code using the preprocess way.
In your template.theme file:
/**
* Implements hook_preprocess_node.
*/
function template_preprocess_node(&$variables) {
$node = $variables['node'];
if($node->bundle() == 'ice-cream') {
// Should be injected.
$termStorage = \Drupal::entityManager()->getStorage('taxonomy_term');
// Load all flavors taxonomy term.
$variables['flavors'] = $termStorage->loadTree('flavors', 0, NULL, TRUE);
}
}
In your node.html.twig or node--ice-cream.html.twig:
{% for flavor in flavors %}
{% set classes = ['field-item'] %}
{% for node_flavor in node.field_flavors if node_flavor.target_id == flavor.id %}
{% set classes = classes|merge(['active'])%}
{% endfor %}
<div class="{{ classes|join(' ') }}">{{ flavor.name.value }}</div>
{% endfor %}
Hope it will help you !

Wagtail Image template tags

I'm using Django-variant CMS Wagtail and am trying to build my own templates for it.
I can upload images into the rich text field in Wagtail's CMS as shown:
In my template's html, I would like to be able to call specific images uploaded in the body so that I can style those specific images differently with js.
perhaps something like {{ body.image }}?
the html:
{% extends 'wagweb/base.html' %}
{% load rich_text static compress cache image_tags pageurl %}
{% block content %}
<div class="box">
<article class ="content">
{{ self.body | richtext }}
</article>
</div>
{% endblock %}
I'm lost at this point, as I can't figure out how to find the pre-existing tag dictionary (if there is any) or to create one without messing with the views.py? Or would it be more straight-forward to install markdown into the richtextfield and work from there?
I'm tons more comfortable with html and css, so one solution is to simply write everything in html and use {{ MEDIA_URL }} to call the specific images. But that seems like an unintelligent way to use Wagtail and Django.
Currently the rich text editor doesn't support embedded images with custom attributes (like CSS classes). It also doesn't provide a HTML source editor for the richtext field.
However, if you don't need to have the images inline with the rich text (but rather before or after the text, you could include them in your page model using InlinePanel pointing to table which uses a ParentalKey. Then, in your templates, you could loop through multiple images and apply the specialized CSS classes. The Wagtail demo project uses this method to create an image carousel. You can find some explanation on the more general tactic of using ParentalKey/InlinePanel here in the Editing API.

DJangoCMS - Outputting number of menu children to menu template

Within DjangoCMS I'd like to display the number of children a page has in the navigation.
I have a menu item called "Careers" and I'd like it to say "Careers (2)" if there are 2 sub-pages within that page in the site tree.
Is this possible?
I can target the right menu item in menu.html but need to dynamically generate the number somehow.
{% if child.get_menu_title|slugify == "careers" %}<span>1</span>{% endif %}
I more or less determined that without faffing with models (which I can't do) I solved the problem with some nifty CSS and JavaScript. Not a wonderful result, but it's sufficient.
Just tried it myself and you can do:
{% if child.children %} <span>{{ child.children|length }}</span>{% endif %}

Django: Is there a better way to bold the current page link

I have a base.html template that contains a list of links.
Example:
<div id="sidebar1">
<ul>
<li>Index</li>
<li>Stuff</li>
<li>About Me</li>
<li>Contact Me</li>
</div>
Then I have in my views.py a definition for each of index.html, stuff.html, about.html and contact.html. Each of those templates simply derive from a base.html template and set their own respective titles and contents.
My question is about the above /stuff I have a class="current".
I'd like to make the current page that I'm on have that class attribute.
I could set a different variable in each view like current_page="about" and then do a compare in the template with {% ifequal %} in each class element of each link , but that seems like duplicating work (because of the extra view variable).
Is there a better way? Maybe if there is a way to get the view function name that the template was filled from automatically I would not need to set the extra variable? Also it does seem like a lot of ifequals.
Here's an elegant way to do this, which I copied from somewhere and I only wish I could remember where, so I could give them the credit. 8-)
I assign an id to each of my pages (or all the pages within a section) like this:
In index.html: <body id='section-intro'>...
In faq.html: <body id='section-faq'>...
In download.html: <body id='section-download'>...
And then an id for the corresponding links:
<li id='nav-intro'>Introduction</li>
<li id='nav-faq'>FAQ</li>
<li id='nav-download'>Download</li>
And the in the CSS I set a rule like this:
#section-intro #nav-intro,
#section-faq #nav-faq,
#section-download #nav-download {
font-weight: bold;
/* And whatever other styles the current link should have. */
}
So this works in a mostly declarative way to control the style of the link that the current page belongs in. You can see it in action here: http://entrian.com/source-search/
It's a very clean and simple system once you've set it up, because:
You don't need to mess about with template markup in your links
You don't end up using big ugly switch statements or if / else / else statements
Adding pages to a section Just Works [TM]
Changing the way things look only ever means changing the CSS, not the markup.
I'm not using Django, but this system works anywhere. In your case, where you "set their own respective titles and contents" you also need to set the body id, and there's no other Django markup required.
This idea extends easily to other situations as well, eg. "I want a download link in the sidebar on every page except the download pages themselves." You can do that in CSS like this:
#section-download #sidebar #download-link {
display: none;
}
rather than having to put conditional template markup in the sidebar HTML.
Haven't used Django, but I've dealt with the same issue in Kohana (PHP) and Rails.
What I do in Kohana:
<li><a href="/admin/dashboard" <?= (get_class($this) == 'Dashboard_Controller') ? "class=\"active\"" : NULL ?>>Dashboard</a></li>
<li><a href="/admin/campaigns" <?= (get_class($this) == 'Campaigns_Controller') ? "class=\"active\"" : NULL ?>>Campaigns</a></li>
<li><a href="/admin/lists" <?= (get_class($this) == 'Lists_Controller') ? "class=\"active\"" : NULL ?>>Lists</a></li>
What I do in Rails:
<li><a href="/main" <%= 'class="active"' if (controller.controller_name == 'main') %>>Overview</a></li>
<li><a href="/notifications" <%= 'class="active"' if (controller.controller_name == 'notifications') %>>Notifications</a></li>
<li><a href="/reports" <%= 'class="active"' if (controller.controller_name == 'reports') %>>Reports</a></li>
I see only a couple of ways of doing it, while avoiding repeated ifequals:
Javascript. Something along the lines of (jQuery):
var parts = window.location.pathname.split('/');
var page = parts[parts.length-1];
$('#sidebar1 a[href*=' + page + ']').addClass('current');
Change your views to contain a list of pages with their associated titles and URLs and create a {% for %} loop in your template, which will go through that list, and add a single {% ifequal %}.
Option 2 being the favorite from where I stand. If the logic for all of your pages is the same, and only the templates differ, you might consider using the FlatPages model for each of your pages. If the logic is different, and you need different models, you might consider using a menuing app of some sort. A shameless plug: I have a menuing app of my own
If you add the request context processor, it's pretty straightforward:
settings.py:
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.request',
'django.contrib.auth.context_processors.auth' # admin app wants this too
)
Now you have access to the HttpRequest, which contains the request path. Highlighting the current page is a simple matter of checking if the path matches the link's destination, i.e., you're already there:
<li><a class="{% if request.path == '/' %}current{% endif %}" href="/">Index</a></li>
<li><a class="{% if request.path == '/stuff/' %}current{% endif %}" href="/stuff/">Stuff</a></li>
<li><a class="{% if request.path == '/about/' %}current{% endif %}" href="/about/">About Me</a></li>
<li><a class="{% if request.path == '/contact/' %}current{% endif %}" href="/contact/">Contact Me</a></li>