--- title: 'Making CSS-only Overrides' created_time: '2023-09-23 17:31:48' language: fr subtitle: '' --- # Making CSS-only Overrides by Marc Dechèvre **JoomlaShack Conference, 9 & 10 December 2020**  slides https://slides.woluweb.be [replay on YouTube](https://www.youtube.com/watch?v=lsg5XASlp1s&list=PLbSGtuctZCf2kLvfAjsFnZumeyMwAtStQ) ## The power of Joomla **Did I already tell you that Joomla is sooo powerful ?** - not only because of its native **Custom Fields** - not only because it manages **Multilingual** websites natively - not only because of **Users Access Management**... - but also a.o. because of the possibility to make **Overrides** / Alternate Layouts for any View of any Component or Module --- Most of the time you don't even need to know anything of **PHP** to make your first Overrides, for example if you simply want to move the Image before/after the Title or create a 2 column layout for your content. And once you have tested/tasted it, you will probably want to go to the next level and exploit the possibilities of PHP too to make more complex things. --- Typically making an Override / Alternate Layout entails two things: 1. changing the View, namely the **HTML generated by some PHP file** 2. adding a bit of **CSS** to customize the styling of the elements (if needed) ## Inspiration for Overrides To get inspiration for Overrides / Alternate Layouts, see for example - https://www.j-over.de/ - https://www.web-eau.net/developpement/joomla-overrides and -why not- join the current Joomla Override Challenge #joc - https://twitter.com/hashtag/JoomlaOverrideChallenge ## Overrides... only with CSS In this presentation, we will show how to make a "kind of" Override or Alternate Layout... only with CSS. This is indeed made possible by what is called CSS Grid https://caniuse.com/css-grid ## Example On the following Animated Gif, we already have a first idea of what we can achieve: - a total freedom on where I put which element (Title, Image, Text, Links, ...) - different layouts according to the viewport ---  ## Advantages This way of making Overrides is very handy for different reasons: 1. even **less technical** people can customize their layouts (no HTML and no PHP involved) 2. you can easily achieve even the most **sophisticated layouts** 3. you can have (completely) different layouts according to the **viewport** and so be mobile-first 4. it works no matter your **Bootstrap / UIkit / ...** version --- 5. in many cases, you can just copy-paste your CSS **from one Template to another** and it will work immediately (in our demo, our override in Astroid 2.4 immediately works on Helix 3, even if they come from two different template editors and if the latter is an old generation of Helix) 6. it requires **less maintenance**: when you create a "real" Override / Alternate Layout, you actually fork the original PHP file. This means that when there are fixes / improvements / changes to that original Joomla file, you are supposed to revise your forked code accordingly 7. last but not least, **Joomla 4's** frontend is largely based on CSS Grid. So it is definitely an extra motivation to learn it so that you can customize even more things in Joomla 4 --- Of course, real Overrides / Alternate Layouts are still useful because you can go further and do more things. But if the only purpose is to rearrange the layout of the existing content without manipulating it, CSS Grid can be a nice way to do it. ## How it started I have always been very curious about **Flexbox** and **CSS Grid** but never really implemented them in my projects, except for little things like displaying the Partners/Sponsors/Clients logos in a footer. --- The first really nice implementation of **CSS Grid** I discovered in the Joomla world was done by Allon Moritz (the father of Joomla's Custom Fields btw, my favourite topic 😊 ) https://joomla.digital-peak.com/demo/dpc/en/event-details-view.html Simply inspect the code and look at `