We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3177
    • 137 Posts
    Quote from: Addgod at May 21, 2009, 05:59 PM

    Is it just me, or does this snippet require that you use Friendly Urls to make it work?

    Or am I doing something wrong?

    It doesn’t look like it. Take a look at line 224 of the snippet. There it’s showing that the siteurl is taken.

    Haven’t tested this though.
      • 449
      • 14 Posts
      Ok let me rephrase that.

      To be able to make a sitemap.xml friendly urls needs to be enabled. Am I correct in that assumption?
        • 3177
        • 137 Posts
        Let me also rephrase my answer then wink
        "No, I don’t think so, but I haven’t tested it".

        The code shows that the "siteurl" is taken. And the siteurl function gives you the url of the page: Either the friendly url (if enabled) or the standard url (if friendly urls are not enabled).

        But did you get an sitemap if FriendlyURLs are turned off? And what do you get when it’s turned on?

        In my installations I get a sitemap with Friendly URLs. (Must admit that I always use Friendly URLs)
          • 449
          • 14 Posts
          Well I was setting up a new website, and I just had not gotten around to doing the .htaccess file and enabling friendly urls, when I noticed that the sitemap.xml did not seem to work. And after I had enabled friendly urls it worked fine. Or I might say it was accessible. Witch makes good sense, since there is no file in the file structure called sitemap.xml.
            • 11588
            • 6 Posts
            I’ve got an issue with the generated sitemap on an IIS server:

            I’m trying to create a Google sitemap, but for whatever reason I’m getting two tab characters at the beginning of the XML document, meaning it’s not a valid format.
            I’ve already followed the advice given previously to create a new "empty" template and use that for the sitemap page, but it doesn’t work.

            The snippet code I am using is as follows:

            [!SiteMap? &format=`sp` &excludeTemplates=`blank, empty, hidden`!]


            searchable = off
            cacheable = off
            rich text = off
            content type = text/xml
            content disposition = inline.
              • 28801
              • 4 Posts
              I think something isn’t right. I get this message when I go to the preview tab:

              The XML page cannot be displayed 
              Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later. 
              
              
              --------------------------------------------------------------------------------
              
              A semi colon character was expected. Error processing resource 'http://www.example.com/index.php?id=1031&z=manprev'....
              
              [[SiteMap? &format=`sp`]]
              ------------------^
              


              I followed the instructions in the wiki and only entered:

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


              June 25, 2009 update
              Never mind the above, somehow I figured it out.
                Suds was the name of a cat.
                • 36527
                • 120 Posts
                Completely stumped...

                This has happend twice now to me - and I wonder if anyone has any ideas... but on 50 odd other sites..no problem ever with this snippet.

                1. Create site in a subfolder on a domain while developing

                2. Make the site live - install snippet (like I have done so many times before)

                3. In the XML file (format sp) it only prints out the index page (furls on)

                4. Ok so time to work out why... tried using doc manager and updating all editedon to todays date... no joy - just renders the homepage doc and not all other 20 odd pages...

                So confused...HELP!
                  • 23041
                  • 16 Posts
                  Hi,

                  I’ve made a rewrite to the SiteMap snippet that I think you should integrate. My problem was that we have a vBulletin in a www.domain.com/forum/ directory, and I couldn’t find a way to get it to be part of the sitemap to get it indexed.

                  That particular menu entry is a Weblink with the contents forum/index.php . I would have assumed that for a non-numeric weblink, the SiteMap snippet would create the text, but it doesn’t seem to. So I’ve written it into the code below. The code assumes that if the Weblink is not numeric, it’s a link to a subpage (we’re assuming that external links are pointless in this regard). So in those cases, we simply append this to the site_url.

                  Replace this code around line 223:

                  	foreach ($docs as $doc)	{
                  		if ($doc['type']=='reference')
                  		{
                  			$docObject = $modx->getDocument($doc['id']);
                  
                  			$content=$docObject['content'];
                  			
                  			if ( ! is_numeric($content) )
                  			{
                  				$url = $modx->config['site_url'] . $content;
                  			}
                  			else
                  				$url = '[(site_url)][~'.$doc['id'].'~]';
                  		}
                  		else
                  			$url = '[(site_url)][~'.$doc['id'].'~]';
                  


                  Actually, I have the numeric URL generated twice at the end, so the logic could be better structured. The point mainly just is generate a text URL for text weblinks.

                  Best,

                  Per
                    • 24709
                    • 1 Posts
                    First time posting any mods, so please check results on your sites. These changes worked for me while retaining original function of version 1.0.8.

                    I wanted a way to see through unpublished docs like mentioned here before. I have active docs to display that weren’t. This patch adds a new paramater similar to ditto called &seeThruUnpub that will do exactly that - see through the unpublished docs for active docs. By active, I was looking for published but not deleted. I am sure there is a better way to do this, but this works. The patch updates the notes at the top but not the version number completely. I added an ’a’ to a couple of places so I could identify what I was doing or if I had my modified version in place.

                    Also makes a small change to not display the alias name or site_url if the doc id is the same as the site_start id. Cleans up display of homepage link.

                    Hope this helps someone else.

                    --- sitemap.orig        2009-07-24 11:17:16.000000000 -0700
                    +++ sitemap.new 2009-07-24 11:46:48.000000000 -0700
                    @@ -20,6 +20,11 @@
                     MODx: 0.9.2.1, 0.9.6.1
                    
                     History:
                    +# 1.0.8a
                    +- Added ability to see through unpublished docs to find active documents. Added new parameter similar to the ditto
                    +  call, &seeThruUnpub. Useful if you use documents as containers but don't publish the containers.
                    +- Added fix pointed out in comments for the home page URL. Checks the site start id and leaves off the alias portion
                    +  if the current document is the home page. From comment by Urban on 05-28-09
                     # 1.0.8
                     - excludeTemplates can now also be specified as a template ID instead of template name.
                       Useful if you change the names of your templates frequently. (ncrossland)
                    @@ -129,12 +134,19 @@
                     $excludeWeblinks = (isset($excludeWeblinks)) ? $excludeWeblinks : false;
                    
                    
                    +# $seeThruUnpub [ bool ]
                    +# Should we look into unpublished folders to published content?
                    +# You may want to include documents that are contained inside unpublished containers
                    +# By default, these are ignored.
                    +# Default: false
                    +$seeThruUnpub = (isset($seeThruUnpub)) ? $seeThruUnpub : false;
                    +
                     /* End parameters
                     ----------------------------------------------- */
                    
                     # get list of documents
                     # ---------------------------------------------
                    -$docs = getDocs($modx,$startid,$priority,$changefreq,$excludeTV);
                    +$docs = getDocs($modx,$startid,$priority,$changefreq,$excludeTV,$seeThruUnpub);
                    
                    
                     # filter out documents by template or TV
                    @@ -221,7 +233,7 @@
                    
                    
                            foreach ($docs as $doc) {
                    -               $url = '[(site_url)][~'.$doc['id'].'~]';
                    +               $url = ( $doc['id'] == $modx->config['site_start'] ) ? '[(site_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
                    @@ -270,21 +282,50 @@
                     }
                    
                     # gets list of published documents with properties
                    -function getDocs($modx,$startid,$priority,$changefreq,$excludeTV)
                    +function getDocs($modx,$startid,$priority,$changefreq,$excludeTV,$seeThruUnpub=false)
                     {
                    +       $activeDocs = array();
                            // get children documents
                    -       $docs = $modx->getActiveChildren($startid,'menuindex','asc','id,editedon,template,published,searchable,pagetitle,type');
                    +       if ($seeThruUnpub)
                    +       {
                    +           $docs = $modx->getAllChildren($startid,'menuindex','asc','id,editedon,template,published,searchable,pagetitle,type,deleted');
                    +           //We will determine if we are going to write or not later
                    +           $writeDoc = false;
                    +       } else {
                    +           $docs = $modx->getActiveChildren($startid,'menuindex','asc','id,editedon,template,published,searchable,pagetitle,type');
                    +           //Since we are only dealing with Active Docs, safe to write them all
                    +           $writeDoc = true;
                    +       }
                            // add sub-children to the list
                            foreach ($docs as $key => $doc)
                            {
                    +               if ($seeThruUnpub) {
                    +                 //Its possible we are looking at an unpublished document
                    +                 if ($doc['published'] && !($doc['deleted'])) {
                    +                   // Doc is published and is not deleted, so we want to add it to array
                    +                   $writeDoc = true;
                    +                 } else {
                    +                       // Doc was not published or was deleted or something else we didn't want so go to next doc
                    +                   $writeDoc = false;
                    +                 }
                    +               }
                                    $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));
                    +               if ($writeDoc) {
                    +                       # If here, we have a valid active document
                    +                       $activeDocs[$key] = $doc;
                    +                       $activeDocs[$key][$priority] = getTV($modx,$id,$priority); // add priority property
                    +                       $activeDocs[$key][$changefreq] = getTV($modx,$id,$changefreq); // add changefreq property
                    +                       $activeDocs[$key][$excludeTV] = getTV($modx,$id,$excludeTV); // add excludeTV property
                    +               }
                    +               //Check to see if this Doc has any children...
                    +               if ($seeThruUnpub) {
                    +                       if ($modx->getAllChildren($id))
                    +                               $activeDocs = array_merge($activeDocs, getDocs($modx,$id,$priority,$changefreq,$excludeTV,$seeThruUnpub));
                    +               } else {
                    +                   if ($modx->getActiveChildren($id))
                    +                               $activeDocs = array_merge($activeDocs, getDocs($modx,$id,$priority,$changefreq,$excludeTV,$seeThruUnpub));
                    +               }
                            } // end foreach
                    -       return $docs;
                    +       return $activeDocs;
                     }
                     ?>
                    
                    
                    
                    
                    
                    


                    Added attachment of the patch as well.
                      • 10190
                      • 187 Posts
                      Hello,

                      I can’t get excludeTV to work. I made a TV called "sitemap_exclude", type checkbox. Although it is set automatically on every page, nothing is excluded in the snippets output.

                      The snippet call is
                      [[sitemap?&format=`sp`&excludeTV=`sitemap_exclude`]]

                      but I think I could leave the last parameter away as it is default.

                      Should the TV be of type radio button? What is a TV of type "boolean"?

                      Cheers
                      Frisco