Creating Google Sitemap

From Aikiframework wiki

Jump to: navigation, search

Google Sitemap

example from OCAL

(noloop(<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
)noloop)  <url>
    <loc>http://www.openclipart.org/detail/((id))/<php str_replace(.svg,,((filename))); php></loc>
    <image:image>
        <image:loc>[root]/((full_path))((filename))</image:loc>
        <image:title><php str_replace(&,and,((upload_name))) php></image:title>
        <image:license>http://creativecommons.org/publicdomain/zero/1.0/</image:license>
    </image:image>
  </url>(noloop_bottom(</urlset>[no_pagination])noloop_bottom)

([no_pagination] - in noloop_bottom is used to disable html for pagination)

with SQL:

SELECT * FROM ocal_files WHERE filename LIKE '%.svg' ORDER BY upload_date

with pagination enabled and url ?page=[page]

and no result error

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:image="http://www.sitemaps.org/schemas/sitemap-image/1.1">
</urlset>

Google Sitemap Index

If you have to many urls to put in one sitemap you can create sitemap index file since Aiki don't have for loops I use a hack

SQL that calculate the number of pages

SELECT ceil(count(*)/1000) AS c FROM ocal_files WHERE filename rlike '.svg'

and inline sql `for' replacement

<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
(sql(
(
SELECT i FROM counter LIMIT ((c))||    <sitemap>
      <loc>http://www.openclipart.org/sitemap.txt?page=[-[i]-]</loc>
   </sitemap>)
)sql)
</sitemapindex>

before this to work you need to create table counter with numbers from 1 to 50

Personal tools