3

I have a page that I've used partial designs to create a consistent header and footer for all pages across my site. Now I'm trying to figure out how to have different types of content in my "main" section. I see the Page Content type in the list of components, but I can't figure out how to use it. Every time I try to use it, all I get for a rendering is the word Content Field.

What is the purpose of this Page Content, and how can I use it?

3 Answers 3

7

I will try to answer your main question and few that you asked in comments.

What is the purpose of this Page Content, and how can I use it?

Before that lets clarify what variants are

Variants:

Page Content is one of the simplest renderings in SXA (in terms of complexity). Without variants it would be a rendering which displays a single field (same like basic rendering which displays page title).

Adding variants to a renderings change it in a way you can dynamically choose which fields should be used to display the content.

So instead of creating different components which are the same but displays different fields (content or title for example) you can have one with variants.

Yes. We could live without Title or Page Content rendering in SXA because both are working the same.

Page Content rendering

I think this is a key point here.

It displays fields which are present on your context item. Your current page is holding data for Page Content so there is no mapping needed.

Examples

Scenario 1: single field

I don't have any page designs. I want to put renderings directly on a page.

My page template has following specification: contains single field Content.

  • I create a new item under home using my Page Template.
  • Fill field Title with some text
  • Open newly created Page and drop Page Content rendering
  • Select default variant Content

    Now you will see that the rendering will display single field from your page named Content

Scenario 2: multiple fields

I don't have any page designs. I want to put renderings directly on a page.

My page template has following specification: contains fields Title, Content, Image.

  • I create a new item under home using my Page Template.
  • Fill field Title with some text
  • Fill field Content with some text
  • Fill field Image with some image
  • Open newly created Page and drop Page Content rendering
  • Create new Rendering Variant, configure it to display Title, Content, Image fields and assign this to your Page Content (see screenshot below)

enter image description here

Now you will see that the rendering will display multiple fields from your page in a way you defined it in your Variant Definition. You can change the order of fields, change tags, add prefix, suffix, nest fields in some divs and so on.

Scenario 3: using page content on partial design

Like you already noticed when you use Page Content on partial design the only thing you see is Content field (see example for multiple fields).

enter image description here

It is totally normal. We call it mock values for partial designs. You already know where the Page Content gets the fields from (from the context item).

When you are editing partial design you are currently on an item which does not contain any of your fields, so there is nothing to display.

If you use this partial design with page content on it on any page where fields are present you will see them rendered.

Different types of content in my "main" section.

Let's say you have footer, header partial designs.

You want to use footer and header on every page but have different center section (different main) for different page types.

You have to define different partial designs and create different page designs then for different page templates.

Example:

  • News Page Design, which consists

    • header partial design
    • main with news fields partial design
    • footer partial design
  • Blog Post Design, which consists

    • header partial design
    • main with blog post fields partial design
    • footer partial design

Then you will have to map different designs to different page types:

enter image description here

From now each of your page will share the same parts like: footer, header but will have different main depending on template.

Hope it helps

1
  • This is awesome Alan, very helpful!!! +1
    – Joel Min
    Commented Jul 9, 2019 at 1:02
0

I think what you want to do is create a page template for each "type" of content page (e.g., blogs, products, news, etc).

To add a custom page template, you can create a template for your Project that inherits from your Page Template (or from the SXA template that it inherits from).

After that, I would create a global header and footer partial, and then a partial for each type of page that you want. You can assign those to page designs for each type of page across your site.

1
  • Right, I think that I'm following you, Dylan. But how do I associate the different parts of a product to a content page. For example, I want to have a product that has a title, description, image, and price. How do I setup that in SXA? Where do I store my actual products? How do I access those items in one of those template pages? Commented Nov 10, 2016 at 17:20
0

The Page Content type in the list of Components in a plain SXA setup will output the Content field of your current item.

You can adapt it with variant to show more fields.

Haven't tested this myself, but in the "Rendering Variants" you can find a Page Content item. I assume you could add variant there to include some additional fields in the Page Content component.

enter image description here

3
  • I've got multiple fields defined in my variation. How do I use them? Is there some sort of mapping that is done somewhere that says which field in my variation maps to a data source? How do I tell the variation/page content what data to use? It seems like this is the way to use multiple components in a single page spot, but I'm having a hard time figuring out how that mapping works. Commented Nov 10, 2016 at 17:15
  • For what I could see in the code, the Page Component rendering has a loop over variant fields. But there stops my knowledge.. maybe one of the experts can elaborate.
    – Gatogordo
    Commented Nov 10, 2016 at 19:25
  • If you really need several product fields displayed, probably in a specific layout, I assume you need a custom rendering. But I could be wrong - am no sxa expert yet ;)
    – Gatogordo
    Commented Nov 10, 2016 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.