Page 1 of 1

Global Search And Replace

Posted: Mon Jan 31, 2022 12:28 am
by Zippo
I’m new here and new to CMSMS so I apologize if this has been suggested but I would love to have a global search and replace function. It would be great to search all templates and/or style sheets for #fefefe and replace it with #cecece for example.

Re: Global Search And Replace

Posted: Wed Feb 02, 2022 2:46 pm
by DIGI3
A global search and replace would be handy but I think would have to come with a version control for "undo" as well, given the damage it could do. That's a pretty massive undertaking but perhaps a module developer would want to take it on.

In the meantime, that's a great reason to use variables for styles, so you only need to change something in one place. In a stylesheet you would do something like:

Code: Select all

[[$mybackground = '#fefefe' scope=global]]
.link {
  background-color: [[$mybackground]];
}
.button {
  background-color: [[$mybackground]];
}
then to change everything using #fefefe you'd only need to edit the first line. The scope=global makes it available to your other stylesheets, assuming this is the first one in the list. (There's other ways of doing this, and you can get into using modules and/or content blocks to give your client a simple theme editor, but this is the gist of it)

Re: Global Search And Replace

Posted: Wed Feb 02, 2022 3:08 pm
by velden
Although I've never used it myself I'd consider using CSS custom properties for this specific example.
https://developer.mozilla.org/en-US/doc ... properties

Re: Global Search And Replace

Posted: Fri Feb 04, 2022 6:33 pm
by Zippo
Thanks for the very helpful replies.