I have set up a minimal test file to see how a file can be included in the main file. The included file (test_include_file.html) only contains <p>Hello world!</p>
with a carriage return at the end (see code below).
Pinegrow’s WYSIWYG display doesn’t show “Hello world!”; it only shows the paragraph “Some content”. However, if I “\Page\Preview in browser” then both lines are shown –
Is there a way to show the included file’s content in Pinegrow’s WYSIWYG display? (I’d like to do this because I have a main file with a 1000-line list where that list could be handled more easily outside of the main file – i.e., in a separate included file.)
Pinegrow 6.4, Windows 10
Thanks,
Don C.
==========================================================================
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>blah</title>
<script>
/* 28/Feb/2022 - from https://www.w3schools.com/howto/howto_html_include.asp */
function includeHTML() {
var z, i, elmnt, file, xhttp;
/* Loop through a collection of all HTML elements: */
z = document.getElementsByTagName("*");
for (i = 0; i < z.length; i++) {
elmnt = z[i];
/*search for elements with a certain atrribute:*/
file = elmnt.getAttribute("w3-include-html");
if (file) {
/* Make an HTTP request using the attribute value as the file name: */
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4) {
if (this.status == 200) {elmnt.innerHTML = this.responseText;}
if (this.status == 404) {elmnt.innerHTML = "Page not found.";}
/* Remove the attribute, and call this function once more: */
elmnt.removeAttribute("w3-include-html");
includeHTML();
}
}
xhttp.open("GET", file, true);
xhttp.send();
/* Exit the function: */
return;
}
}
}
</script>
</head>
<body>
<p>Some content</p>
<div w3-include-html="/test_include_file.html"></div> <!-- <p>Hello world!</p> -->
<!-- 28/Feb/2022 - see https://www.w3schools.com/howto/howto_html_include.asp -->
<script> <!-- 28/Feb/2022 - from https://www.w3schools.com/howto/howto_html_include.asp -->
includeHTML();
</script>
</body>
</html>