Results = 0

I am trying to build a homepage based in a modular form - including a slider. For some reason I cannot get the slider to work as it is set up in http://demo.getgrav.org/shop-skeleton/

So, I decided to build out the slides using the same method as I used for the showcase section on another part of the page. However, when I am trying to pull the images, I am getting 0, -1, 1 as the results for my queries I am setting in the header.

slider.md
pageslider:
- slide-image: test.jpg
slide-content: content one

- slide-image: image-2.jpg
  slide-content: content two

- slide-image: image-3.jpg
  slide-content: content three

slider.html.twig
{% for panel in page.header.pageslider %}
	<li>
		<div class="panel-bg" style="background-image: url({{ panel.slide-image }});"> 
			<div class="panel-padding">
			</div>
		</div>
	</li>
{% endfor %}

You can see the results:  http://ryanwake.com/pp/

The slider used in the shop-skeleton is using our lightslider plugin. It’s pretty simple to use as it’s really only one page that defines the text for each panel and the images need to be named: image-1.jpg, image-2.jpg, etc.

There are some basic instructions here on the lightslider github page, although it would be easier to download and setup the shop-skeleton package and copying the user/pages/slider folder and using that as your basis. You will of course need the lightlsider plugin itself, but you can install this easily with:

bin/gpm install lightslider

I did that and it wouldn’t work. So, I decided to not use that slider, and I will use my own. However, I cannot even get this to pull the assets I have in the header. Is there a reason I am getting -1,0.1 as results?

I can’t really tell because you’ve not pasted your YAML in code block, so can’t see the spacing (which is critical in YAML), but you will need something like:

pageslider:
  - image: test.jpg
    content: content one
  - image: test2.jpg
    content: content two
  - image: test3.jpg
    content: content three

then:

    {% for panel in page.header.pageslider %}
        {{ dump(panel) }}
        <li>
            <div class="panel-bg" style="background-image: url({{ panel.image }});">
                <div class="panel-padding"> 
                    {{  panel.content }}
                </div>
            </div>
        </li>
    {% endfor %}

It seems that Twig doesn’t like the dot syntax with array items with - in them. You can however use _, such as slide_image however slide_ is redundant in this case so I remove it completely for improved readability.

BTW, if you use the dump() command with the debugger enabled you can get a dump in the message tab to better see what’s going on. Find out more about the debugger and logging.

Remove that when you go live of course.

Also, this approach of using page headers means you won’t be able to use Markdown in your panel contents, it will need to be HTML, just FYI.

Also extra FYI, you will need to have a full working URL to the panel.image file as it will not work as-is.

So, I decided to take your advice, I figure I am doing something wrong. So, I tried to start fresh with a new install of the lightslider plugin - and I am getting an error. SMH.

http://ryanwake.com/progress_pump/

You need to update Grav, your version is out of date. Can you access the terminal on this site via SSH? if so you can update with GPM, grav itself, plugins, and themes too. Your on < 0.9.3, and we’re up to 0.9.5 now.

Thank you for being quick to respond. You were right. Followed your advice and ended up with what I needed. Thanks again.

Phew, glad you got it sorted!

So far, I am pretty impressed with Grav. It’s been a bit of a learning curve simply because I want to completely customize it, and I don’t really know much about TWIG yet. But that was one of the reasons I chose it, so I could learn more TWIG. So, thank you for creating such a cool product.

Thanks! We built Grav because nothing out there was really up to the task, and being extensible and flexible was a key component of that.

I think that when Grav gets more momentum more people start developing plugins and themes, there will be very little it will not be able to do. So far everything I have thought of I’ve been able to realize with very little effort compared to traditional platforms. That’s what makes it so much fun to work with :slight_smile: