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

01 - Add a header image to the homepage #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

luca-rath
Copy link
Contributor

@luca-rath luca-rath commented Jul 7, 2020

Add a header image to the homepage

Goal

Our homepage looks quite naked right now. To stir our users emotions, we would like to add a nice header image on
the homepage.

Steps

  • Add a new property headerImage with the type single_media_selection to the
    config/templates/pages/homepage.xml file
  • Log into the admin UI with user "admin" and password "admin"
  • Switch to "Assets" and create a new asset collection with the name "Header Images"
  • Upload a beautiful image to the newly created collection
  • Modify the "Homepage", select your uploaded image as header image and save the page
  • Add a new image format with the key x400 to the config/image-formats.xml file
  • Output the image in your templates/pages/homepage.html.twig in the right dimension

Hints

  • Use {{ dump(content) }} in the Twig template to find out how to output the header image URL.

More Information

To solve this assignment we need to understand a few different concepts in Sulu:

Each page in Sulu has a template. The template consists of two parts:

  • an XML file with the structure of the page
  • an HTML (Twig) file with the HTML of the page

A template is made up of properties. Each property has a name (for example "title") and a (content) type (for
example text_line). The supported content types can be found in the documentation:
http://docs.sulu.io/en/latest/reference/content-types/index.html

Furthermore, Sulu uses image formats to transparently create thumbnails in the respective sizes for uploaded images.
A thumbnail is generated when it is accessed for the first time. That means that only thumbnails that are really used
are stored on your disk.

When defining image formats, you can apply different actions to your source images. The most used action is scale,
which resizes an image into the desired dimensions while keeping its original aspect ratio
(http://docs.sulu.io/en/latest/book/image-formats.html).

Links

@alexander-schranz alexander-schranz added the assignment Pull request for a assignment solution label Sep 23, 2020
@niklasnatter niklasnatter force-pushed the assignment/01 branch 2 times, most recently from 27ab3c6 to b0a9741 Compare September 23, 2020 10:47
@niklasnatter niklasnatter force-pushed the assignment/01 branch 6 times, most recently from 5b17716 to 3a7ed77 Compare October 23, 2020 15:14
@niklasnatter niklasnatter force-pushed the assignment/01 branch 2 times, most recently from a07c1b8 to 2f93f7f Compare February 16, 2021 14:23
@niklasnatter niklasnatter force-pushed the assignment/01 branch 2 times, most recently from 4db185c to b5bf216 Compare March 31, 2021 10:51
@ericpugh
Copy link

Note: I think the docs in this description have moved.

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

Successfully merging this pull request may close these issues.

4 participants