Creating a slideshow with dots navigation I have this slideshow implementing to entries, which works except Dot navigation.

A count of Dots in navigations depends on manually inputing attributes and assigning 
numbers from 0...∞ ascendingly like this.

&lt;ul&gt;
    &lt;li data-uk-slideshow-item="0"&gt;&lt;a href=""&gt;&lt;/a&gt;&lt;/li&gt;
    &lt;li data-uk-slideshow-item="1"&gt;&lt;a href=""&gt;&lt;/a&gt;&lt;/li&gt;
    &lt;li data-uk-slideshow-item="2"&gt;&lt;a href=""&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


Actually, I limit(3) count of entries, so I know that there will be a certain number of dots. However, If there aren't any entries defined or only 1 entry defined, than I always get all three dots appeared, which don't function. So there MUST to be the exact number of dots as entries. 


1 Entry: 1 Dot
2 Entires: 2 Dots
3 Entries: 3 Dots


So I'm thinking to go with if condition or loop through entries, but with my attribute output with number increased by 1.

So far, I've started with if, because no need to loop ... and I don't know, if this is right way.

{# Display navigation if the condition is true #}
{% if craft.entries.section('handle').lightswitchHandle('1') is defined %}

&lt;ul&gt;
{# This is where I end up ... some comparission filter maybe ? #}
{% if craft.entries.section('handle').lightswitchHandle('1') %}
  &lt;li data-uk-slideshow-item="0"&gt;
      &lt;a href=""&gt;&lt;/a&gt;
  &lt;/li&gt;    
{% elseif craft.entries.section('handle').lightswitchHandle('1') %}
  &lt;li data-uk-slideshow-item="1"&gt;
      &lt;a href=""&gt;&lt;/a&gt;
  &lt;/li&gt;    
{% endif %} 
&lt;/ul&gt;
{% endif %}


Update

&lt;div id="food-slideshow" class="uk-switcher"&gt;
&lt;div data-uk-slideshow&gt;
    &lt;span&gt;&lt;a href="" data-uk-slideshow-item="previous"&gt;p&lt;/a&gt;&lt;/span&gt;
    &lt;span&gt;&lt;a href="" data-uk-slideshow-item="next"&gt;n&lt;/a&gt;&lt;/span&gt;

    {# Get the slides, store in variable called "slides" #}
    {% set slides = craft.entries.section('food').news('1').limit(3) %}

    {% if slides %}
        &lt;ul class="uk-slideshow"&gt;
        {# Output slides, using the same "slides" variable #}    
        {# Loop through "news" with lightswitch on #}
        {% for slide in slides %}
            {# Entry type - Article #}
            {% if slides.type == 'article' %}
                {% include '_includes/components/food/news-article' %}
            {# Entry type - Person #}   
            {% elseif slides.type == 'person' %}
                {% include '_includes/components/food/news-person' %}
            {# Entry type - Recipe #}
            {% elseif slides.type == 'recipe' %}
                {% include '_includes/components/food/news-recipe' %}
            {% endif %}
            {% else %}
                &lt;p&gt;Any Text&lt;/p&gt;
        {% endfor %}

        &lt;/ul&gt;
    {% endif %}

{% if craft.entries.section('food').news('1') is defined %}
{# Output navigation, check length of "slides" variable #}
&lt;ul class="uk-dotnav uk-dotnav-contrast uk-position-bottom uk-text-center"&gt;
     {% for i in 1..slides | length %}
         &lt;li data-uk-slideshow-item="{{ i }}"&gt;
            &lt;a href=""&gt;&lt;/a&gt;
         &lt;/li&gt;
     {% endfor %}
&lt;/ul&gt;
{% endif %}

&lt;/div&gt;
First, store your slides in a variable when you fetch them using craft.entries. Then, you can use the length property of that variable (which will be equal to the number of slides) to output your dots/navigation.

Full example:

{# Get the slides, store in variable called "slides" #}
{% set slides = craft.entries.section( 'yourSlideSection' ).limit( 3 ) %}

{% if slides %}
&lt;ul class="slideshow"&gt;

    {# Output slides, using the same "slides" variable #}
    {% for slide in slides %}
    &lt;li class="slide"&gt;[Your slide content here]&lt;/li&gt;
    {% endfor %}

    {% if craft.entries.section('handle').lightswitchHandle('1') is defined %}
    {# Output navigation, check length of "slides" variable #}
    &lt;ul class="nav"&gt;
         {% for i in 0..slides | length - 1 %}
         &lt;li data-uk-slideshow-item="{{ i }}"&gt;
              &lt;a href=""&gt;&lt;/a&gt;
         &lt;/li&gt;
         {% endfor %}
    &lt;/ul&gt;
    {% endif %}

&lt;/ul&gt;
{% endif %}


What the inner navigation loop does here, is to increment the variable i by one, each time the loop runs, until i is equal to the number of slides (slides | length). This means you'll always have exactly the same number of dots as slides. Inside the loop, the variable i is also used for the data attribute.

More on the Twig loop function here