We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5091
    • 332 Posts
    after upgraded to MODx 0.9.6.2 about a week ago, google no longer picking up new documents from my site, so I upgraded to v1.0.8, call the snippet in my sitemap.xml just like before

    [!SiteMap? &format=`sp`!]

    But it’s showing me this:

    This page contains the following errors:

    error on line 1 at column 1: Document is empty
    Below is a rendering of the page up to the first error. (me: nothing below this line of text)
      • 5628
      • 44 Posts
      hey ho
      trying out this nice wee snippet but cannot seem to avoid getting the following error message:
      Fatal error: Cannot redeclare gettv() (previously declared in C:\Program Files\xampp\htdocs\modx_latest_171108\manager\includes\document.parser.class.inc.php(766) : eval()’d code:247) in C:\Program Files\xampp\htdocs\modx_latest_171108\manager\includes\document.parser.class.inc.php(766) : eval()’d code on line 270
      any ideas what is causing this tout le monde?
        • 20310
        • 3 Posts
        Hey here is my HTML unsorted list with page levels snippet based on the code of the sitemap snippet.

        If you think it is good, maybee you will add the functionality to the base snippet:

        <?php
        $startid = (isset($startid)) ? $startid : 0;
        
        $excludeTemplates = (isset($excludeTemplates)) ? $excludeTemplates : array();
        
        $docs = getDocsWithLevels($modx,$startid);
        
        #var_dump($docs);
        
        // get all templates
        $select = $modx->db->select("id, templatename", $modx->getFullTableName('site_templates'));
        while ($query = $modx->db->getRow($select)) {
        	$allTemplates[$query['id']] = $query['templatename'];
        }
        
        $remainingTemplates = $allTemplates;
        
        // get templates to exclude, and remove them from the all templates list
        if (!empty ($excludeTemplates)) {
        
        	$excludeTemplates = explode(",", $excludeTemplates);
        
        	// Loop through each template we want to exclude
        	foreach ($excludeTemplates as $template) {
        		$template = trim($template);
        
        		// If it's numeric, assume it's an ID, and remove directly from the $allTemplates array
        		if (is_numeric($template) && isset($remainingTemplates[$template])) {
        			unset($remainingTemplates[$template]);
        		} else if (trim($template) && in_array($template, $remainingTemplates)) { // If it's text, and not empty, assume it's a template name
        			unset($remainingTemplates[array_search($template, $remainingTemplates)]);
        		}
        	} // end foreach
        }
        
        $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[$startid] as $doc)
        {
        	if (isset($remainingTemplates[$doc['template']]) && $doc['template']!=0)
        	{
        		$output  .= "  <li class=\"sitemap\">";
        		$output .= "<a href=\"[(site_url)][~" . $doc['id'] . "~]\" class=\"sitemap\">" . $doc['pagetitle'] . "</a>";
        		$output .= "</li>\n";
        
        
        		$id = $doc['id'];
        		if(isset($docs[$id])) {
        			$output .= "<ul class=\"sitemap\">\n";
        			foreach($docs[$id] as $sub_doc) {
        				$output  .= "  <li class=\"sitemap\">";
        				$output .= "<a href=\"[(site_url)][~" . $sub_doc['id'] . "~]\" class=\"sitemap\">" . $sub_doc['pagetitle'] . "</a>";
        				$output .= "</li>\n";
        			}
        			$output .= "</ul>\n";
        		}
        	}
        
        } // end foreach
        $output .= "</ul>\n";
        
        return $output;
        
        function getDocsWithLevels($modx,$startid)
        {
        	// get children documents
        	$docs[$startid] = $modx->getActiveChildren($startid,'menuindex','asc','id,editedon,template,published,searchable,pagetitle,type');
        	// add sub-children to the list
        	foreach ($docs[$startid] as $doc)
        	{
        		$id = $doc['id'];
        
        		if ($modx->getActiveChildren($id))
        		$docs[$id] = $modx->getActiveChildren($id,'menuindex','asc','id,editedon,template,published,searchable,pagetitle,type');
        	} // end foreach
        	return $docs;
        }
        ?>
        


        It will output an unsorted list with the root documents. If there are Child Documents for the Root Document they will be displayed at the same place in a new <ul>

        greets moveax1
          • 29059
          • 88 Posts
          i’m not sure if my problem is specifically SiteMap related or not.
          please see my posting @ http://modxcms.com/forums/index.php/topic,32170.0.html

          it’s regarding "invalid dates" (1969) showing up for a lot of pages.

          thanx.jason.
            • 32873
            • 9 Posts
            Quote from: grad at Jan 24, 2007, 08:11 AM

            Quote from: ricardosanX at Jan 24, 2007, 05:42 AM

            Is there any way to get this Snippet to display pages that are nested within Unpublished folders. My blog pages are accessed via the Ditto Snippet, so are inside an Unpublished folder.

            Try this:

            <?php
            # @line 119
            if (!$doc[$excludeTV]) // remove
            if (!$doc[$excludeTV] && $doc['published'] && $doc['template']!=0) // add
            
            # @line 198
            $docs = $modx->getActiveChildren($startid,'menuindex','asc','id,editedon,template'); //remove
            $docs = $modx->getAllChildren($startid,'menuindex','asc','id,editedon,template,published'); // add
            
            # @line 206
            if ($modx->getActiveChildren($id)) // remove
            if ($modx->getAllChildren($id)) // add
            ?>


            The change includes also filtering out documents with no template inteded for weblinks.

            Is there a similar solution for SiteMap 1.0.8? Those lines have changed in the sourcecode, so I could not figure out how to include pages in unpublished folders to the sitemap.

            Or an even better solution for me would be if I could include ALL documents and only exclude those I don’t need using a TV..
              • 32645
              • 377 Posts
              This snippet creates a google "sitemap.xml", which I have got working, complete with the template variables.

              BUT....

              There is no title in the title bar when the Sitemap.xml is viewed.

              How do I set the title in the title bar using this snippet?

              Thanks
                • 28107
                • 230 Posts
                I’ve run in some curious results
                On my own site google claims that the sitemap does not contain any URL, other sites (same version 9.6.3 and sitemap 1.08) works fine.
                The other sites are on the same server, configured exactly as the first one.

                Google says : 500 (Internal ServerError) when trying to get that sitemap.

                I then saved the sitemap to a textfile and uploaded it and google says’ fine’.
                  CONIN Werbeagentur . Köln
                  http://www.conin.de
                  • 32645
                  • 377 Posts
                  I have a specific request.

                  I have a table called holiday offers. I want to output the 10 latest records (based on date) inside the Google Sitemap.

                  How do I add such a table using this snippet?
                    • 16085
                    • 203 Posts
                    Has anyone come across a solution for blank xml list?

                    I’ve got the v1.0.8 snippet running on two MODx 9.6.3 sites on the same server, except one site is not displaying the any urls in the xml output. All I get is below:
                    <?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">
                    </urlset>


                    I also just tried to down grade to 1.0.7 but I got a parse error:

                    PHP error debug
                    Error: Invalid argument supplied for foreach()
                    Error type/ Nr.: Warning - 2
                    File: ../manager/includes/document.parser.class.inc.php(769) : eval()’d code
                    Line: 211

                    huh
                      • 449
                      • 14 Posts
                      Is it just me, or does this snippet require that you use Friendly Urls to make it work?

                      Or am I doing something wrong?