Jekyll Links is not properly working - hyperlink

github site: https://geloangelia.github.io/mynewsite/profile
REPO: https://github.com/geloangelia/mynewsite
I am having trouble with the links. i doesn't link to the right path.
the path should be _site\vclist(NAME)
CODE:
<ul>
{% for list in site.data.vclist %}
<li>{{list.Name}}
</li>
{% endfor %}
</ul>

The problem is how you generate the links with the filter tag, you need to add the basepath to the generated URLs and specify the directory where the plugin generates the files:
<ul>
{% for list in site.data.vclist %}
<li>{{list.Name}}</li>
{% endfor %}
</ul>
Also, the permalink shouldn't be located in the layout, so remove the permalink from _layouts/profile.html
---
layout: page
---

Related

Craft cms search multiple fields with query parameter

I would like to use a query term for multiple fields according to their fields' handle in Craft cms 3.5.x, but unfortunately only for field title that works correctly, while for the other fields i get no results at all.
{% if craft.app.request.getParam('q') %}
{% set searchQuery = craft.app.request.getParam('q') %}
{% set queryEntries = craft.entries({
search:{
query: 'title:' ~ searchQuery ~ ' OR appealer:' ~ searchQuery ~ ' OR assigner:' ~ searchQuery,
subLeft: true,
subRight: true
}
}).all() %}
{% endif %}
{% if queryEntries|length %}
<p>{{ queryEntries|length }} results:</p>
<ol>
{% for entry in queryEntries %}
<li>{{ entry.title }}</li>
{% endfor %}
</ol>
{% else %}
<p>Your search for “{{ searchQuery }}” didn’t return any results.</p>
{% endif %}
Any idea that could help me?
Regards
This is a duplicate of https://craftcms.stackexchange.com/questions/37966/search-on-multiple-custom-fields-with-a-query-parameter, which I have responded to, please avoid posting duplicates.

Possible to reference front-matter values in template files?

I have a theme and for a post page, I'm showing the image value if there is one.
I also have a plugin that renders a YouTube video and usage is like this: {% youtube id_12345 %}.
In my template file, would it be possible to reference the video value from the front-matter of a post and render it with the same plugin that I can use in my content?
Something like:
{% if post.video %}
{% youtube {{post.video}} %} # <-- this does not work
{% elsif post.image %}
<img src="{{ post.image }}" class="post-image" alt="{{ post.title }}">
{% endif %}
Thanks!
Since variables are not compatible with {% %} calls, I ended up reproducing much of the plugin's functionality in this one line. I started with the BetterTube and modified it for my needs.
{% if post.video %}
{% capture video_id %}{{ post.video |
replace: 'https://www.youtube.com/watch?v=','' |
replace: 'https://youtu.be/', '' }}{% endcapture %}
<figure class='BetterTube' data-youtube-id='{{video_id}}' data-player-width=''
data-player-height='' id='{{video_id}}' style='padding-bottom: 56.25%'>
<a class='BetterTubePlayer' href='http://www.youtube.com/watch?v={{video_id}}'
style='background: url(http://img.youtube.com/vi/{{video_id}}/hqdefault.jpg) 50%
50% no-repeat rgb(0, 0, 0);'></a><div class='BetterTube-playBtn'></div>
</figure>
{% elsif post.image %}
<img src="{{ post.image }}" class="post-image" alt="{{ post.title }}">
{% endif %}
I wished I could simply call the plugin, but sadly I don't think it's possible.
I take it that you're using this plugin. I don't know much about writing plugins, but it seems to me like you can't use variables in it.
Maybe try this one instead? It seems like it supports variables.
That being said, I don't even think you need to go through the hassle of running a plugin for that. The following code should do the work just fine:
{% if post.video %}
<iframe width="560" height="420" src="http://www.youtube.com/embed/{{ post.video }}?color=white&theme=light"></iframe>
{% elsif post.image %}
<img src="{{ post.image }}" class="post-image" alt="{{ post.title }}">
{% endif %}

