Page 1 of 1

Sitemap

Posted: Sat Mar 07, 2009 1:14 am
by Jacob
Why can't I find the sitemap to edit? >:( I am running V.0.7.9

Cheers

Re: Sitemap

Posted: Sat Mar 07, 2009 4:38 am
by Qphoria
First: You'll get better support for 0.7.9 in the new OpenCart Zero forums (i wish daniel would lock this board)

Second: Sitemap is autogenerated. But you can change the code in catalog/controller/sitemap.php or the template in catalog/template/default/content/sitemap.tpl

Re: Sitemap

Posted: Sun Mar 08, 2009 10:47 pm
by Jacob
Thanks Q

Apparently I have a space at the top of the page which is causing an Xml error. I have found both files you mention but don't see how to fix fix the error.

http://www.capoeiracanal.co.uk/capoeira ... =g_sitemap

Re: Sitemap

Posted: Sun Mar 08, 2009 11:02 pm
by Qphoria
That's g_sitemap.... from the Google SEO Complete pack that david gilbert released. Not sure what is causing that one. Perhaps he can help if you PM him.

Re: Sitemap

Posted: Mon Mar 09, 2009 9:59 am
by nde
The XML declaration MUST be in the first line of an document. Maybe that breaks the page (as things are more strict there).
With the DOCTYPE it's not that strict, most browsers just ignore the declaration if it's not on the first line (which is most likely unwanted too since it triggers Quirks mode).

XHTML is a bit of overkill anyay, why not use HTML 4.01? It's an interesting subject. Valid XHTML 1.0 code is actually invalid HTML 4.01 - the MIME-type decides how a document gets served. If it's sent as text/html, it gets treated as HTML (probably 99% of websites). IE 6.0 doesn't even know application/xhtml+xml.

I always use the following for new documents, that's enough:

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

Re: Sitemap

Posted: Mon Mar 09, 2009 6:54 pm
by Jacob

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
That's what I use when creating a doc, but the cart was created by OpenCart and my basic understanding of Php etc means I have no idea how to correct the error.

Here is my g_sitemap, can anyone advise on how to fix the error.

Code: Select all

<?php 
class ControllerGSitemap extends Controller { 
 function index() {
  $module   =& $this->locator->get('module');
  $response =& $this->locator->get('response');
  $template =& $this->locator->get('template');
  $url      =& $this->locator->get('url');
  $config   =& $this->locator->get('config');
  $database =& $this->locator->get('database');
  $language =& $this->locator->get('language');
  $image    =& $this->locator->get('image'); 
  
         //Google Sitemaps addon for karzina!
        
            // Base URL
            if (@$_SERVER['HTTPS'] != 'on') {
            $catalog_url = HTTP_SERVER;
            $image_url = HTTP_IMAGE;
            } else {
            $catalog_url = HTTPS_SERVER;
            $image_url = HTTPS_IMAGE;
            }
          
          //Output XML
          header('Content-type: text/xml');
          echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
          echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
          
          //Add the Home Page
          echo '<url>' . "\n";
          echo '<loc>' . $catalog_url . '</loc>' . "\n";
          echo '<changefreq>weekly</changefreq>' . "\n";
          echo '<priority>1.0</priority>' . "\n";
          echo '</url>' . "\n";
          
          if ($config->get('config_url_alias'))  {
          //Get all URL's in the site!
          $sql = "select `alias` from `url_alias`";
          $results = $database->getRows($sql);
          
          foreach($results as $result) {
          
          $page = $result['alias'];
          
          //Static Page - Store Home
          echo '<url>' . "\n";
          echo '<loc>' . $catalog_url . $page . '</loc>' . "\n";
          echo '<changefreq>weekly</changefreq>' . "\n";
          echo '<priority>0.9</priority>' . "\n";
          echo '</url>' . "\n";
            
          } 
          }
          else  {
          //Get all URL's in the site!
          $sql = "select `query` from `url_alias`";
          $results = $database->getRows($sql);
          
          foreach($results as $result) {
          
          $page = $result['query'];
          
          //Static Page - Store Home
          echo '<url>' . "\n";
          echo '<loc>' . $catalog_url . 'index.php?' . $page . '</loc>' . "\n";
          echo '<changefreq>weekly</changefreq>' . "\n";
          echo '<priority>0.8</priority>' . "\n";
          echo '</url>' . "\n";
          }
          }
          
          echo '</urlset>';
        }   
    }
?>
Will PM david gilbert

Thanks!

Re: Sitemap

Posted: Mon Mar 09, 2009 8:46 pm
by Jacob
Can not find a member with the name David Gilbert?

Edit - found him

Re: Sitemap

Posted: Tue Mar 10, 2009 8:33 am
by nde
Oh I didn't read that you already noticed the empty first line. The code of the plugin shouldn't produce whitespace.
Your generated XML works if the first empty line is removed, I just tested and it's well-formed...