Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sidebar elements #7

Closed
Suplanus opened this issue Nov 28, 2019 · 4 comments
Closed

Sidebar elements #7

Suplanus opened this issue Nov 28, 2019 · 4 comments

Comments

@Suplanus
Copy link

Suplanus commented Nov 28, 2019

In your live demo there are this side elements:
image

But in the _demo I can not see how to do this. Is it possible to set the images? Also dont understand that for intro.

@hughbris
Copy link
Owner

Sure, it's a little convoluted but very flexible :) It should possibly be documented.

In `_demo/pages/01.home/home.md, line 24 (which I don't seem to be able to link to directly), there is:

features:
    items:
        '@taxonomy.pagetype': 'feature'
    order:
        by: default

which is defining a Grav collection called 'features', made up of every page tagged 'feature' in the taxonomy vocabulary 'pagetype', so any page with taxonomy.pagetype: feature in the frontmatter.

Let's take the page you can see in the screenshot, right-sidebar.md. It has that in its frontmatter, and then these items as well in its frontmatter:

spotlight:
  image: 'images/pic04.jpg' # spotlight.jpg
  headline: 'Interdum felis blandit praesent sed augue'
  subheading: 'Nunc commodo accumsan eget id nisi eu col volutpat magna'
  blurb: 'Feugiat accumsan lorem eu ac lorem amet ac arcu phasellus tortor enim mi mi nisi praesent adipiscing. Integer mi sed nascetur cep aliquet augue varius tempus lobortis porttitor lorem et accumsan consequat adipiscing lorem.'
  # button:
  #  text: 'Learn More'

This is where that info is pulled from. So the direct answer to your question is spotlight.image in every page tagged pagetype='feature'. Change that for a different image.

You could redefine that collection 'features' in the homepage if you want, using a taxonomy query, a fixed list of pages, or any of the methods available for defining a Grav collection.

If you look at how this works in Twig, you can see home.html.twig just loads the collection based on its name, then calls partials/sections/features.html.twig on each feature item.

That template checks for image in the frontmatter under spotlight and has a fallback too.

A bit quick but I hope that explains it.

@Suplanus
Copy link
Author

Great. Thanks a alot 😘
I will look into it!

@8513421
Copy link

8513421 commented Apr 17, 2020

Hi! Sorry but i dont understand your previous explanation. Could you write me exact code to put in home yaml section to run sidebar in home page? Becasue in demo pages home-sidebars is inactivated (and no code for this) and i spend few hours to figured out how to activated it with no result. Thanks in advance!

@ganar
Copy link

ganar commented May 15, 2024

Great! I manage to solve the issue I had with this: thanks for the explanation, @hughbris

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants