Jekyll Pagination Index not found - pagination

First off, I am using Jekyll 3.5.1
I have enabled Pagination in my Jekyll config and have added the following to my _config.yml file:
#pagination
paginate: 5
paginate_path: "blog/page:num"
In my root directory, I have created a folder called 'blog' with inside of it an 'index.html' file. Yet, when I try to serve the file I get the warning that pagination can not find an index.html file.
I have also tried to just use the index.html file under root, but that was unsuccesfull as well.
Here you can see the github repo in case that would be of any help.
I have tried to play with the paginate_path as well as with the index.html file. Any help would be appreciated!
The concrete error message is:
Pagination: Pagination is enabled, but I couldn't find an index.html page to use as the pagination template. Skipping pagination.
Any help would be greatly appreciated.

One cause of this error message: The Brackets Editor 'Beautifier' command doesn't recognize YAML code when it executes, so it sees the top YAML of your index.html file:
---
layout: default
title: Jekyll Title
---
... and transforms the 4 lines into one continuous line:
--- layout: default title: Jekyll Themes ---
Jekyll responds with the error message:
Pagination: Pagination is enabled, but I couldn't find an index.html page to use as the pagination template. Skipping pagination."

index.html must not be empty. The pagination template file (as referred by pagination_path should contain the code to generate each page with the list of posts, as docs suggests, create blog/index.html:
---
layout: default
title: My Blog
---
<!-- This loops through the paginated posts -->
{% for post in paginator.posts %}
<h1>{{ post.title }}</h1>
<p class="author">
<span class="date">{{ post.date }}</span>
</p>
<div class="content">
{{ post.content }}
</div>
{% endfor %}
<!-- Pagination links -->
<div class="pagination">
{% if paginator.previous_page %}
Previous
{% else %}
<span class="previous">Previous</span>
{% endif %}
<span class="page_number ">Page: {{ paginator.page }} of {{ paginator.total_pages }}</span>
{% if paginator.next_page %}
Next
{% else %}
<span class="next ">Next</span>
{% endif %}
</div>

Related

Display product custom field in listing page in shopware 6?

I created a custom field and assigned it to the products and I want to display that custom field value on the listing page. On the description.html.twig page, I add this below variable and the value is showing on the detail page.
{{ page.product.translated.customFields.custom_events_dates }}
The same variable I placed on the box-standard.html.twig, but the value is not showing.
{% sw_extends '#Storefront/storefront/component/product/card/box-standard.html.twig' %}
{% block component_product_box_info %}
{{ parent() }}
<div class="test">
<p>{{ page.product.translated.customFields.custom_events_dates }}</p>
</div>
{% endblock %}
How can I display the custom field value on the listing page?
You need to use product.translated without the page. The page object only contains the product data on a product detail page, on listing pages it is not set.

Twig: add content in the footer using extends makes extended code appear twice

To my understanding, by using twig's extends method, it should be possible to add code to the footer from within a template that is included anywhere else.
Like if we render the main page and have a <form> there in a template edit_form.html.twig and we know we need special javascript here (only for that form) so we decide to add this javascript tags in the footer at the end of the page like this:
edit_form.html.twig
{% block edit_form %}
<form id="editForm">
<!-- form html here -->
</form>
{% endblock edit_form %}
{{ include('edit_form_js.html.twig') }}
We want this javascript to be at the end of the page:
edit_form_js.html.twig
{% extends "footer.html.twig" %}
{% block js %}
{{ parent() }}
<script>
// special js code only needed for the <form>
</script>
{% endblock js %}
footer.html.twig
{% block js %}
<script src="jquery.js"></script>
{% endblock js %}
But doing this does not add the custom form javascript at the end after the jquery inclusion but results in the block js being twice on the page (after the form and in the footer)
Is my understanding of twigs extends wrong?
Q: Is there any way to add code from anwywhere to the footer?
Included templates don't know anything from the template it's being called from. There for an included template cannot alter a block from that said template. You might want to have a look at the deferred extension

Digg-style pagination customize in template

I am using django-el-pagination package and trying to implement digg-style pagination on my home template. I am displaying it with..
{% get_pages %}
{{ pages.get_rendered }}
and it is showing like this <1234567> which is fine but
I want to add some css or class to change the way it look.
If you have any other way to achieve this. Please suggest..
please tell how can I customize it.
You can change it to make it looks something like this or like whatever you want:
Here is an example:
{% get_pages %}
<div class="pagination">
{% for page in pages %}
<li class="page-item">{{ page.number }}</li>
{% endfor %}
</div>
You can check the documentation here: https://django-el-pagination.readthedocs.io/en/latest/templatetags_reference.html#get-pages to check all the available options for get_pages

Symfony2 - How to only show specific elements to ROLE_USER

I am trying to hide CRUD elements in TWIG so that it only appears for the specified ROLE_USER.
Right now I am using IS_AUTHENTICATED REMEMBERED which works against anonymous users but other logged in users are still able to see this.
{% if is_granted('IS_AUTHENTICATED_REMEMBERED') %}
<li>
<a href="">
Create a new entry
</a>
</li>
{% endif %}
I want to only show this to the specific ROLE_USER that I have set in the access_control in security.yml and the controller. For instance the code above should only be shown to ROLE_USER1.
What is the command to do this in Twig?
Use is_granted('ROLE_USER1')
{% if is_granted('ROLE_USER1') %}
<li>
<a href="">
Create a new entry
</a>
</li>
{% endif %}

Octopress site.navigation

I have this thing in my Octopress blog:
<ul class="nav">
{% for link in site.navigation %}
<li {% if page.url == link.url %}class="active"{% endif %}>{{ link.text }}</li>
{% endfor %}
</ul>
What this:
{% for link in site.navigation %}
I checked _config.yml, but didn't find navigation definition. I searched the whole project for the string "navigation", without avail. Can someone please help me understand what this {% for link in site.navigation %} is, and how I can change it?
So, kikito thinks he's correct. Well, yes. Spot on, my friend.
I think the navigation yaml could go inside an _include called "navigation" or something similar, but I haven't tried using yaml inside those so I don't know whether it will work. In my case, since I've got a multi-lingual site, it's easier to have everything inside config (missing translations are easier to spot)
Bascially, go to navigation.html inside the _includes directory, and you may find the source where site.navigation is populated from. In my case:
{% include custom/navigation.html %}
<ul class="nav pull-right">
{% if site.github_user %}
<li><i class="icon-github-sign social-navbar"></i></li>
{% endif %}
{% if site.bitbucket_user %}
<li><i class="icon-bitbucket-sign social-navbar"></i></li>
{% endif %}
...
</ul>

Resources