I try to add titles in a template, which is used at different title levels. But I can't figure out how to make the titles use the correct style.
When I just use a subtitle small enough, it works with the numbering, but the title is in the subtitle 5 for example, but should be in 3.
Example:
My template has something like:
==== Title 1 ====
Bla bla
===== Title 2 =====
And I use it at various locations, such as
==Profile ==
{{MyTemplate}}
or:
==== Another Profile ====
{{Template}}
Related
I am trying to modify a Dawn 2.0 theme to, on the product page, only render images with certain tags depending on an input selector. I have one product which consists of 8 items, each item has an image. This product can be ordered in three variations:
The first variation would be the product with 4 items.
The second variation would be the product with 6 items.
The third variation would be the product with 8 items.
There is a variant selector in the products page:
and the three variants have been created on the Shopify admin products page. The solution that I'm attempting to use is this one. I chose it as it's the only one I found reference to elsewhere (apart from buying an add on which I don't want to do), it seemed a logical approach to me, though I have no particular loyalty to this approach if anyone can think of a better way to achieve what I'm trying to.
This solution involves using values assigned to image's alt text attribute via the Shopify admin products page. The alt text values applied are:
set_all for the first 4 images, because these 4 items would be included in all three of variants (the one with only x4 itmes, the one with x6 items, and the one with x8 items).
set_6&8 for the 5th and 6th images, because these 2 items would be included in both the 2nd variant (the one with x6 items) and the 3rd variant (the one with x8 items).
set_8 for the 7th and 8th images, because these 2 items would only be included in the 3rd variant (the one with x8 items)
Then interpolating that alt text value into a data tag in the html:
data-thumbnail-set-number="{{media.alt}}"
which is applied to the <li> that each image is housed within and then writing a js function which:
hides all images
stores in local variable the alt text value of the featured image ('featured image' being the one, and only, image that you can apply to each variant in the Shopify admin products page. Therefore if the user selects a different variant a different featured image with different alt text is attached to that variant).
shows the images whose data-thumbnail-set-number value matches the value from the variant's featured_image.alt text. JS being:
'./assets/global.js' in VariantSelects class, line ~561
onVariantChange() {
...
this.filterThumbnails();
...
};
filterThumbnails() {
if (this.currentVariant.featured_media != null && this.currentVariant.featured_media.alt != null) {
document.querySelectorAll('[data-thumbnail-set-number]').forEach(function(el) {
el.style.display = 'none';
});
// show thumbnails for selected set
var selected_set = this.currentVariant.featured_media.alt;
document.querySelectorAll('[data-thumbnail-set-number="' + selected_set + '"]').forEach(function(el) {
el.style.display = 'block';
});
}
else {
//show all thumbnails
document.querySelectorAll('[data-thumbnail-set-number]').forEach(function(el) {
el.style.display = 'block';
});
}
// console.log("thumbnail update", this.currentVariant.featured_media.alt)
}
This all works apart from two problems:
I need to write further conditions in the JS to not just match the featured_image.alt text but to also include:
the set_all images as those items come with all 3 variations, and for the set_8 variant to include the set_6&8 images. I should be able to deal with this fine, will probably hard code the data-thumbnail-set-number that each three conditional is looking for.
Even though the JS function seems to be effective at searching and showing the images with a data-thumbnail-set-number value that matches the variant's featured image alt text value, the page also always seems to render one other image, which does not have the data-thumbnail-set-number class applied to the <li> at all, and it seems that that image is always the first of the images saved to the main product.
Despite a good deal of time looking I can't seem to understand why issue 2. is happening, and how to stop it. Can anybody help me solve this?
PEBCAK 🥴
To solve issue 2, I found that another <li> is inserted in the main-product.liquid above the <li> which iterates and shows all images in the image colleciton just to show just the featured image. I don't really understand why this featured image is separated out for rendering apart from the others in the collection, but it it. I just needed to add the data-thumbnail-set-number="{{media.alt}}" into this newly found featured image <li>.
As i took some time to write out this question I thought that I'd leave it here in case it's of help to anyone else.
I have created a Template in my MediaWiki which I want to pass "free text" to. To keep it simple, imagine it as a table in which the first named parameter goes into cell 1 and the other named parameter goes into cell 2.
Writing the Template itself seemed easy enough, but I keep stumbling into errors when I try to pass certain structures in the arguments. My first issue was with a code block: if I wrote
{{MyTemplate|first=
// code...
|other=
// other code instead...
}}
then the wiki thought that the pipe character was part of the preformatted text block, and in the end I ended up without a second parameter. This issue was solved using <pre></pre>, but I thought it was more of a workaround than a solution.
Now I'm in trouble again when I try to pass a list:
{{MyTemplate|first=
* Item 1a
* Item 2a
|other=
* Item 1b
* Item 2b
}}
Again, I end up with the first item (Item 1a) ignored (not rendered as a list item), the second rendered ok (Item 2a, as a list item), then a double pipe, an asterisk and "Item 1b", then the list goes on with "Item 2b".
I am clearly doing something wrong, but I have no idea what to do, nor I could find any useful example in the docs. Please help me understand how to correctly pass any text (which may include lists or other markdown constructs) as a template argument.
EDIT
Here is the code of my Template:
{|
!First !!Other
|-
|{{{first|}}} ||{{{other|}}}
|}
Also, I'm sorry, but I typed the usage wrong: the four more spaces were a leftover from the snippet above. I've fixed that.
#Ivanhercaz I've tried your suggestion (which only differs from mine for the empty lines), and still got the same result.
In this case I have to suppose how is the template you created, because you didn't shared the structure, just how you call and two parameters. Because of this reason I am going to suppose that you create a template as:
{{{first|}}}
{{{other|}}}
About your first question, you can use {{!}} to escape the pipe character (|). From the version 1.24 this is a magic word, but before the solution to this issue was to create a template with a pipe and then replace the | by {{!}}. The use of the magic word is the same, but you is unnecessary to create the template.
About your second question, taking in account that you have a similar structure to what I wrote at the top of this answer, if I wrote a page with this:
{{MyTemplate|first=
* Item 1a
* Item 2a
|other=
* Item 1b
* Item 2b
}}
I get a two lists and two code blocks: list one with "Item 1a" and the first code block with * Item 2a; list two with "Item 2a" and the second code block with * Item 2b. It doesn't seem to what you get rendered:
the first item (Item 1a) ignored (not rendered as a list item), the second rendered ok (Item 2a, as a list item), then a double pipe, an asterisk and "Item 1b", then the list goes on with "Item 2b". This happened due to the extra space before the * in the parameters.
So I recommend to you to share the code of the template to check and answer to you better. Of course, if what you want is to pass two different lists in each parameter you could make something like:
{{Test|first=
* Item 1a
* Item 2a
|other=
* Item 1b
* Item 2b
}}
This structure solved the problem I mentioned. But I wait your comment to be sure and edit my answer if it is necessary.
Edit
Now, with the code of the template I understand your problem. To work correctly and without problems with templates, tables and lists you have to consider that the * need to have an line break after the | and ||. What I recommend to you is insert this line breaks
{|
! Wikitext !! Rendering
|-
|
{{{first|}}}
||
{{{other|}}}
|}
I think it is an easy and clean way to do what you are trying. So, if you use the template in this way:
{{Test
|first=* Item 1a
* Item 2a
|other=* Item 1b
* Item 2b
}}
Or in this other way:
{{Test
|first=
* Item 1a
* Item 2a
|other=
* Item 1b
* Item 2b
}}
You will have a table like that (I add a class=wikitable to have a more beautiful table to show):
I hope this trick has been helpful.
I've got a structured set of pages in a collection, and the structure looks something like this:
chapter1
section1
section2
section3
chapter2
section1
section2
section3
chapter3
section1
section2
section3
Each is a separate page that renders its own permalink.
Say I'd like to make a link to chapter3/section1, how would I do this? I'd like to use the Liquid where filter, but this seems to give me the page contents, not the metadata.
{% assign section_post = site.chapters | where:"url","chapter3/section1" %}
{{ section_post }}
This gets me the proper page, but not the right content. If I were to write this in my layout, I get nothing:
{{ section_post.title }}
What am I doing wrong? How can I get the metadata using a where filter? I've got a bunch of pages, so looping through them is super inefficient...
The problem is that a where expression returns all the objects in an array given a certain condition.
[#<Jekyll::Document _chapters/chapter3/section1 collection=chapters>]
In this case you are expecting that this list of objects just return a single item, so we can select that item with the first liquid tag (returns the first element of an array).
{% assign ch3s1 = site.chapters |
where:"id","/chapters/chapter3/section1" | first%}
title: {{ch3s1.title}}
<br>
url: {{ch3s1.url}}
would output the desired section:
title: Chapter 3 section 1
url: /chapters/chapter3/section1
So I have a report that I was able to get almost exactly how I wanted it, but I can't manage to get a page break between the 2 subreports. Help would be highly appreciated.
I have 3 reports
PARENT.rdl
SUBREPORT_1.rdl
SUBREPORT_2.rdl
SUBREPORT_1 and SUBREPORT_2 share a common field (for example city) so I'm able to group them inside the PARENT.rdl so it has this type of format:
What I have looks like this:
SUBREPORT_1: MIAMI
SUBREPORT_2: MIAMI
----- page break ------
SUBREPORT_1: ORLANDO
SUBREPORT_2: ORLANDO
----- page break ------
SUBREPORT_1: TAMPA
SUBREPORT_2: TAMPA
I have all of this working perfectly, my only problem is I'd like to add a page break between SUBREPORT_1 and SUBREPORT_2. There is already a page break at the end of the City grouping. I want it to look like:
SUBREPORT_1: MIAMI
-- page break -- << add this
SUBREPORT_2: MIAMI
----- page break ------
SUBREPORT_1: ORLANDO
-- page break -- << add this
SUBREPORT_2: ORLANDO
----- page break ------
SUBREPORT_1: TAMPA
-- page break -- << add this
SUBREPORT_2: TAMPA
I've tried putting the subreports in rectangles inside of the tablix cells, but no luck. I'm assuming because of the PARENT tablix can't be broken up mid-tablix ?
Any help with this would be great, of if there is a better solution than the subreport method. That is what I found in my research.
Thanks
When you placed your subreport inside the rectangle did you check the subreport properties to make sure the Parent under the "other" in properties was the rectangle? If it isnt you'll need to drag the subreport out of the rectangle and then back into it so it becomes the parent item then set the rectangle to have a page break.
I want to find similar posts on my website depending on the url slug.
say i have the following five slugs
i-am-a-slug /*the slug i want to compare*/
i-am-another-slug /* 3 same words */
i-am-an-ant /* 2 same words */
the-slug-life /* 1 same word */
foo-bar /* 0 same words */
at the moment i am using the following code to find out if there are any similar words in the compared slug
SELECT *
FROM News
WHERE News.slug != "i-am-a-slug"
ORDER BY CASE
WHEN News.slug REGEXP "i|am|a|slug" THEN 1
ELSE 2
it doesn't even work very well... words like the a in the example give back hits in nearly every slug i have in my database... in the example, even the slug foo-bar would be returned.
i can't seem to figure out how to select a variable same-words-count that counts all the same words within each tested slug (see comments first code-block for the solutions i would like to get), so i could
SELECT *
FROM News
WHERE News.slug != "i-am-a-slug"
ORDER BY CASE
WHEN same-words-count > 2 THEN 1
WHEN same-words-count = 2 THEN 2
WHEN same-words-count = 1 THEN 3
ELSE 4
or is there an even better way to do this?
thank you very much in advance, sorry my mysql is a bit rusty lately...
What you are looking for is called inverted index: http://en.wikipedia.org/wiki/Inverted_index
Depending on the data amount and what you actually are going to do with the result (do you need to keep it up to date, do you need to show it on the site, etc) you might want to solve the problem using a programming language of your choice or use some full-blown fulltext search solution. Plain SQL just isn't a right tool for this.