then, after updating the HTML, have that page rendered, (essentially, updating the page dynamically and displaying the updated HTML document)? This would be done by a component, so that whatever page it was included on it would 1) Get the page's HTML, 2) Analyze the HTML, and potentially update it, 3) then, display the updated HTML in place of the original HTML, (i.e. with any new elements, javascript, CSS etc.? Ideally, I'd like to update the page's representation in the JCR, so that the dynamic logic won't have to be run everytime the page is loaded, however, if there's no way to do this, I'll just have to incur the cost of running it everytime the page is loaded. Please detail the steps required to do this.
Solved! Go to Solution.
Views
Replies
Total Likes
Its not best practice to dynamically modify AEM generated HTML code that is based on components, etc. A better way to dynamically inject scripts and content is to use Dynamic Tag Manager. See:
http://www.adobe.com/ca/solutions/digital-marketing/dynamic-tag-management.html
Views
Replies
Total Likes
I am not sure, what you want to achieve with this. What are your requirements?
kind regards,
Jörg
Views
Replies
Total Likes
The requirements are to be able to locate HTML elements in the current page document, inject HTML snippets, (and possibly code snippets), immediately before or after the elements, (e.g. inject HTML immediately before the closing </body> element, or to right a script snippet in the <head>), and then have the updated HTML rendered in place of the page's original HTML. Of course, it'd be best to update the page in the JCR, so that the changes are persistent, but if that's not possible, it'll have to be done dynamically each time the page is loaded.
Views
Replies
Total Likes
Hi,
I do understand, that this is your approach to handle the requirement, but still I don't understand the reason, why you want to do this.
If you have the HTML of the page under your full control, why don't you enhance your templates and components in a way, that you don't need to parse the HTML again.
kind regards,
Jörg
Views
Replies
Total Likes
Jorg, the primary reason is to be able to interject HTML and script DYNAMICALLY, (or, delete, or update script, add simple HTML etc.), based on some business logic. This will eliminate the need to have developers touch code to update simple analytics scripts etc., and allow authors to achieve this by dragging and dropping this component on a page. If you know how to achieve this, please help. These types of features are MANDATED by management, even though it's not the common approach.
Views
Replies
Total Likes
Its not best practice to dynamically modify AEM generated HTML code that is based on components, etc. A better way to dynamically inject scripts and content is to use Dynamic Tag Manager. See:
http://www.adobe.com/ca/solutions/digital-marketing/dynamic-tag-management.html
Views
Replies
Total Likes
I don't know that i truly understand what you're trying to accomplish, but the business requirement sounds pretty out there and impossible. I think maybe it'd be worth going back to management and teaching them the best practices of a CMS and websites, rather than trying to tailor a CMS to do something it's not supposed to do.
Views
Replies
Total Likes
smacdonald2008 wrote...
Its not best practice to dynamically modify AEM generated HTML code that is based on components, etc. A better way to dynamically inject scripts and content is to use Dynamic Tag Manager. See:
http://www.adobe.com/ca/solutions/digital-marketing/dynamic-tag-management.html
Thanks, and I've certainly considered using DTM, (which satisfies several of the use-cases), but does DTM allow you to specify where the scripts and/or HTML is injected into the page, (i.e. before or after a particular HTML element)??
Views
Replies
Total Likes
Hi
As stated by many expert that this is not a good practice.
But, still to do so, please find below the link that can act as some help to you.
//
Link:- https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html (Example to show you how to do get/post call and responding to it).
I hope this could help you.
Thanks and Regards
Kautuk Sahni
Views
Replies
Total Likes
Kautuk, thanks a TON for the suggestions. I will try this to see if I can get it to work, and if it works, all I'll have to do is persist the modified page back to the JCR. I hate having to hack things in place, but until I gain the confidence of management, I can't continue explaining/arguing over whether this is the correct/best way to do it, and I just have to go ahead and do what I'm told/asked to do. If anyone else has alternate ideas, I'd love to hear them too.
Views
Replies
Total Likes
Views
Likes
Replies