I’m working on trying to fix the in-page anchors within modx. I’ve already added a plugin that fixes the problem. But my pages have a fixed header with a search bar that I’m trying to code some css for to fix it.
How can I change modx to automatically add a class to that <a> tag? Something like .anchor-fix or something.
This basically works without the extra work for something that is not often used. Modx is weird about it though in that it creates an <a> tag with an ID only rather than an href. So as long as my IDs contain the word “bookmark” this will work fine. Maybe making a template variable that automates some of this too.
Oh, I thought you wanted to put a class on the link to the anchor, not the anchor in the page.
That’s Tinymce creating the page anchor as a link tag plus ID, no href. (It’s valid, but kinda ugly imo. Technically any element on the page with an ID is an anchor, so why use a link tag when it’s not actually a link.) Redactor lets you use IDs on any element as anchors.
Anyway, Tinymce does have a setting called visual_anchor_class that allows for a custom class on anchors, which I think is exactly what you’re looking for. Don’t know if your Tinymce extra allows for configuring it though. Probably TinymceWrapper would.
Edit: nevermind it looks like that class is only for the appearance within the editor window.
Also, i had to amend the CSS for the empty anchor tags a bit. For some reason iOS Safari doesn’t accept empty <a> tags that use padding. So instead of this: