Developer forum

Forum » Swift » Modify/extending swift: Best practise?

Modify/extending swift: Best practise?

Kasper Legarth
Reply

Hello.

We are starting on our first swift projekt. The goal is to use swift without modifications, but it is not possible 100%.
What are the best practises for minior adjustments? Examples of adjustments could be:

  • General

    • Change some the value of some the standard paddings. It could be a row with max spacing is 124px instead of 96 (py-6)

  • Swift_ProductGroupSlider

    • Remove the buttons on each items

    • Place the arrows on the same side under the items.

Thanks for any advice :) 


Replies

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Kasper,

 

You have a few ways to go about it. I can't say there's a prefered way, as they have pros and cons, but let me speak about your examples specifically

 

General paddings

This comes with a cost. You can

  • Create a custom css rule to override the default behavior of py-6
    • I cringe at suggesting it, but it would prevent you from doing customizations all over, which would hinder your ability do do upgrades
  • Edit the Item types and Templates
    • You can edit the templates and the values associated with the item types.
    • This requires some work, but also hinders your from doing upgrades easilly
    • But it does allow you to honor the Bootstrap's proper css classes so it's not confusing to developers
  • Do nothing
    • Push back on the customer/designer and work within the boundaries of the options
    • Although it seems very easy to add, having a smaller set of options helps the users no to get into choice overload. It also helps users to make easier and more consistent choices
    • Although the HTML framework that supports Swift is Bootstrap 5.1, it may/could not be in the future, so it's also not interesting to have the options match every padding Bootstrap provides
    • But then your design may not look at expected (or nice even)

 

I know some additiona features are in the works to make things like this a bit easier, but I can't speak into those.

 

That said, there is something to say about adding 1 more padding option OR some different options. Those requests come up including from me (when makes sense), but I am not supporting of extending this to everywhere.

 

Product Group Slider

This is a more common type of customization. You have a few options here (all with pros and cons)

  1. Change the item type and/or template directly
    • This may make it harder on the upgrade Swift, but if you use Version Control, you can come back to it later and re-implement the change
  2. Create a new template for an existing Item type
    • If you don't need to customize the Item type settings you can just create a copy of the template and then assign it in Apps > Websites > choose your website > Layout > Paragraph Layouts
      Then just pick the custom template for the ProductGroupSlider item type
  3. Create a copy of the Item type
    • You can also create a copy of the item type if you need to add additional fields
    • You'll have to create a copy of the template as well, and if you name it exactly like the System name of the item type, DW can link them together automatically, otherwise check the bullet above
    • You'll have to edit the restrictions of the Page item types where you want to use your new Item Type and enable it under "Allowed Children"
    • This reduces your customization footprint, since it's limited to the restrictions on the Page Item Types, but you probably also can't automatically inherit any changes from upgrades
  4. Use Javascript
    • I also cringe a bit at this suggestion too, but may be applicable in some scenarios to use javascript to add/remove css classes and/or some other modifications.

 

I can tell you we use Option 1 most of the times, and use the power of Git to do cherry-picks and re-implement the changes. That comes with a disciplined behavior of documenting the changes, so we can tell what's what when conflicts emerge.

 

Best Regards,

Nuno Aguiar

 
Kasper Legarth
Reply

Hi Nuno.

Don't worry, I cringe at the same things as you, so those options are out of the question ;)
I think what would suit us the best would be to make custom templates where we need some modifications. 

Thank you for your answer.

Kind Regards,
Kasper Legarth

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Kasper

Also take a look at the customisation section in Swift docs: https://doc.dynamicweb.com/swift/customization

 

You must be logged in to post in the forum