We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Quote from: sottwell at Jun 02, 2005, 10:17 AM

    Having problems with image paths. Will work it out eventually (I hope).

    Susan, what is your issue with image paths? This has been an area of trouble for me during these integrations with the latest TinyMCE and FCKeditor, and since I don’t regularly use the WYSIWYG editors myself for actual content authoring, I’m not sure of all the expectations for dealing with internal paths within them. Currently, both FCKeditor and TinyMCE’s image plugins are inserting full paths when selecting images, otherwise, the document editor cannot properly preview the images unless absolute paths from the document root are employed. You can make them relative paths and the images will show up in the site, but not in the WYSIWYG.

    IMO, all paths should be relative to the root of the site. This provides the best portability for your content and if we can make friendly alias paths work with relative paths, regardless if the site is installed in the document root or in a subdirectory somewhere, then we’ll have a good solution, coupled with consistent pathing behavior from the WYSIWYG’s.
      • 22927
      • 19 Posts
      Made a new fresh install, needed to upload the dutch language file for FCKEditor to /manager/media/fckeditor/editor/lang, after that all worked like expected.
      Without the language file FCKEditro wouldn’t show up
      • Quote from: pcwacht at Jun 02, 2005, 06:43 PM

        Made a new fresh install, needed to upload the dutch language file for FCKEditor to /manager/media/fckeditor/editor/lang, after that all worked like expected.
        Without the language file FCKEditro wouldn’t show up

        I thought that might be a problem. We removed the language files in an effort to keep the MODx package smaller. This is exactly why allowing editors to be downloaded and installed separately would be optimal.
          • 22927
          • 19 Posts
          For developper time being you could fix the language on FCKEditor so it will only show english

          In /manager/media/fckeditor/fckconfig.js
          change
          FCKConfig.AutoDetectLanguage = true ;
          to
          FCKConfig.AutoDetectLanguage = false ;


          • I really don’t know what the problem is. include.inc.php:
            	// automatically assign base_path, base_url, and site_url
            	if($base_path==""||$base_url=="") {
            		$a = explode("manager",str_replace("\\","/",dirname($_SERVER["PHP_SELF"])));
            		if(count($a)>1) array_pop($a);
            		$url = implode("manager",$a); reset($a);
            		$a = explode("manager",dirname(__FILE__));
            		if(count($a)>1) array_pop($a);
            		$pth = implode("manager",$a); unset($a);
            		$base_url = $url.(substr($url,-1)!="/"? "/":"");
            		$base_path = $pth.(substr($pth,-1)!="/"? "/":"");
            		$site_url = (!isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) != 'on')? "http://" : "https://" ;
            	    $site_url .= $_SERVER['HTTP_HOST'];
            	    $site_url .= ($_SERVER['SERVER_PORT']==80 || isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS'])=='on')? "":":".$_SERVER['SERVER_PORT'];
            	    $site_url .= $base_url;
                }
            


            and fck’s php/config.php
            /*------------------------------------------------------------------------------*/
            /* The physical path to the document root, Set manually if not using apache	*/
            /*------------------------------------------------------------------------------*/
            $fckphp_config['basedir']=substr($base_path, 0, strlen($base_path)-1);
            //$fckphp_config['basedir'] = $_SERVER['DOCUMENT_ROOT'] ;
            
            /*==============================================================================*/
            
            /*------------------------------------------------------------------------------*/
            /* Prefix added to image path before sending back to editor			*/
            /*------------------------------------------------------------------------------*/
            //$fckphp_config['urlprefix']=$fckphp_config['prot'].$_SERVER['SERVER_NAME'];
            $fckphp_config['urlprefix']= substr($site_url, 0, strlen($site_url)-1);
            /*==============================================================================*/
            
            
            /*------------------------------------------------------------------------------*/
            /* Path to user files relative to the document root (no trailing slash)		*/
            /*------------------------------------------------------------------------------*/
            $fckphp_config['UserFilesPath'] = "/assets" ;
            /*==============================================================================*/
            


            So I see what’s being done. But... with this setup, I get this path for images:

            http://localhost/bmp/manager/media/fckeditor/editor/file/assets/images/logo.gif


            While if I hardcode the exact same url that a check of the $site_url generating code in config.inc.php produces (an echo statement, and copy/pasted directly from the page output!), in the config.inc.php
            $site_url = "http://localhost/bmp/";


            file it works as expected. huh Really weird.

            But in the process I discovered the fckconfig.js file, and have been very happy playing with the main menu, getting just the objects I want displayed!
            FCKConfig.ToolbarSets["Default"] = [
                ['PasteWord','PasteText','Cut','Copy','Paste','Bold','Italic','Underline','Link','Unlink','Image','Rule','Source'],
                 ['FontFormat','FontName','FontSize','TextColor','BGColor']
            ];
            
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 21301
              • 93 Posts
              Before commenting on anything - Great work! Here’s just a couple of small notes.

              Regarding to the image-path problems. Relative images won’t work in my case because the MODx base URL is http://host/modx/. Images end up linking to /assets/images/image.jpg. Hence http://host/assets/images/image.jpg, whereas it should be http://host/modx/assets/images/image.jpg.
              Is the ’URL to MODx base’ autodeteced? Maybe an extra setting besides the ’URL to images directory’?

              Uploading an image using the imageTV lets you specify dimensions. As I can see, only the path ends up in the variable. I guess you don’t want the extra options like size etc.

              Another (minor) path issue. The fileTV. The current path is used here. The ’current file’ in the manager links (in my case) to /modx/manager/file.zip. The live site links to ’/modx/file.zip’. Both wrong because the file gets uploaded to ’/modx/assets/images’. Can you set the directory where these files go?

              When adding more path settings you might group all file (size/type), path and URL settings into a new tab.

              So far. And I love the product! Flexibility is products like these is hard to find. Etomite/MODx doesn’t force you to do anything, but adds a great framework!
              • Thanks for pointing those out Theo and for the suggestions. There’s several areas that need to be reviewed still, but we want to release Tech Previews so folks can get early access. Some of the areas due for an overhaul include paths (as you and Sottwell pointed out), friendly aliases (especially paths LOL) and the upcoming modules/plugins enhancements. There’s a lot more of course, but that’s some of the things going on. Enjoy and keep the feedback coming! smiley
                  Ryan Thrash, MODX Co-Founder
                  Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                • Quote from: sottwell at Jun 03, 2005, 09:47 AM

                  I really don’t know what the problem is. include.inc.php:
                  	// automatically assign base_path, base_url, and site_url
                  	if($base_path==""||$base_url=="") {
                  		$a = explode("manager",str_replace("\\","/",dirname($_SERVER["PHP_SELF"])));
                  		if(count($a)>1) array_pop($a);
                  		$url = implode("manager",$a); reset($a);
                  		$a = explode("manager",dirname(__FILE__));
                  		if(count($a)>1) array_pop($a);
                  		$pth = implode("manager",$a); unset($a);
                  		$base_url = $url.(substr($url,-1)!="/"? "/":"");
                  		$base_path = $pth.(substr($pth,-1)!="/"? "/":"");
                  		$site_url = (!isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) != 'on')? "http://" : "https://" ;
                  	    $site_url .= $_SERVER['HTTP_HOST'];
                  	    $site_url .= ($_SERVER['SERVER_PORT']==80 || isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS'])=='on')? "":":".$_SERVER['SERVER_PORT'];
                  	    $site_url .= $base_url;
                      }
                  


                  and fck’s php/config.php
                  /*------------------------------------------------------------------------------*/
                  /* The physical path to the document root, Set manually if not using apache	*/
                  /*------------------------------------------------------------------------------*/
                  $fckphp_config['basedir']=substr($base_path, 0, strlen($base_path)-1);
                  //$fckphp_config['basedir'] = $_SERVER['DOCUMENT_ROOT'] ;
                  
                  /*==============================================================================*/
                  
                  /*------------------------------------------------------------------------------*/
                  /* Prefix added to image path before sending back to editor			*/
                  /*------------------------------------------------------------------------------*/
                  //$fckphp_config['urlprefix']=$fckphp_config['prot'].$_SERVER['SERVER_NAME'];
                  $fckphp_config['urlprefix']= substr($site_url, 0, strlen($site_url)-1);
                  /*==============================================================================*/
                  
                  
                  /*------------------------------------------------------------------------------*/
                  /* Path to user files relative to the document root (no trailing slash)		*/
                  /*------------------------------------------------------------------------------*/
                  $fckphp_config['UserFilesPath'] = "/assets" ;
                  /*==============================================================================*/
                  


                  So I see what’s being done. But... with this setup, I get this path for images:

                  http://localhost/bmp/manager/media/fckeditor/editor/file/assets/images/logo.gif



                  We’ve gotta replace that base_url code, cause if your path has another instance of manager in it (say filemanager (this is why you are getting the path above), it gets screwed up. However, your config.inc.php looks like it was not upgraded, cause I fixed this in the latest release and you’re missing those changes???
                  • I manually updated the config.inc.php file from the install/instprocessor.php file in 1.0pre2.1. Is there a newer version?

                    I’m looking at a couple of other ways of dealing with setting these three items up. One is to only run the script at install and write the result to the file; since moving the site requires manual intervention in the database configuration I don’t see a big deal with having to change the base paths/urls as well. There could be an autodetection script available that would be run if there were database errors indicating the config.inc.php file was no longer applicable, sort of like the one that shows the need of running the installation script. ("It appears that your database configuration has changed. Please update your site configuration"; then have a form to update the config.inc.php data. Would also need to check that config.inc.php is writable.)

                    Besides, I’m not overly fond of the idea of that code having to be run every page impression! It should be set up on installation and that’s it.
                      Studying MODX in the desert - http://sottwell.com
                      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                      Join the Slack Community - http://modx.org
                    • Quote from: sottwell at Jun 04, 2005, 04:40 AM

                      I manually updated the config.inc.php file from the install/instprocessor.php file in 1.0pre2.1. Is there a newer version?

                      I’m looking at a couple of other ways of dealing with setting these three items up. One is to only run the script at install and write the result to the file; since moving the site requires manual intervention in the database configuration I don’t see a big deal with having to change the base paths/urls as well. There could be an autodetection script available that would be run if there were database errors indicating the config.inc.php file was no longer applicable, sort of like the one that shows the need of running the installation script. ("It appears that your database configuration has changed. Please update your site configuration"; then have a form to update the config.inc.php data. Would also need to check that config.inc.php is writable.)

                      Besides, I’m not overly fond of the idea of that code having to be run every page impression! It should be set up on installation and that’s it.

                      Here is portion of the instprocessor.php updated to address a couple of issues -- this should be in 2.1, but I’ll have to double-check the package...

                      	// automatically assign base_path and base_url
                      	if($base_path==""||$base_url=="") {
                      		$a = explode("/manager",str_replace("\\\\","/",dirname($_SERVER["PHP_SELF"])));
                      		if(count($a)>1) array_pop($a);
                      		$url = implode("manager",$a); reset($a);
                      		$a = explode("manager",dirname(__FILE__));
                      		if(count($a)>1) array_pop($a);
                      		$pth = implode("manager",$a); unset($a);
                      		$base_url = $url.(substr($url,-1)!="/"? "/":"");
                      		$base_path = $pth.(substr($pth,-1)!="/" && substr($pth,-1)!="\\\\"? "/":"");
                      		$site_url = (!isset($_SERVER[\'HTTPS\']) || strtolower($_SERVER[\'HTTPS\']) != \'on\')? "http://" : "https://" ;
                      	   $site_url .= $_SERVER[\'HTTP_HOST\'];
                      	   $site_url .= ($_SERVER[\'SERVER_PORT\']==80 || isset($_SERVER[\'HTTPS\']) || strtolower($_SERVER[\'HTTPS\'])==\'on\')? "":":".$_SERVER[\'SERVER_PORT\'];
                      	   $site_url .= $base_url;
                      	}';
                      


                      Notice the opening slash added to the first explode and the
                      && substr($pth,-1)!="\\\\"
                      added to the final $base_path expression (for Windows paths).