We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5901
    • 11 Posts
    Hello,

    I@m a ModX newbie loving the ease of use of the ModX system. I’m currently building an XML Sitemap based around the tutorial at:

    http://rtfm.modx.com/display/ADDON/getResources.Google+XML+Sitemap

    In my XML Sitemap document I have the following code, and everything is outputting as it should be.

    <?xml version="1.0" encoding="UTF-8"?>
    <urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
    [[!getResources?
      &parents=`0`
      &tpl=`XMLSitemapTPL`
      &limit=`500`
      &sortdir=`DESC`
      &includeTVs=`1`
      &includeContent=`1`
      &processTVs=`1`
      &depth=`10`
      &sortbyTV=`sitemappriority`
      ]]
    </urlset>


    Naturally, I want to exclude some documents from the Sitemap (such as error pages, etc). I have created another TV called ’sitemapexclude’ with the following properties: Output Type Text - Include==1||Exclude==0

    I then tried to insert the dollowing into the code:

    &tvFilters=`sitemapexclude==Include'


    The sitemap then outputs a blank sitemap with nothing between the <urlset></urlset> tags.

    Am I doing something wrong here?? I’v searched these forums and Google for an answer but cant seem to find one!

    Regards

    Craig

    Help Appreciated!

      • 59
      • 10 Posts
      Hi, perhaps you could try it using the &where paramater?

      &where=`{{"sitemapexclude:=":"Include"}}` &includeTVs=`1` &processTVs=`1`
        • 5901
        • 11 Posts
        Thanks, I’ll give it a go and let you know.

        Craig
          • 5901
          • 11 Posts
          Hi 1pxrgba

          Checked out your solution and it still doesn’t appear to be working. Any other ideas please?

          Regards

          Craig
            • 5901
            • 11 Posts
            Still having issues with this. Has anyone got any other ideas?

            Regards

            Craig
              • 18463
              • 121 Posts
              Martijn van Turnhout Reply #6, 15 years, 5 months ago
              Try using these percentage thingies:

              &tvFilters=`sitemapexclude==%Include%'
              
                • 5901
                • 11 Posts
                Thanks for replying Marrijn

                I have give the solution a go, but get a similar output to using &tvFilters=`sitemapexclude==Include’.

                Essentially it builds the XML document, but it is empty. The only two tags showing in the XML document is <urlset></urlset> when veiwing through a browser at www.domain.com/sitemap.xml.

                The output of the code as shown in the source is:

                <?xml version="1.0" encoding="UTF-8"?>
                <urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
                
                </urlset>


                Regards

                Craig
                  • 5901
                  • 11 Posts
                  Is this a known bug, is anybody else having issues with achieving something similar?
                    • 33608
                    • 27 Posts
                    I think you need to have the tvFilter search for "1", not "Include". If you look at your database, you can see the value that is being set and filter looking for that value.

                    I really don’t know how the tvFilter thing works under the hood, but i’ve had much better luck using strings instead of ints (include==include||exclude==exclude). Does this help?
                      • 5901
                      • 11 Posts
                      How would the strings sit within the following call:

                      <?xml version="1.0" encoding="UTF-8"?>
                      <urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
                      [[!getResources?
                        &parents=`0`
                        &tpl=`XMLSitemapTPL`
                        &limit=`500`
                        &sortdir=`DESC`
                        &includeTVs=`1`
                        &includeContent=`1`
                        &processTVs=`1`
                        &depth=`10`
                        &sortbyTV=`sitemappriority`
                        ]]
                      </urlset>


                      Thanks

                      Craig