Quantcast
Channel: Joomla! Forum - community, help and support
Viewing all articles
Browse latest Browse all 1466

General Questions/New to Joomla! 4.x • Re: display the custom_html module's Note field in the frontend

$
0
0
That was my initial thought and why I tried to get the modulenote inside the Sourcerer code in the module content. But I couldn't get it to work so I incorrectly opted for the module override.

THe concept is that the modulenote is the table name. In the following example it is: p3rm_tblPlantsB

Do you know how to get the modulenote, from the same module, inside this same Sourcerer code in the content to replace the p3rm_tblPlantsB?

Code:

{source}<?php$query = "SELECT COUNT(*) from p3rm_tblPlantsB";$database->setQuery($query);$result = $database->loadResult();?> <!DOCTYPE html><html lang="en"><body><h3 class="number" data-total="<?php echo $result; ?>" id="animated-number-<?php echo $result; ?>">0</h3><script>document.addEventListener("DOMContentLoaded", function() {const element = document.getElementById('animated-number-<?php echo $result; ?>');const total = parseInt(element.getAttribute('data-total'), 10);let current = 1;const duration = 2000; // Animation duration in millisecondsconst increment = total / (duration / 10); // Increase the number every 10msconst animateNumber = () => {if (current < total) {current += increment;if (current > total) current = total;element.textContent = Math.floor(current);requestAnimationFrame(animateNumber);} else {element.textContent = total;}};const observerOptions = {root: null, // Use the viewport as the rootrootMargin: '0px',threshold: 1.0 // Trigger when 100% of the element is visible};const observerCallback = (entries, observer) => {entries.forEach(entry => {if (entry.isIntersecting) {animateNumber();observer.unobserve(entry.target); // Stop observing once the animation starts}});};const observer = new IntersectionObserver(observerCallback, observerOptions);observer.observe(element);});</script></body></html>{/source}

Statistics: Posted by modernmagic — Sun Jul 28, 2024 4:31 pm



Viewing all articles
Browse latest Browse all 1466

Trending Articles