We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 329
    • 4 Posts
    I get:


    « MODx Parse Error »
    MODx encountered the following error while attempting to parse the requested resource:
    « Execution of a query to the database failed - Unknown column ’Imuthes’ in ’where clause’ »
    SQL: SELECT alias FROM `db246662437`.`jvkcms_site_content` WHERE `id` = Test-File.pdf

    Dr. Scotty, as you can see this is caused by WHERE `id`=Test-File.pdf, namely the "-" in the filename and lack of enclosing single quotes around it in the SQL clause. The problem is caused by line 108 in the snippet, change this:
    		$document = $modx->db->select('alias', $site_content, "`id` = $id");
    

    Into:
    		$document = $modx->db->select('alias', $site_content, "`id` = '$id'");
    

    smiley
      • 329
      • 4 Posts
      Another issue I noticed is that the download counter only works properly if the download link page is placed in the root, and it won’t count properly downloads of the same file from different pages, and doesn’t work with friendly alias paths too well.

      I fixed it, replace this part which starts on line 25:

      // Get download count for requested document.
      if ($action == 'count')
      {
      	$filename = isset($filename) ? $filename : Download::GetAlias($id);
      	
      	if ($modx->config['friendly_urls'] && $modx->config['friendly_alias_urls']) 
      	{
      		$_pIds = $modx->getParentIds($id);
      
      		foreach($_pIds as $pId) 
      		{
      			$_alias = Download::GetAlias($pId);
      			$_aliaspath[] = (!$_alias) ? $pId : $_alias;
      		}
      		$filename = implode("/",$_aliaspath)."/".$filename;
      	}
      	
          return Download::Count($filename, $_table, $dberror, $nofile);
      }
      


      Not sure if this project / thread is dead, if not then I can fix all the issues and submit it as the next version.

      cheers

      Jonny
        • 25663 MODX Staff
        • 12,272 Posts
        Jonny, the good Pirate is a bit preoccupied with life in general so anyone that can make an update to this that consolidates bug fixes would be appreciated. Thansk!
          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • 7231
          • 4,205 Posts
          abyssalplain: this being a community it is always welcome to chip in with some code, specially if it fixes a bug. I think it is great that code evolves once it gets made public. grin grin
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don't know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 31782
            • 103 Posts
            Scotty, thank you for your snippet FileDownloadPE.
            It works fine on the site posted on the local computer, but when the site moved to the hosting snippet stopped working. I reinstall several times.
            When click the link to download the file, then downloaded txt file with size 0 kB. And doesnot count the number of downloads.
            Generally in site`s database there is not ’download’ table .
            sad
              • 37550 ☆ A M B ☆
              • 711 Posts
              Hi Scotty

              Just wanted to say thanks for this snippet its fantastic and just what I needed.

              Aaron
                http://www.onesmarthost.co.uk
                UK MODX Hosting with love.
                • 28893
                • 2 Posts
                Quote from: ruceb at Nov 01, 2008, 08:10 PM

                Thanks again. Hhm, I’m still not getting this to work, even with your script. If I change the template accordingly and put a snippet call in the site where I want to provide downloads, Firefox ask to download the whole site when clicking the link that should carry the user there. So, it seems I’ll finally have to have someone investigate this further directly on my site / code if I can find someone. Thanks anyway, again!

                Regards, Ruceb

                Hey.. It’s a bit long since your post. But I’ve got a simple solution...

                Had the same issue earlier today. Worked fine in IE and Chrome, but not in FireFox. The solution is easy tho, add the appropriate content types to your configuration. Go to tools - configuration - custom content types and add the required types as text/rar etc.

                Change the contenttype @ the download page and hopefully you will be happy aswell smiley I left the TV set to ’force-download’
                  • 33549
                  • 15 Posts
                  Hello.
                  I see FileDownloadPE behaving strangely in my website.

                  URL: http://test.zipgenius.it
                  MODx 0.9.6.3

                  I uploaded two .exe files to my server and added the download links as per FileDownloadPE instructions in the same page.

                  The first one is the file placed in assets/files/zg60/zg603std.exe (5 MB circa).
                  If I click on its link in the donwload page, the download starts and the counter increases by 1 as designed.

                  The second one is assets/files/zg60/zg602sui.exe (8.03 MB circa).
                  If I click on its link, I get a file not found error but the download counter increases by 1.
                  If I add "../" to its path in the File TV and try again, the download starts fine but the download counter doesn’t update.

                  Any idea?
                    • 29877
                    • 35 Posts
                    I am utilizing this in in a corporate website right now, but it’s not entirely working as desired. I would like to be able to resolve this as quickly as possible without finding another solution and starting all over.

                    Most of the files that I’m using with this are PDFs. Most download correctly, while some do not. The starting point for most my downloads begins here: http://www.nettrekker.com/customer-resources/learn/resources


                    Here are some live examples, shown below:

                    1. Here is one link that displays the PDF correctly:
                    http://www.nettrekker.com/downloads/customer-resources/how-tos/access-and-implementation/access_methods.pdf


                    2. Here is one link that does NOT display the PDF correctly:
                    http://www.nettrekker.com/downloads/customer-resources/how-tos/login-and-user-roles/user_registration_-_student.pdf

                    If you look at the first screen-shot used in the document, the image appears corrupt. It DOES display correctly if you view the document at it’s official location:
                    http://www.nettrekker.com/assets/files/customer_resources/how_tos/user_registration_-_student.pdf


                    Additionally, I WAS also using this on the following logo page: http://www.nettrekker.com/about-us/press-and-media/logos
                    Here, I was offering four image formats for download (JPG, EPS, PSD and TIFF). Again, some (not all) worked correctly. For what it’s worth, I tried using different MIME types as well. I added additional MIME types for the EPS, PSD and TIFF formats. I’ve even tried to force the download. The end result was that it was saving corrupt files and they were not being displayed or opening.

                    Help solving this would VERY MUCH be appreciated.

                    Thank you!
                      • 20751
                      • 122 Posts
                      Hi,

                      It didn’t work for me right away either. It is usually a conflict issue with Phx. Do you have that plugin installed? If you do just try and disable it to see if this fixes the issue. If it does fix the issue, re-enable it and I will show you how to resolve matters without having to diable Phx permenantly.