We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17329
    • 53 Posts
    I was implementing the Google Sitemap using Ditto that neon_eddy suggested and I noticed that Ditto does not retrieve the value of TVs with no value and with a default value @INHERIT.

    I have 3 TVs
    - sitemap_changefreq
    - sitemap_priority
    - sitemap_exclude
    for each doc to give me the necessary information.

    The default value of sitemap_changefreq and sitemap_priority is @INHERIT so that I can specify the value in a parent document when needed. That means that for many documents, those two variables don’t have a value set but just get the default @INHERIT.

    What I see in the result is that all @INHERIT default values are not retrieved properly from the parents but stay empty.


    My Ditto call is the following :

    [[Ditto? &dateFormat=`%Y-%m-%d` &parents=`0` &tpl=`googleSitemap` &dateSource=`editedon` 
    &sortby=`sitemap_priority` &depth=`4` &display=`all` &noResults=`` &filter=`sitemap_exclude,1,2` 
    &hiddenFields=`sitemap_changefreq,sitemap_priority`]]
    


    My template googleSitemap is the following :

    <url>
    <loc>[(site_url)]/[~[+id+]~]</loc>
    <lastmod>[+date+]</lastmod>
    <priority>[+sitemap_priority+]</priority>
    <changefreq>[+sitemap_changefreq+]</changefreq>
    </url>
    


    I am using the very latest Ditto 2.0.2 SVN.
      • 18397
      • 3,250 Posts
      Can you provide the debug output of the call please? Thanks.
        • 17329
        • 53 Posts
        Mark,

        I actually noticed something very funny. My site looks like that :

        root (0)
        |- en (english root)
        |- sr (serbian root)
        |- sitemap.xml

        If I make the ditto call to generate the sitemap in sitemap.xml under root it doesn’t work as I said.
        If I move ’sitemap.xml’ inside the folder ’en’ or ’sr’, everything being the same : it works fine !

        So only when the page is child of root it doesn’t work.

        I attached the debug console for the non working case when the page is child of root (id = 0).

        cheers
          • 18397
          • 3,250 Posts
          1. Does your @INHERIT have a default value?
          2. Try putting en and sr in a folder.
          3. Try putting sitemap.xml in a folder.
            • 17329
            • 53 Posts
            I did some debugging and its seems the problem is occuring in "appendTV" function in ditto class.

            In the following code

            $query = "SELECT name,type,display,display_params,default_text";
            $query .= " FROM $tb2";
            $query .= " WHERE name='".$tvname."' LIMIT 1";
            $rs = $modx->db->query($query);
            $row = @$modx->fetchRow($rs);
            $defaultOutput = getTVDisplayFormat($row['name'], $row['default_text'], $row['display'], $row['display_params'], $row['type'],$row['contentid']);
            


            In the case of my problem, the function "getTVDisplayFormat" is called with "default_text" being @INHERIT and "contentid" being the id of the sitemap page.
            "name" is the name of the variable to get (sitemap_priority or sitemap_changefreq).

            The page sitemap.xml has a blank template and does not have those TVs defined (doesn’t need to).

            When sitemap.xml is child of root (0) it seems that because the TV are neither defined in sitemap.xml nor in the root it doesn’t work. ($defaultOutput is empty)

            When sitemap.xml is child of a folder (en or sr), the parent have those TVs defined and it works. ($defaultOutput is set to the value in the parent)


            Now the problem is that it should not matter what TVs are defined on the page where the call to ditto is made but only on the pages that are included in the ditto result.


            In order words, where is the page with the ditto call located should not affect the result. Especially since that page is excluded from the result.

            It hard for me to debug further as I do not know the mecanic to go from @INHERIT to the value and how is that done for each page of the result.

            lionel
              • 5727
              • 160 Posts
              Any news on that? I’m being cursed by the same problem. I’m making extensive use of @INHERIT on one of my web site and I can’t get none of the TVs to display. Any solutions, even temporary fix or a nasty hack would be appreciated.
                Olivier Deland
                Montreal, Canada - Web Developer
                • 17329
                • 53 Posts
                I am not aware of a solution.
                In the meantime, for Google sitemap, I am not using Ditto but the snippet Sitemap:

                http://www.modxcms.com/sitemap-711.html

                I am really happy with it. My point to go with Ditto was to consolidate and use less code. But so far it doesn’t work.