1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

How to create an XML document of fabrik detail-view template?

Discussion in 'Community' started by marozen, Sep 7, 2019.

?

Are there easier ways to safe the page loadings in HTML or XML and to load them quicker?

  1. Maybe the entire page can be as an RSS-feed?

    0 vote(s)
    0.0%
  2. Maybe PDF file is loaded also faster?

    0 vote(s)
    0.0%
  3. Maybe continue to create a custom XML file with XSL styling?

    0 vote(s)
    0.0%
Multiple votes are allowed.
  1. marozen

    marozen Member

    Level: Community
    Loading a webpage can take a lot of time if values are loaded with php from, a large database table. I want to add php code that transforms the loaded page into a XML file. And then with XSL files you can make the page look like a HTML page. And loading it will be much faster and the file can also be loaded at other websites like an RSS-feed.

    The code in the default.php template is as followed:

    $xml = new DOMDocument("1.0","UTF-8");
    $xml->substituteEntities = true;

    $stylesheet = new DOMDocument;
    $stylesheet->substituteEntities = true;
    if ($stylesheet->load("https://rozendale.com/th/rad/plants.xsl") == false)
    die('Failed to load XSLT file');

    $xml->formatOutput=true;
    $root=$xml->createElement('root');
    $root->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance");
    $root->setAttribute('xsi:noNamespaceSchemaLocation', "https://rozendale.com/th/rad/plants.xsd");

    $xml->appendChild($root);

    $title=$xml->createElement("title", $title);
    $root->appendChild($title);

    $body=$xml->createElement("body", $body);
    $root->appendChild($body);

    echo "<xmp>".$xml->saveXML()."</xmp>";
    $xml->save("https://rozendale.com/th/rad/p$id.xml") or die("Error,Unable to create XML");

    The result is an XML file with $body as an element with the entire html output of the template.

    Are there easier ways to safe the page loadings in HTML or XML and to load them quicker?
     
  2. marozen

    marozen Member

    Level: Community
    I found another way: To save the output as html-document. And the result is that it loads much faster:

    ob_start();
    echo $template_content;
    file_put_contents("/website/id$id.html", ob_get_contents());
     

Share This Page