How to fix relative path issue in Joomla for a component?

696 views Asked by At

I have created one component in Joomla and added one view called 'editor' inside it

component name: com_at
view name: editor
layout name: default.php

After that, I have added 'content-editor' folder on path: /var/www/dev.com/public/content-editor

content-editor contain following file and folder(it's a javascript application with no php dependency, I want to wrap this application inside Joomla and only authenticated users should be able to access it)

  • index.html
  • styles

code in index.html

<html>
<head>
    <!-- inject:css -->
    <link rel="stylesheet" href="styles/external.min.css">
    <link rel="stylesheet" href="styles/style.min.css">
</head>
<body>
  text
</body>
</html>

Now in default.php (a layout file which is inside 'editor' view) I have added following code

<?php
require_once "content-editor/index.html"
?>

When I'm loading view it's giving 404 for external.min.css & style.min.css as it looking to find file http://dev.com/styles/external.min.css/

I want it to find this file http://dev.com/content-editor/styles/external.min.css

If I change CSS path in href to "content-editor/styles/external.min.css" then it is working fine but I don't want to make changes in index.html

2

There are 2 answers

0
Sven Bluege On

I guess you have three options here:

  • adjust the index.html file
  • load the content of the file and do a search&replace of the path instead of directly using it.
  • implement this integration in the right way. Joomla provides some editor plugins out of the box where you can check how to implement your integration.
0
Mattia Verga On

Have you tried to modify the links like

./styles/external.min.css
./styles/style.min.css