Developer forum

Forum » Development » Handle custom font family/styling inside titles

Handle custom font family/styling inside titles

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I have a situation where I need to accommodate something like this:

This means that I have to add some custom styling to a piece of text inside a heading.
I can define a reliable separator that would identify the segment to be customized. Still, I would like to avoid (if possible) customization of all templates that have Title fields (which is basically almost every template).

I was wondering if I could apply a Regex pattern replacement before the page renders. Possibly on a Notification of some sort.

I think that DW is doing (or used to do) something similar for friendly URLs.

The questions are:
1. What would be the proper notification to use?
2. What is the performance hit associated with this scenario?

Thank you,

Adrian


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Use Standard.Page.AfterOutput - it contains a template instance that has the rendred markup as its html

Your code will determine performance.

Consider doing it client side instead - i.e. using something like this:

https://gist.github.com/cferdinandi/68bae3f551d7daff8d442e232c499307

Or if it is always the last word, you can do something like this - still needs some JS to locate that last word and inject the css accordingly:

https://codepen.io/anon/pen/GYxBZB

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

Thank you for the suggestion.

Unfortunately, the position of the text is not fixed. It can be anywhere inside the title.
I was trying to avoid changing it client side in order to avoid rerendering the content. But it can be a solution if the processing it server-side proves to be a performance issue.

Thank you very much,

Adrian

 

You must be logged in to post in the forum