1. "Fabrik 4" helpers needed!

    You are invited to join other community members active in coding, maintaining and improving Fabrik. Please visit https://fabrik.help for more information!
    Dismiss Notice

Fabrik and JSitemap

Discussion in 'Community' started by sohopros, Jun 17, 2017.

  1. sohopros

    sohopros Member

    Level: Community
  2. marozen

    marozen Member

    Level: Community
    A way to make a sitemap of all your records in a table is by using this file.php:

    $mysqli = new mysqli("localhost", "root", "", "testdb");
    $result=$mysqli->query("SELECT * FROM yourtable");

    $xml=new DOMDocument("1.0");
    $xml->formatOutput=true;
    $urlset=$xml->createElement('urlset');
    $urlset->setAttribute('xmlns', "http://www.google.com/schemas/sitemap/0.84");
    $urlset->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance");
    $urlset->setAttribute('xsi:schemaLocation', "http://www.google.com/schemas/sitemap/0.84/sitemap.xsd");

    $xml->appendChild($urlset);

    while($row=mysqli_fetch_array($result)){
    $url=$xml->createElement("url");
    $urlset->appendChild($url);

    $loc=$xml->createElement("loc", "https://yoursite.com/index.php/yourtable/details/99/".$row['id']);
    $url->appendChild($loc);

    $lastmod=$xml->createElement("lastmod",$row['date_time']);
    $url->appendChild($lastmod);

    $changefreq=$xml->createElement("changefreq",'weekly');
    $url->appendChild($changefreq);

    $priority=$xml->createElement("priority",'0.8');
    $url->appendChild($priority);
    }

    echo "<xmp>".$xml->saveXML()."</xmp>";

    $xml->save("reports.xml");
     
  3. dimoss

    dimoss Well-Known Member

    Level: Community
    Hi,

    i bring this up again and I wonder if there is someone who used it and had success.
    Thanks.
     

Share This Page