Next Chapter: Moving from Test or Development to Production

Creating a mobile sitemap with CakePHP

2019-05-13 16:28:56.872974+00

In addition to our desktop sitemap we will create a mobile sitemap.

In the existing model file /usr/local/www/ we add this function

We would like to call the functionality for sitemap creation from the command line. Therefore we need in CakePHP a Shell. Shells are in the subdirectory .../Console/Command/ and must end with "Shell.php".

vi /usr/local/www/

Add the function call in LShell.php as follow

        $this->out(print_r($sm, true));

        $sm = $this->Sitemap->createSitemapMobile(); 
        $this->out(print_r($sm, true));

Use this command to run the shell:

/usr/local/bin/php -f /usr/local/www/ \
l createsitemap -app /usr/local/www/

the shell gives this output:

<pre> Welcome to CakePHP v2.6.2 Console --------------------------------------------------------------- App : app Path: /usr/local/www/ --------------------------------------------------------------- </pre>

Lets check the mobilesitemap.xml file:

cat /usr/local/www/ 
<pre> <?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="" xmlns:xhtml=""> <url> <loc> Application Development with Open Source Software</loc> <changefreq>monthly</changefreq> <priority>1.0</priority> </url> </urlset> </pre>

To finish we need to talk to the search robots. We tell them the name of the sitemap file

vi /usr/local/www/

#ganze Website freigeben
User-agent: *
Disallow: /admin/

# url to the sitemap file:

Lastly we need to check if our sitemap is a valid xml file. Therefore we will use free online services such as

Tag: cakephp2

Previous Chapter: Creating a new mobile View for Books

Next Chapter: Moving from Test or Development to Production