Jump to content

data attibutes in page edit link


virtualgadjo
 Share

Recommended Posts

Hi all,

i'm wondering what would be the best way to add custom data attributes in pw link edition in order to get something like

<a href="https://foo.com" data-src="https://foo.com" data-width="800" data-type="iframe">xxx</a>

and so on
would you advise to use a hook? a custom text formatter? extend pw native module? i would like to be the less savage i can be (and usually am ?) hence the question ?
(i know there are two different things here, using the href as a data-src would be quite easy with js but adding whatever other data-attibute, depending on the link is something else)

of course, i'm thinking making that easy for final users as personally i would write this directly in the source code but this is a migraine source for non coders... ?

any advice would be very welcome

have a nice day

Link to comment
Share on other sites

Hi @kongondo,

and thank you for taking time to read my post ?

i'm speaking about the native ProcessPageEditLink module where we can store a few classes, rels and target for the end user to use when adding a link in ckeditor (and even add them, or not, by default, to external links, a very clever and useful feature...)
i'm just wondering if it would be a good idea to modify it to deal with dynamic data-attributes or if it is again one of my savage ideas :
D

have a nice day
chris

  • Like 1
Link to comment
Share on other sites

2 hours ago, virtualgadjo said:

i'm speaking about the native ProcessPageEditLink module where we can store a few classes, rels and target

Wow. I didn't even know this module existed ?.

 

2 hours ago, virtualgadjo said:

i'm just wondering if it would be a good idea to modify it to deal with dynamic data-attributes

I have just had a quick look so cannot comment much. You should be able to create your own version of the module which ProcessWire will subsequently detect and ask which one to load (I think this applies to Process Modules too - anyone?). Maybe a hook would work too, but am not sure. Looks like the links are created in JavaScript, so, you would need to consider that too. Maybe your solution could be all at the JavaScript level, although in that case you would need access to the value for your data-attributes. Sorry I am not of much help. Just a few starter thoughts ?.  

  • Like 1
Link to comment
Share on other sites

10 hours ago, kongondo said:

Wow. I didn't even know this module existed ?.

? there are so many coming with PW... i nearly always use this one ablility to add default attributes to external links as clients tend to forget those good SEO practices and, thanks to this module, they always act as pros ?

Coming to this attributes thing, this night i had an idea when having to deal with modale videos using a library needing attributes instead of a simple class
The solution may be to create a repeater field, each element containing an image (screenshot for example), the video url and... a field using your FiledtypeRuntimeMarkup module displaying the HannaCode to be used in ckeditor
i have done this kind of trick for images carrousels that a client may use wherever she wanted in a content and she appeared to like it and used it a lot ?

Thanks a lot for coming and brainstroming with me + for this module i like to couple with HannaCode as for many people, writing a simple snippet of code is a bit freaky when copying/pasting sounds like a daily usage ?

have a nice day

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...