We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28033
    • 925 Posts
    Quote from: tkfm at May 29, 2008, 08:35 PM

    Quote from: Soshite at May 25, 2008, 03:47 PM

    Also might be the reason why http://symphonicheaven.com/sitemap.xml is failing.
    Try using uncached form [!...!].

    Seems there was a mispelling w/ the snippet call. It works fine now. smiley
      My Snippets
      -> PopUpChunk v1.0
      • 28033
      • 925 Posts
      As a suggestion, for a future version, maybe extend the ulli type so it makes a proper hierarchy, i.e., where it "pushes" out sections like in Wayfinder.

      I would use Wayfinder, but it (currently) cannot search inside unpublished folders like this script can. wink
        My Snippets
        -> PopUpChunk v1.0
        • 3177
        • 137 Posts
        I would rather state that including unpublished folders is undesired behaviour and should be switched off, or at least there should be a param to switch it off. Having said this, it involves programming work to be done. I have to be honest to say that I am using Wayfinder in one of my projects now. Maybe it’s better to include a param in Wayfinder to include unpublished folders (this is probably nothing more than changing a SQL query). Programming the hierarchy in this snippet involved more work.
          • 21056
          • 327 Posts
          Quote from: bertcatsburg at May 31, 2008, 09:23 AM

          I would rather state that including unpublished folders is undesired behaviour and should be switched off, or at least there should be a param to switch it off. Having said this, it involves programming work to be done. I have to be honest to say that I am using Wayfinder in one of my projects now. Maybe it’s better to include a param in Wayfinder to include unpublished folders (this is probably nothing more than changing a SQL query). Programming the hierarchy in this snippet involved more work.
          Agreed. Also this snippet included deleted documents - clearly not intended!
            Author: ManagerManager plugin - customise your ModX manager interface

            Rckt - web development, Sheffield, UK
            • 5399
            • 17 Posts
            Hi,

            I have created a sitemap for a site which seems to work and lists all the pages fine in the browser.

            <?xml version="1.0" encoding="UTF-8" ?>
            - <urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
            - <url>
            <loc>http://www.domain.co.uk/contactus.html</loc>
            <lastmod>2008-03-18</lastmod>
            </url>
            - <url>
            <loc>http://www.domain.co.uk/casestudies.html</loc>
            <lastmod>2008-03-18</lastmod>
            </url>
            - <url>
            <loc>http://www.domain.co.uk/instock.html</loc>
            <lastmod>2008-04-28</lastmod>
            </url>
            - <url>
            <loc>http://www.domain.co.uk/aboutus.html</loc>
            <lastmod>2008-02-29</lastmod>
            </url>
            - <url>
            <loc>http://www.domain.co.uk/index.html</loc>
            <lastmod>2008-04-25</lastmod>
            </url>
            </urlset>

            I have submitted to Google in Webmaster tools but I get the following error.

            Sitemap errors and warnings
            Line Status Details
            Details - Network unreachable: Network unreachable
            We encountered an error while trying to access your Sitemap. Please ensure your Sitemap follows our guidelines and can be accessed at the location you provided and then resubmit. HTTP Error:
            Found: 500 (Internal server error) Help

            Jun 6, 2008

            http://www.google.com/support/webmasters/bin/answer.py?answer=83040&hl=en

            Has anyone any suggestions of what might be wrong and how I can fix?
              • 3177
              • 137 Posts
              Sitemap errors and warnings
              Line Status Details
              Details - Network unreachable: Network unreachable
              We encountered an error while trying to access your Sitemap.
              Without looking at the sitemap itself but only looking at the message above. Might it be that there is a standard network error at the moment of submitting the sitemap? The string "We encountered an error" is nothing more that "Hey, somethings wrong, and what it is is mentioned above" (which is the Network Error).
                • 36592
                • 970 Posts

                Details - Network unreachable: Network unreachable
                We encountered an error while trying to access your Sitemap. Please ensure your Sitemap follows our guidelines and can be accessed at the location you provided and then resubmit. HTTP Error:
                Found: 500 (Internal server error) Help
                I am not sure but stopping Search Highlighting Plugin might work...
                  • 28033
                  • 925 Posts
                  <?php
                  /*
                  ==================================================
                  	sitemap
                  ==================================================
                  
                  Outputs a machine readable site map for search
                  engines and robots. Supports the following
                  formats:
                  
                  - Sitemap Protocol used by Google Sitemaps
                    (http://www.google.com/webmasters/sitemaps/)
                  
                  - URL list in text format
                    (e.g. Yahoo! submission)
                  
                  Author: Grzegorz Adamiak [grad]
                  Version: 1.0.6 @ 29-feb-2008
                  License: LGPL
                  MODx: 0.9.2.1, 0.9.6.1
                  
                  History:
                  # 1.0.6
                  - Add optional parameter (excludeWeblinks) to exclude weblinks from the sitemap, since they often point to external
                    sites (which don't belong on your sitemap), or redirecting to other internal pages (which are already
                    in the sitemap). Google Webmaster Tools generates warnings for excessive redirects.	
                    Default is false - e.g. default behaviour remains unchanged.
                  # 1.0.5
                  - Modification about non searchable documents, as suggested by forum user JayBee
                    (http://modxcms.com/forums/index.php/topic,5754.msg99895.html#msg99895)
                  # 1.0.4 (By Bert Catsburg, [email protected])
                  - Added display option 'ulli'. 
                    An <ul><li> list of all published documents.
                  # 1.0.3
                  - NC added ability to specify the XSL URL - you don't always need one and it 
                    seems to create a lot of support confusion!
                    It is now a parameter (&xsl=``) which can take either an alias or a doc ID
                  - Modifications suggested by forum users Grad and Picachu incorporated
                    (http://modxcms.com/forums/index.php/topic,5754.60.html)
                  # 1.0.2
                  - Reworked fetching of template variable value to
                    get INHERITED value.
                  # 1.0.1
                  - Reworked fetching of template variable value,
                    now it gets computed value instead of nominal;
                    however, still not the inherited value.
                  # 1.0
                  - First public release.
                  
                  TODO:
                  - provide output for ROR
                  --------------------------------------------------
                  */
                  
                  /* Parameters
                  ----------------------------------------------- */
                  
                  # $startid [ int ]
                  # Id of the 'root' document from which the sitemap
                  # starts.
                  # Default: 0
                  
                  $startid = (isset($startid)) ? $startid : 0;
                  
                  # $format [ sp | txt | ror ]
                  # Which format of sitemap to use:
                  # - sp <- Sitemap Protocol used by Google
                  # - txt <- text file with list of URLs
                  # TODO - ror <- Resource Of Resources
                  # Default: sp
                  
                  $format = (isset($format) && ($format != 'ror')) ? $format : 'sp';
                  
                  # $priority [ str ]
                  # Name of TV which sets the relative priority of
                  # the document. If there is no such TV, this
                  # parameter will not be used.
                  # Default: sitemap_priority
                  
                  $priority = (isset($priority)) ? $priority : 'sitemap_priority';
                  
                  # $changefreq [ str ]
                  # Name of TV which sets the change frequency. If
                  # there is no such TV this parameter will not be
                  # used.
                  # Default: sitemap_changefreq
                  
                  $changefreq = (isset($changefreq)) ? $changefreq : 'sitemap_changefreq';
                  
                  # $excludeTemplates [ str ]
                  # Documents based on which templates should not be
                  # included in the sitemap. Comma separated list
                  # with names of templates.
                  # Default: empty
                  
                  $excludeTemplates = (isset($excludeTemplates)) ? $excludeTemplates : array();
                  
                  # $excludeTV [ str ]
                  # Name of TV (boolean type) which sets document
                  # exclusion form sitemap. If there is no such TV
                  # this parameter will not be used.
                  # Default: 'sitemap_exclude'
                  
                  $excludeTV = (isset($excludeTV)) ? $excludeTV : 'sitemap_exclude';
                  
                  # $xsl [ str ] 
                  # URL to the XSL style sheet
                  # or
                  # $xsl [ int ]
                  # doc ID of the XSL style sheet
                  
                  $xsl = (isset($xsl)) ? $xsl : '';
                  if (is_numeric($xsl)) { $xsl = $modx->makeUrl($xsl); }
                  
                  
                  # $excludeWeblinks [ bool ]
                  # Should weblinks be excluded?
                  # You may not want to include links to external sites in your sitemap,
                  # and Google gives warnings about multiple redirects to pages 
                  # within your site.
                  # Default: false
                  $excludeWeblinks = (isset($excludeWeblinks)) ? $excludeWeblinks : false;
                  
                  
                  /* End parameters
                  ----------------------------------------------- */
                  
                  # get list of documents
                  # ---------------------------------------------
                  $docs = getDocs($modx,$startid,$priority,$changefreq,$excludeTV);
                  
                  # filter out documents by template or TV
                  # ---------------------------------------------
                  // get all templates
                  $select = $modx->db->select("id, templatename", $modx->getFullTableName('site_templates'));
                  while ($query = $modx->db->getRow($select))
                  {
                  	$allTemplates[$query['id']] = $query['templatename'];
                  }
                  
                  // get templates to exclude
                  if (!empty ($excludeTemplates))
                  {
                  	$excludeTemplates = explode(",", $excludeTemplates);
                  	// trim template names and remove empty ones (just in case)
                  	foreach ($excludeTemplates as $template)
                  	{
                  		if (trim($template))
                  			$excludeTemplates[] = trim($template);
                  	} // end foreach
                  }
                  
                  // filter out documents
                  foreach ($docs as $doc)
                  {
                  	if (!in_array($doc['template'], array_flip(array_intersect($allTemplates, $excludeTemplates)))) {
                  		if (!$doc[$excludeTV] && $doc['published'] && $doc['template']!=0 && $doc['searchable']) {
                  			if (!$excludeWeblinks || ($excludeWeblinks && $doc['type'] != 'reference')) {
                  				$output[] = $doc;		
                  			}
                  		}
                  	}
                  }
                  $docs = $output;
                  unset ($output, $allTemplates, $excludeTemplates);
                  
                  # build sitemap in specified format
                  # ---------------------------------------------
                  
                  switch ($format)
                  {
                  	// Next case added in version 1.0.4
                  	case 'ulli': // UL List
                  		$output .= "<ul class=\"sitemap\">\n";
                  		// TODO: Sort the array on Menu Index
                  		// TODO: Make a nested ul-li based on the levels in the document tree.
                  		foreach ($docs as $doc)
                  		{
                  			$s  = "  <li class=\"sitemap\">";
                  			$s .= "<a href=\"[(site_url)][~" . $doc['id'] . "~]\" class=\"sitemap\">" . $doc['pagetitle'] . "</a>";
                  			$s .= "</li>\n";
                  			$output .= $s;
                  		} // end foreach
                  		$output .= "</ul>\n";
                  		break;
                  		
                  	case 'txt': // plain text list of URLs
                  
                  		foreach ($docs as $doc)
                  		{
                  			$url = '[(site_url)][~'.$doc['id'].'~]';
                  
                  			$output .= $url."\n";
                  		} // end foreach
                  		break;
                  
                  	case 'ror': // TODO
                  	default: // Sitemap Protocol
                  
                  	$output = '<?xml version="1.0" encoding="UTF-8"?>'."\n";
                  	if ($xsl != '') {
                  		$output .='<?xml-stylesheet type="text/xsl" href="'.$xsl.'"?>'."\n";
                  	}
                  	$output .='<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'."\n";
                  	
                  	
                  	foreach ($docs as $doc)	{
                  		$url = '[(site_url)][~'.$doc['id'].'~]';
                  		$date = $doc['editedon'];
                  		$date = date("Y-m-d", $date);
                  		$docPriority = ($doc[$priority]) ? $doc[$priority] : 0; // false if TV doesn't exist
                  		$docChangefreq = ($doc[$changefreq]) ? $doc[$changefreq] : 0; // false if TV doesn't exist
                  
                  		$output .= "\t".'<url>'."\n";
                  		$output .= "\t\t".'<loc>'.$url.'</loc>'."\n";
                  		$output .= "\t\t".'<lastmod>'.$date.'</lastmod>'."\n";
                  		$output .= ($docPriority) ? ("\t\t".'<priority>'.$docPriority.'</priority>'."\n") : ''; // don't output anything if TV doesn't exist
                  		$output .= ($docChangefreq) ? ("\t\t".'<changefreq>'.$docChangefreq.'</changefreq>'."\n") : ''; // don't output anything if TV doesn't exist
                  		$output .= "\t".'</url>'."\n";
                  	} // end foreach
                  	$output .= '</urlset>';
                  
                  } // end switch
                  
                  return $output;
                  
                  # functions
                  # ---------------------------------------------
                  
                  # gets (inherited) value of template variable
                  function getTV($modx,$docid,$doctv)
                  {
                  /* apparently in 0.9.2.1 the getTemplateVarOutput function doesn't work as expected and doesn't return INHERITED value; this is probably to be fixed for next release; see http://modxcms.com/bugs/task/464
                  	$output = $modx->getTemplateVarOutput($tv,$docid);
                  	return $output[$tv];
                  */
                  	
                  	while ($pid = $modx->getDocument($docid,'parent'))
                  	{
                  		$tv = $modx->getTemplateVar($doctv,'*',$docid);
                  		if (($tv['value'] && substr($tv['value'],0,8) != '@INHERIT') or !$tv['value']) // tv default value is overriden (including empty)
                  		{
                  			$output = $tv['value'];
                  			break;
                  		}
                  		else // there is no parent with default value overriden 
                  		{
                  			$output = trim(substr($tv['value'],8));
                  		}
                  		$docid = $pid['parent']; // move up one document in document tree
                  	} // end while
                  	
                  	return $output;
                  }
                  
                  # gets list of published documents with properties
                  function getDocs($modx,$startid,$priority,$changefreq,$excludeTV)
                  {
                  	// get children documents
                  	$docs = $modx->getAllChildren($startid,'menuindex','asc','id,editedon,template,published,searchable,pagetitle,type'); 
                  	// add sub-children to the list
                  	foreach ($docs as $key => $doc)
                  	{
                  		$id = $doc['id'];
                  		$docs[$key][$priority] = getTV($modx,$id,$priority); // add priority property
                  		$docs[$key][$changefreq] = getTV($modx,$id,$changefreq); // add changefreq property
                  		$docs[$key][$excludeTV] = getTV($modx,$id,$excludeTV); // add excludeTV property
                  		
                  		if ($modx->getActiveChildren($id))
                  			$docs = array_merge($docs, getDocs($modx,$id,$priority,$changefreq,$excludeTV));
                  	} // end foreach
                  	return $docs;
                  }
                  ?>


                  http://symphonicheaven.com/sitemap.xml

                  Anyone know why it’s putting a whitespace in the first line? Google’s giving a warning because of that...
                    My Snippets
                    -> PopUpChunk v1.0
                    • 36592
                    • 970 Posts
                    Is the template of this document really ’blank’ ?

                    And what is the content of this document ?
                    Is the snippet call placed at the top of the content field ?
                      • 28033
                      • 925 Posts
                      Quote from: tkfm at Jun 10, 2008, 10:30 PM

                      Is the template of this document really ’blank’ ?

                      And what is the content of this document ?
                      Is the snippet call placed at the top of the content field ?

                      IIRC, it’s set to blank and the only thing in the field is the snippet call.
                        My Snippets
                        -> PopUpChunk v1.0