Variables to work with loops in rails

The Symfony framework has loop_index, first and last variables for working with loops.
{% for each link in links %}
{% if loop_index == first %}
.....
{% else %}
....
{%endif %}
{% end %}
Are there such variables or functions in rails?
Not exactly but you can use each_with_index:
{% links.each_with_index do |link, index| %}
{% if index == 0 %}
.....
{% else %}
....
{%endif %}
{% end %}

Shopify linklists iteration

Is it possible to iterate through the Shopify linklists?
Currently I'm doing this to print all the items in all the menus:
{% assign menuHandles = "menu-1-handle|menu-2-handle|menu-3-handle" | split: "|" %}
{% for list in menuHandles %}
{% for link in linklists[list].links %}
{{ link.title }}
{% endfor %}
{% endfor %}
This requires hard coding the menu names and i'd like to avoid that.
This has now been added! Fast turnaround. :D
{% for linklist in linklists %}
{{ linklist.handle }}
{% endfor %}

How to translate with pluralization in Twig?

How can I translate the current hardcoded text with the key from the language file (messages.en.xliff)?
I tried to use the
{% trans %} translation_key{% endtrans %}
with no success. Symfony returns this error
A message must be a simple text in 'ProjectEventsBundle:Default:show_event.html.twig'
500 Internal Server Error - Twig_Error_Syntax
{% transchoice count %}
{0} The current hardcoded text|{1} is attending|{2} are attending|]2,Inf] and %count% - 2 others are attending
{% endtranschoice %}
Thanks in advance.
I would use a solution like this:
messages.en.xliff:
<trans-unit id="1">
<source>some.translation.key</source>
<target>{0} no.attendee|{1} one attendee|{2} two attendees|{3} three attendees|]3,Inf] many attendees</target>
</trans-unit>
Twig template:
{{ 'some.translation.key'|transchoice(count) }}
If you need to put some arguments, you should pass them as second argument.
Here's the prototype of the filter:
public function transchoice($message, $count, array $arguments = array(), $domain = "messages", $locale = null)
This subject is quite old, but I would suggest you to do something like that :
In your messages.LOCALE.yml
you.translaction.key: "{1}1 Comment|]1,Inf]%count% Comments"
In your twig template
{% set count = 2 %}
{% transchoice count with {'%count%': count} %}you.translaction.key{% endtranschoice %}
Cheers,
Simon
Found this from Symfony Documentation:
Symfony2 provides specialized Twig tags (trans and transchoice) to help with message translation of static blocks of text:
{% trans %}Hello %name%{% endtrans %}
{% transchoice count %}
{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples
{% endtranschoice %}
The transchoice tag automatically gets the %count% variable from the current context and passes it to the translator. This mechanism only works when you use a placeholder following the %var% pattern.
Example with one more parameter:
{{ 'label.policy_expires_in'|transchoice(expiresInDays, {}, 'VopInsPolicyBundle') }}
I found a solution. It's a little bit dirty but it's working. If you find a better ways, don't forget to post it.
{% set noattendee %}{% trans %} no.attendee {% endtrans %}{% endset %}
{% set oneattendee %}{% trans %} one.attendee {% endtrans %}{% endset %}
{% set twoattendees %}{% trans %} two.attendees {% endtrans %}{% endset %}
{% set treeattendees %}{% trans with {'%people%': people} %} tree.attendees {% endtrans %}{% endset %}
{% set manyattendees %}{% trans with {'%people%': people} %} many.attendees {% endtrans %}{% endset %}
{% transchoice count with {
'%noattendee%': noattendee,
'%oneattendee%': oneattendee,
'%twoattendees%': twoattendees,
'%treeattendees%': treeattendees,
'%manyattendees%': manyattendees}
%}
{0} %noattendee%|{1} %oneattendee%|{2} %twoattendees%|{3} %treeattendees%|]3,Inf] %manyattendees%
{% endtranschoice %}

Resources