How to move language selector in OpenCart - twig

How to move language selector from "common.header" to anywhere else?
Once there are two or more languages on the website - a language selector begins to appear in the header section of the website, represented by {{ language }} twig variable.
If I cut
{{ language }}
from the template - language selector disappears. That is expected.
If I place it anywhere else outside common.header twig template - it doesn't appear.
It's not a css thing, the code just doesn't get parsed. I want to move it to footer but I can't seem to pinpoint the source of the problem.

If you want to show it in footer, edit this file:
catalog\controller\common\footer.php
Find:
return $this->load->view('common/footer', $data);
Add before it:
$data['language'] = $this->load->controller('common/language');
Now you can use it in footer.twig:
{{ language }}
You may need to clear modifications cache and theme caches.

Related

Which twig template to extend for a custom theme?

I apologise before for a long explanation - I have a hard time explaining it to myself.
I run Shopware 6 locally and using the development template. I needed to remove the product number from the product detail page. So, I override the twig template "buy-widget.html.twig":
{% sw_extends '#Storefront/storefront/page/product-detail/buy-widget.html.twig' %}
{% block page_product_detail_ordernumber_container %}
{% endblock %}
Works as expected - if I have not change the layout template for the product, but using the Shopware default.
But, when I change the layout to a custom layout (the only difference is that the image thumbs is bellow the main image) the product number is back?!
Checking with the Symfony Profiler, I can see that it's now another twig template (from a folder "component/.." responsible for displaying the product number.
Question: Am I correct to assume that I should extend the twig template from this component folder if I'm using a custom layout? I have not find anything in the docs about these "small" details. And if one need to be sure that a custom theme works in every case, you must make the changes (using sw_extends) in two files?
/ Magnus

In MkDocs / Material, is it possible to put the table of contents on the left?

I'm using MkDocs with the Material theme. I'd like to build a site that looks a little like the Stripe API docs.
By default, the Material theme puts .md documents in the sidebar on the left, and the headings withing those documents in a Table of Contents sidebar on the right. I'd like to put it all on the left:
Introduction
A ## heading here
Another heading
Getting Started
Subsection
etc.
I could do this by making every entry its own document, but I'd prefer to have only one document per major heading, with the table of contents consisting of subheadings underneath. Possible?
Update:
I have made some progress.
First, extend the theme by by following these instructions: https://squidfunk.github.io/mkdocs-material/customization/
Second, get rid of the TOC on the right by overriding the "site_nav" template block. In main.html, just copy the existing site_nav block from base.html, then comment out the "Table of contents" section.
Third, copy the nav-item.html partial into the /partials directory and make modifications.
Now I'm stuck. It looks like nav-item.html does have code to render the TOC under each item, and it does get rendered with a display:none. When I turn that off, though, the TOC does not appear properly.
I've done an hour of fiddling with CSS to get it to work with no success. Any ideas?
In your custom css file, write:
.md-sidebar--secondary {
order: 0;
}
And in your mkdocs.yml, write:
extra_css:
- assets/<custom_css_filename>.css
Your update to the question is exactly what I did so I'm unsure if this will be useful.
In mkdocs.yml add custom_dir to the theme:
theme:
name: material
custom_dir: overrides
Create a file overrides/main.html and observe the file you are replacing https://github.com/squidfunk/mkdocs-material/blob/master/material/base.html. Use the nav code but include the toc partial to get the following:
{% extends "base.html" %}
{% block site_nav %}
<div class="md-sidebar md-sidebar--primary" data-md-component="navigation">
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
{% include "partials/toc.html" %}
</div>
</div>
</div>
{% endblock %}
Here is the result:
If you are looking at changing the table of contents to also include pages look into the partials in the git repo.
The easiest hack I've come up with is the following:
In your mkdocs.yml, write:
extra_javascript:
- 'javascripts/extra.js'
In your docs/javascripts/extra.js, write:
document.addEventListener("DOMContentLoaded", function() {
show_toc_left();
});
function show_toc_left(){
document.querySelectorAll('.md-nav .md-nav--secondary')[0].setAttribute("style", "display: block; overflow: visible; color: #7d7f8e9c")
document.querySelectorAll('.md-nav .md-nav--secondary label')[0].remove()
}
This will show the TOC within your left side navigation menu of the currently active page.
You can also add this to the top of the individual page:
---
hide:
- toc
---

what exactly is haswidgets and widgets in bolt (or twig rather )?

I was just going through the Default theme of bolt CMS, and i came actoss the following lines of code:
{% if haswidgets('aside_top') %}
{{ widgets('aside_top') }}
{% else %}
I googled twig haswidgets and also twig widgets , but i could't find anything.
can somebody explain what these two methods are ? and what exactly do they do ?
They are a feature of Bolt. Extensions can push content to specific places in the backend and also to some places in the frontend, as long as the theme supports that. They are called widgets. the haswidgets() and widgets() twig functions are for checking and displaying them.
You can find more info here https://docs.bolt.cm/3.1/templating/widgets and here https://docs.bolt.cm/3.1/extensions/intermediate/widgets

load external html files with handlebars

I would like to create external Handlebars files using the following -
1. header- Contains html codes
2. footer- Contains html codes
3. nav- Contains html codes
4. search - Contains html codes
etc.
Is there a way with handlebars to do this, so that I can include each template if and when needed in a specific page. Not sure how to go about it.
Thanks!
Absolutely! You can use Handlebar partials to do this. Simply register your header, nav, etc files as partials and then you can use this in your main template by doing something like this:
{{> header }}
{{> nav activePage=(activePage) }}
Have you considered using ASP.NET?
If you wanted to add content from other html files, I would highly recommend using
#RenderPage()If you use this, then you could set up a layout such as:
#RenderPage("header.html")
Some random description
#RenderPage("navigationbar.html")
#RenderPage("searchbar.html")
- Insert some content here -
#RenderPage("footer.html")
I'm certain that if you use this kind of layout, you'd get the appearance you would want. Obviously this is just an example, so you'd probably want to add some kind of CSS layout to suit your taste, but this is how I would go about it in ASP.NET.

Bolt-CMS Using extensions in page?

I read this from a recent answer to a question:
After enabling the extension, just use {{ twitterfeed() }} in your templates.
But, what if I only want say a contact form on one page? Putting the tag in the page's text field doesn't work. And putting it in the template would have it available on all the pages using that template. Do I have to duplicate a template to use only for the contact page? If not where do I put the contact form tag?
I went to Bolt's extension page, selected "how to use extensions" from the menu, and got this message:
No proper name for a page in the docs. Bye!
Perhaps someone at Bolt could fix the URL?
I would like to know why none of the extensions I want to use are not working. I am clearly missing a vital piece of info.
Thank you.
After enabling the extension, just use {{ twitterfeed() }} in your templates.
The Twig function {{ twitterfeed() }} belongs (generally speaking) in a Twig template file. You can use Twig in record fields, but that requires setting allowtwig: true for that Contenttype field.
But, what if I only want say a contact form on one page?
There are a few ways to do this, but the easiest way is to make a copy of your sites template file for the page's Contenttype and select that template for the 'Contact' record. The default 'pages' Contenttype that comes with Bolt has a templateselect field type that enables this.
No proper name for a page in the docs. Bye!
Fixed! Thanks for pointing it out.

Resources