Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter
Support for Vanilla Forums Cloud product

In this Discussion

Follow Us


Javascript url isn't properly built

edited April 2012 in Questions

First of all, thanks to the development team. Vanilla is the way I see forums : simple and pretty.

I've just installed one and I noticed that none of the Javascript functionalities were active. I looked in the code and it appears that some of the directories separators are missing and it's the reason why the page can't find the scripts.

The same applies to the themes previews pictures but other urls are ok (profile pictures, css, etc.). Oh and the invitation emails only contain : "EmailInvitation".

In my opinion, the problem is caused by PHP : maybe some option from the hosting provider (online.net) or the version of PHP (according to phpinfo : "PHP Version 5.2.9-1.illimite").

My version of Vanilla is the last one : 2.0.18.4.

Here is a portion of the vanilla page.

<link rel="stylesheet" type="text/css" href="/applications/dashboard/design/style.css?v=2.0.18.4" media="all" />
<link rel="shortcut icon" href="/themes/default/design/favicon.png" type="image/x-icon" />
<link rel="canonical" href="http://forum.***.fr/categories" />

<script src="/jslibraryjquery.js?v=2.0.18.4" type="text/javascript"></script>
<script src="/jslibraryjquery.livequery.js?v=2.0.18.4" type="text/javascript"></script>
<script src="/jslibraryjquery.form.js?v=2.0.18.4" type="text/javascript"></script>
<script src="/jslibraryjquery.popup.js?v=2.0.18.4" type="text/javascript"></script>
<script src="/jslibraryjquery.gardenhandleajaxform.js?v=2.0.18.4" type="text/javascript"></script>
<script src="/jsglobal.js?v=2.0.18.4" type="text/javascript"></script>
<script src="/applicationsvanillajsbookmark.js?v=2.0.18.4" type="text/javascript"></script>
<script src="/applicationsvanillajsdiscussions.js?v=2.0.18.4" type="text/javascript"></script></head>
Tagged:

Best Answer

  • x00x00 MVP
    edited April 2012 Answer ✓

    You could try something like

    define('PATH_ROOT', '/.');

    technically this is bug, but it is a very edge case, most people do not have your setup.

    Another way you could do it, put the forum in folder, use .htaccess to rewrite so you preserve your uri structure, and use

     $Configuration['Garden']['StripWebRoot'] = TRUE;
     $Configuration['Garden']['WebRoot'] = forumfolder; //note no preceding or trailing slash
    

    grep is your friend.

Answers

  • AoleeAolee Hobbyist & Coder ✭✭

    Have you tried installing it in a localhost or different server?


    Check out my other Plugins here

  • 422422 Developer MVP

    Am thinking ur missing a /

    422 Real Estate Australia , now open Check it out

  • x00x00 MVP
    edited April 2012

    in class.controller.php

    you have stuff like $JsPaths[] = PATH_ROOT . DS . 'js' . DS . $JsFile;

    then

               // Find the first file that matches the path.
               $JsPath = FALSE;
               foreach($JsPaths as $Glob) {
                  $Paths = SafeGlob($Glob);
                  if(is_array($Paths) && count($Paths) > 0) {
                     $JsPath = $Paths[0];
                     break;
                  }
               }
    
               if ($JsPath !== FALSE) {
                  $JsSrc = str_replace(
                     array(PATH_ROOT, DS),
                     array('', '/'),
                     $JsPath
                  );
    

    then $this->Head->AddScript...

    grep is your friend.

  • note $Options['path'] = $JsPath;

    AddScript in head module refers to $Attributes = array('src' => Asset($Src, FALSE, GetValue('version', $Options)), 'type' => $Type);

    Asset in functions.general.php

    grep is your friend.

  • x00x00 MVP
    edited April 2012

    so I would be looking to see what PATH_ROOT is set as.

    Note in index.php

    // 1. Define the constants we need to get going.
    define('DS', '/');
    define('PATH_ROOT', dirname(__FILE__));
    

    grep is your friend.

  • are you using $Configuration['Garden']['StripWebRoot'] perchance?

    grep is your friend.

  • Thanks for your help.

    I runed it on my localhost (PHP 5.3.8) and there is no problem with the Javascript paths, that's why I think the problem is caused by the PHP configuration. I made no special modification in the source.

    x00 said: are you using $Configuration['Garden']['StripWebRoot'] perchance?

    No, there is no such line in the configuration.

  • Yep could be right, it does seem to be a strange version to run on a production server.

    I would check to see if you have a choice of php versions.

    grep is your friend.

  • I've managed to have the Javascript working by using an optimization plugin. So, it's ok for the moment.

    I'll check if I can have control on the PHP version.

  • try this script

    <?php
    error_reporting(E_ALL);
    ini_set('display_errors', 'on');
    ini_set('track_errors', 1);
    define('DS', '/');
    define('PATH_ROOT', dirname(__FILE__));
    
    var_dump(PATH_ROOT);
    
    

    grep is your friend.

  • No error displayed.

    The output of var_dump is :

    string(1) "/"
  • yep that is wrong it should show something like /var/www

    in index.php you could change

    define('PATH_ROOT', '/path/to/www');

    in any event ending in / could cause that problem becuase that is what is stripped.

    grep is your friend.

  • edited April 2012

    Indeed, in my localhost, this value is correct.

    Problem is : I don't know how I can get the correct value from the server.

    The value of $_SERVER["DOCUMENT_ROOT"] is the same "/" and the only connection I have to the server is FTP.

  • x00x00 MVP
    edited April 2012

    what is the value of __FILE__?

    grep is your friend.

  • The trick with '/.' worked.

    I'll find more time later to make it clean with the .htaccess.

    Thank you very much for your help!

  • 422422 Developer MVP

    Cough

    422 Real Estate Australia , now open Check it out

  • x00x00 MVP
    edited April 2012

    422 said: Cough

    oh dear is it itchy and dry or chesty? Or the option that no remedy seems to mention red raw?

    grep is your friend.

Sign In or Register to comment.