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

    You can force removal of www by removing all references to www in the example htaccess code:

    RewriteCond %{HTTP_HOST} .
    RewriteCond %{HTTP_HOST} !^example\.com [NC]
    RewriteRule (.*) http://example.com/$1 [R=301,L]

    I suppose this could be done in the plugin itself, but you might as well use htaccess if it’s required for FURLs to work.

    I’m actually testing in Lighttpd, not sure if anyone here uses it heh.

    @Geo88,

    Great, glad it’s workin. The getChildIds() call is necessary because it is what determines whether a document is a container or not. I’ve looked through the API, including the $documentMap identifier, but am unable to find any other way for doing this short of a using at least one additional db query. Although I haven’t tested it, I guess the best way to do this would be to add the following lines somewhere outside of the loop:


    $isfolder_arr = array();
    $result = $modx->db->select(’id, isfolder’, $modx->getFullTableName(’content’), ’published > 0’);
    while ($row = $modx->db->getRow($result))
    {
    $isfolder_arr[$row[’id’]] = $row[’isfolder’];
    }

    And then in the foreach loop set: $isfolder = $isfolder_arr[$id];

    Insted of: $isfolder = count(...


    Perhaps I should add an option to either perform this query or use the API to derive the count?

    As a side note: The core patch I have and may release a patch for avoids a lot of the inconsistencies and inefficiencies of the plugin but the plugin works in a pinch and should be pretty efficient for smaller to medium sized sites.
      • 23491 ☆ A M B ☆
      • 1,056 Posts
      Apoxx, possibly you could assist with troubleshooting http://www.pixelchutes.com with me...

      NOW, with override=1, I get weird behavior where links generate "/index" instead of "/", and "/portfolio" instead of "/portfolio/" ??

      Why wouldn’t a container, empty or not, with manual override flagged as folder show up as "/folder/" ?

      I think I had a lot better luck w/ 0.7.2 wink
        Mike Reid - www.pixelchutes.com
        MODx Ambassador / Contributor
        [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
        ________________________________
        Where every pixel matters.
        • 1932
        • 137 Posts
        @Pixelchutes: I’ve updated 0.8.1 in my post above, it should correct any problems when no suffix is defined.
          • 10666
          • 68 Posts

          @Geo88,
          $isfolder_arr = array();
          $result = $modx->db->select(’id, isfolder’, $modx->getFullTableName(’content’), ’published > 0’);
          while ($row = $modx->db->getRow($result))
          {
          $isfolder_arr[$row[’id’]] = $row[’isfolder’];
          }

          And then in the foreach loop set: $isfolder = $isfolder_arr[$id];

          Insted of: $isfolder = count(...
          I have tried to implement that , but couldn’t even get it to work as good as the default 0.8.1 . Guess I’m that bad at php. grin
          Maybe an isFolder() method could be proposed as an API function for future releases ( 0.7 .. ) ?
            • 1932
            • 137 Posts
            @Geo88,

            Sorry, I used the wrong table name, should be site_content not content. To get containers working instead of just counting children, the code would be changed as follows:

            Change:
               if ($makeFolders) $isfolder = (count($modx->getChildIds($documentIdentifier, 1)) > 0) ? 1 : 0;
            


            To:
               if ($makeFolders)
               {
                  $result = $modx->db->select('isfolder', $modx->getFullTableName('site_content'), 'id = ' . $documentIdentifier);
                  $isfolder = $modx->db->getColumn('isfolder', $result);
               }
            


            And change:
                     // Replace container links
                     foreach ($modx->documentListing as $id)
                     {
                        if (count($modx->getChildIds($id, 1)) > 0)
                        {
            


            To:
                     // Populate isfolder array
                     $isfolder_arr = array();
                     $result = $modx->db->select('id', $modx->getFullTableName('site_content'), 'published > 0 AND isfolder > 0');
                     while ($row = $modx->db->getRow($result))
                        $isfolder_arr[$row['id']] = 1;
            
                     // Replace container links
                     foreach ($modx->documentListing as $id)
                     {
                        if (isset($isfolder_arr[$id]))
                        {
            
              • 25663 MODX Staff
              • 12,272 Posts
              Quote from: ApoXX at Feb 09, 2007, 05:56 PM

              @rthrash,

              You can force removal of www by removing all references to www in the example htaccess code:

              RewriteCond %{HTTP_HOST} .
              RewriteCond %{HTTP_HOST} !^example\.com [NC]
              RewriteRule (.*) http://example.com/$1 [R=301,L]

              I suppose this could be done in the plugin itself, but you might as well use htaccess if it’s required for FURLs to work.

              Just so everyone is clear, this is added in addition to whatever else is in your .htaccess file. Mine at collabpad.com now looks like:

              RewriteEngine On
              RewriteBase /
              
              RewriteCond %{HTTP_HOST} .
              RewriteCond %{HTTP_HOST} !^collabpad\.com [NC]
              RewriteRule (.*) http://collabpad.com/$1 [R=301,L]
              
              RewriteCond %{REQUEST_FILENAME} !-f
              RewriteCond %{REQUEST_FILENAME} !-d
              RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]


              This does beg a question though, if you wanted a secure section of the site like https://secure.collabpad.com/ for logins and possibly selling items, how would the above .htaccess need to be changed?
                Ryan Thrash, MODX Co-Founder
                Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                • 1932
                • 137 Posts
                @rthrash,

                Forcing of secure URLs can be done in .htaccess with the following lines:

                RewriteCond %{SERVER_PORT} !^443
                RewriteRule (.*) https://example.com/$1 [R=301,L]
                


                You can either add the above rules in addition to what you have, or, I believe you could chain conditions like this:

                RewriteCond %{SERVER_PORT} !^443
                RewriteCond %{HTTP_HOST} !^collabpad\.com [NC]
                RewriteRule (.*) https://collabpad.com/$1 [R=301,L]
                


                As far as I know, the "RewriteCond %{HTTP_HOST} ." line is really only needed for legacy browsers which don’t send out the HTTP_HOST header.
                  • 10666
                  • 68 Posts
                  Works like a charm grin .

                  So is this going to make it in to the 0.7 core ?
                    • 1932
                    • 137 Posts
                    It is planned for integration into version 0.9.7. It will work a little bit differently, but essentially allow for the same functionality.
                      • 25663 MODX Staff
                      • 12,272 Posts
                      It works great btw. Only suggestions I’d make it to turn the configuration stuff in the code into a configuration parameter line... and maybe allow alternate functionality based on Geo88’s request/your code above. Keep it up!
                        Ryan Thrash, MODX Co-Founder
                        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me