Search…

X3 Photo Gallery Support Forums

Search…
 
pbhq
Topic Author
Posts: 18
Joined: 21 Jan 2019, 11:07

Include external content

25 Jan 2019, 13:51

Hello,

I have long plans to provide a smartphone friendly version in addition to the image gallery of my website. It was important for me that the new software does not change the pictures and that the original file names are preserved. Photo Gallery does the job very well.

But I have a few more questions:

I would also like to include external content, but since Photo Gallery is an AJAX application, the previous way via SSI (Server Side Includes) is no longer applicable.

What is the best way to integrate the additional HTML/INC files via JavaScript?

PS: And no, IFRAME is not the way to the solution  :thinking:.

Best wishes, Thomas
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13993
Joined: 30 Sep 2006, 03:37

Re: Include external content

26 Jan 2019, 04:10

pbhq wrote:I would also like to include external content, but since Photo Gallery is an AJAX application, the previous way via SSI (Server Side Includes) is no longer applicable.
Can you be a bit more clear about what you mean "external content"? As of right now, you can of course type anything (including advanced HTML) into an X3 page's content editors. Furthermore, you can embed images and videos, also from remote sources if you want. The point of the panel/CMS is to include your content/HTML directly there.

Seems you want to include custom html fragments without adding them directly to the page content? I'm trying to figure out exactly what you are trying to achieve that you cannot do by simply adding your custom html into the page content.
pbhq wrote:What is the best way to integrate the additional HTML/INC files via JavaScript?
It is possible to make an AJAX javascript call to load and inject data (html/txt) into X3. Perhaps not the most practical solution.
 
pbhq
Topic Author
Posts: 18
Joined: 21 Jan 2019, 11:07

Re: Include external content

26 Jan 2019, 06:58

mjau-mjau wrote: Seems you want to include custom html fragments without adding them directly to the page content? I'm trying to figure out exactly what you are trying to achieve that you cannot do by simply adding your custom html into the page content.
I would like to save the work of integrating many identical content individually into each website or page. Currently I do this for such topics as GDPR, licenses, imprint, copyright, etc. simply via SSI. So I have to keep only a few files up to date.

In Photo Gallery is the way over SSI (because of AJAX) not a good way in my opinion. I also tried it and found problems with the cache. ;-)
mjau-mjau wrote:
pbhq wrote:What is the best way to integrate the additional HTML/INC files via JavaScript?
It is possible to make an AJAX javascript call to load and inject data (html/txt) into X3. Perhaps not the most practical solution.
I'm well aware that my idea does not quite match the concept of Photo Gallery. The solution to integrate all content via an external link in the menu, that's  isn't either.

If I could solve this elegantly via JavaScript, then that would be quite good. I also have full access to the HTML/INC/CGI-sources and the webserver. There must be a solution. ;-)

PS: I am actually more interessted to add some pages / information around the actual Photogallery, but not for the Gallery himselfs.
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13993
Joined: 30 Sep 2006, 03:37

Re: Include external content

27 Jan 2019, 00:55

As I believe you have noted, "server side includes" is not really something we are able to support in X3. SSI would be available when creating your own templates for a CMS, and although we consider X3 a "CMS", the X3 website itself is already a pre-created template with it's own advanced core.

Javascript
It should not be too complicated to add your own dynamic JS include using AJAX. Here is the basic idea:

1. Add an empty container anywhere on a page where you want to include a specific template:
Code
<div data-template="template_name"></div>
2. In Settings > Custom > Custom Javascript:
Code
function x3_load_page(){
  var elements = $('[data-template]');
  if(!elements.length) return;
  elements.each(function(el) {
    var template = el.getAttribute('data-template');
    if(!template) return;
    $.get('/mytemplates/' + template + '.html', function(data) {
      if(data) el.innerHTML = data;
    });
  });
}
 
pbhq
Topic Author
Posts: 18
Joined: 21 Jan 2019, 11:07

Re: Include external content

27 Jan 2019, 09:08

mjau-mjau wrote:As I believe you have noted, "server side includes" is not really something we are able to support in X3.
SSI is also actively suppressed in the sources of PhotoGallery.  ;-)
mjau-mjau wrote:JavascriptIt should not be too complicated to add your own dynamic JS include using AJAX. Here is the basic idea:
In the meantime, I have also found a solution, I do not think it's particularly elegant now.
Code
/* ssi-wrapper.js */
function SSI_LoadContent(filename)
{
    xmlHttpObject.open('get',filename);
    xmlHttpObject.onreadystatechange = SSI_HandleContent;
    xmlHttpObject.send(null);
    return false;
}

function SSI_HandleContent()
{
    if (xmlHttpObject.readyState == 4)
    {
        document.getElementById('SSI_Wrapper').innerHTML = xmlHttpObject.responseText;
    }
}

var xmlHttpObject = false;

if (typeof XMLHttpRequest != 'undefined')
{
    xmlHttpObject = new XMLHttpRequest();
}
if (!xmlHttpObject)
{
    try
    {
        xmlHttpObject = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
        try
        {
            xmlHttpObject = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(e)
        {
            xmlHttpObject = null;
        }
    }
}
In any case, I can include the include files (including cascaded SSI) and even the CGI tools work without problems.

However, I find your solution much more elegant. ;-)

Thank you for your effort!


Best wishes,

Thomas
 
pbhq
Topic Author
Posts: 18
Joined: 21 Jan 2019, 11:07

Re: Include external content

28 Jan 2019, 14:25

mjau-mjau wrote:Javascript
It should not be too complicated to add your own dynamic JS include using AJAX. Here is the basic idea:
I can not get your example code to work, why ever ...
Otherwise, I'm making good progress with the tinkering. After all, it is almost 10,000 pictures. ;-)
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13993
Joined: 30 Sep 2006, 03:37

Re: Include external content

28 Jan 2019, 23:43

pbhq wrote:I can not get your example code to work, why ever ...
Otherwise, I'm making good progress with the tinkering. After all, it is almost 10,000 pictures. ;-)
Do you have a link for me so I can diagnose?