cegcore asset libraries loading with absolute url

bmurphey 22 Dec, 2016
The cegcore asset libraries are all loading using an absolute url rather than a relative url. This is causing some issues on a site I have running on a private intranet. Example:

<link href="http://localhost:8080/bmt/libraries/cegcore/assets/bootstrap/css/bootstrap.css" media="screen" rel="stylesheet" type="text/css" />
<link href="http://localhost:8080/bmt/libraries/cegcore/assets/bootstrap/css/bootstrap-theme.css" media="screen" rel="stylesheet" type="text/css" />
<link href="http://localhost:8080/bmt/libraries/cegcore/assets/bootstrap/css/bootstrap-gcore.css" media="screen" rel="stylesheet" type="text/css" />
etc..

Is there anyway to get the assets to load with just the relative url? The core Joomla libraries all load relative:

<script src="/bmt/media/jui/js/jquery.min.js" type="text/javascript"></script>
<script src="/bmt/media/jui/js/jquery-noconflict.js" type="text/javascript"></script>
<script src="/bmt/media/jui/js/jquery-migrate.min.js" type="text/javascript"></script>
etc...
GreyHead 22 Dec, 2016
Hi bmurphey,

I think that the files are all loaded from /libraries/cegcore/libs/document.php - you could try editing that and replace \GCore\C::get('GCORE_FRONT_URL') with '/bmt/libraries/cegcore/' so, for example line 114 changes from
$this->addJsFile(\GCore\C::get('GCORE_FRONT_URL').'assets/jquery/jquery.js');
to
$this->addJsFile('/bmt/libraries/cegcore/'.'assets/jquery/jquery.js');


Bob
bmurphey 22 Dec, 2016
Thanks Bob.

I tried that but doesn't seem to be changing anything. I will keep investigating. Please let me know if you have any other ideas.

Thanks!

Brian
bmurphey 22 Dec, 2016
I take that back: It did change the path. The path is now:
<script src="http://localhost:8080/bmt/libraries/cegcore//bmt/libraries/cegcore/assets/jquery/jquery.js" type="text/javascript"></script>

So apparently the absolute is getting tacked on somewhere else.

Thanks -

-Brian
GreyHead 22 Dec, 2016
Hi Brian,

Is there a $livesite setting in the site Configuration.php file - that can cause the domain part to be added?

Bob
bmurphey 22 Dec, 2016
I have $livesite set to ''.

-Brian
GreyHead 22 Dec, 2016
Hi Brian,

Thank you - that eliminates another possibility . . .

Bob
GreyHead 23 Dec, 2016
Hi Brian,

Another possibility to try, At line 80 of /libraries/cegcore/libs/document.php is this function
	function addJsFile($path, $type = 'text/javascript'){
		if(substr($path, 0, 4) != 'http'){
			if(strpos($path, '/') === false){
				$path = \GCore\Helpers\Assets::js($path);
			}else{
				//relative file path provided
				$path = $this->url.$path; // << try commenting out this line 
			}
		}
		if(!in_array($path, (array)Arr::getVal($this->jsfiles, array('[n]', 'src')))){
			$this->jsfiles[] = array('src' => $path, 'type' => $type);
		}
	}
You can try commenting out the line I've flagged which appears to be converting the URLs from Relative to Absolute.

There's a similar CSS function just before that.

Bob
bmurphey 23 Dec, 2016
That did the trick! Many thanks!

-Brian
This topic is locked and no more replies can be posted.