As you can see in the above example, the Home page is represented as a sibling to the About and Locations pages.
I created an item in the tree to represent the Home page, but without all of the overhead of a full page.
Out of the box
Let's have a look at what comes out of the box, and why I decided to do something different.While working with SXA you'll see that there is a Navigation component which allows you to specify a few properties to simplify the setup.
The option to include the root page should work for you in most scenarios. When the markup is generated, you however do not see the Home page on the same level. Let me show the differences in markup.
Here is an example with the root page included and the structure flattened. Notice that the real Home page is at level0, and my fake Home page is at level0 but nested under a ul li.
As you would expect, if you don't flatten the structure the level classes change but the markup is the same.
By creating the fake Home item you are able to eliminate the level0 and thus simplify the markup. Notice that the levels begin with level1.
Custom Template
Getting started is really pretty straightforward.- Create a new template called "Navigation Link".
- Add a few properties to the item.
- Inherit from "_Navigable".
- Add template to the Insert Options for other pages.
- Don't forget to set the source field on custom templates:
- Image field -> query:$siteMedia
- General Link field -> query:$home
- Rich Text -> /sitecore/system/Settings/Html Editor Profiles/Rich Text XA
When using the names I depict in the screenshot, the default rendering variants will work automatically. If you create a custom rendering variant for the Navigation component, be sure to put the proper field name in the link target field like the following:
Have fun with this!
- Michael
Thanks for post. This solved an issue we were facing with adding links instead of pages in the standard navigation.
ReplyDelete