3

First of all, I'm sorry for my question because I'm beginner in Sitecore SXA and in English too. ;)

I'm working on SXA compatible component and I have already advanced well I think but I must have missed a few elements for my module to be complete and be 100% compatible with SXA.

So, I don't know really if my method is the best for a custom component? And if I forgot to do something?

Here I proceeded to realize my module, and it's just a component to make a list of tree buttons:

  1. I made a model that implements RenderingModelBase.

  2. I made a controller which implements StandardController with a method that retrieves the current datasource and then creates a model based on this datasource:

My controller

  1. And a view for my index ActionResult :

My view

  1. And after publishing on my website root, I make a template for my component in the Content Editor.

  2. I added the base template for my rendering parameter, IStyling and IComponentVariant.

  3. I add a rendering using this template rendering parameter and use my controller name and ActionResult name.

  4. Next, I add this rendering in my toolbox, by adding an available rendering in my presentation folder and add this rendering inside.

And now, I can add this component in the Experience Editor, so it's great but I'm not sure if it's really good...

because :

  • I don't see my CSS, my tree button it's just tree links...
  • I don't use @Model.CssClasses.Aggregate() on my view because I can't ( I have an error if I use it ) but I see it on the other question in this site. So how can I use it and why?
  • I don't use the parameters _repository in my controller, and I do not know what it really is, but I see it on the other question on this site. So the same question how can I use it and why?
  • And finally, I'm not sure about putting these different items in the right place in my website file? Can someone show me what is the best practice?

I know that my questions may seem simple for some, but I confess that I am a little lost and I have not managed to find any answers.

In any case, thank you for having already read my post and even more if you answer it!

2
  • HI Fabien - first of all, you don't have to apologize for your English, there are many non-native English speakers here :) - second, this is a large post that really has multiple questions in it. It would be better to split out those questions into small specific questions - it may be easier to answer there and would fit the format of the site better.
    – Richard Seal
    Jan 25, 2017 at 14:22
  • HI Richard, yes of course, I understand my question is too general. After some research, I found some answers here. So if you thought my question is not suitable for here, you can delete it. Thank you for this return.
    – Fabien G.
    Jan 31, 2017 at 18:02

1 Answer 1

1

Looks like you are trying to make a menu. There are some out of box controls for menu items like 'Navigation' or 'Link List', you can use them and then apply rendering variants to achieve your navigation layout. I would suggest to use controller renderings if you code behind contains some business or domain logic. If your components are only for querying certain items and displaying them as iss, use rendering variants.

Your Answer

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

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