-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MDLSITE-7917: Frontpage editable blocks #18
base: main
Are you sure you want to change the base?
Conversation
As an example, you can see the differences between production and next (I added the changes directly into the next pod): |
amd/src/contributedstrings.js
Outdated
define([], function() { | ||
return { | ||
init: function(contributedstrings) { | ||
const contributedstringsElements = document.querySelectorAll('.contributedstrings'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that
class="contributedstrings"
is appropriate selector here. We should not use CSS selectors and identifiers for JS integration. An element that has special meaning for a JS (such as its content is provided like in this case) should be identified via data
attribute. See https://moodledev.io/docs/5.0/guides/javascript
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, my content comes from an HTML block, and moodle filters all these data attributes from this type of content.
This class actually is inside a strong
tag. I tried to add data-contributed-strings
, and the editor changes that to data-contributed-strings=""
but finally is filtered and disappears in the page, the same happens if I use an attribute with content like data-contributed-strings="placeholder"
.
¿Do you know how to change that from a class and works?
</div> | ||
</div> | ||
</div> | ||
{{#js}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need those scripts at all? Could not this simple replacement be put here into the JS section completely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it in the module to maintain the standard, replicating what I did in other JavaScript developments like this, related to the HTML content of Moodle.org pages.
I could simplify it and place the content directly outside the AMD module, but that way, we wouldn't keep the code separate.
Hi David,
Working on the task https://tracker.moodle.org/browse/MDLSITE-7917
I have removed the initial blocks on the frontpage, and now they will be managed as content from the platform.
To do this and taking into account that part of the content is dynamic, I have added 2 JavaScripts that update the dynamic content:
In the task, I added the content with the structure the initial blocks must have. Using this content, the JavaScript modifies the necessary data and maintains the same appearance as the original blocks.
Thanks