Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any known conflicts with Joomla ? #980

Open
Black4rrow opened this issue Feb 19, 2025 · 10 comments
Open

Is there any known conflicts with Joomla ? #980

Black4rrow opened this issue Feb 19, 2025 · 10 comments

Comments

@Black4rrow
Copy link

I work on a website made with Joomla.
I'm trying to import html5-qrcode like this <script src="https://unpkg.com/[email protected]/html5-qrcode.min.js"></script>
But I get this error html5-qrcode.min.js:1 Uncaught TypeError: Cannot read properties of undefined (reading 'length')

I tested on a new project (no Joomla, just an html and js file), and it works. So it may be because of Joomla but I can't find why.

Can anyone help me ?

@ShawnStoddard
Copy link

ShawnStoddard commented Feb 19, 2025 via email

@Black4rrow
Copy link
Author

Make sure the lines you add are processed as HTML and not PHP.

What do you mean ?

@ShawnStoddard
Copy link

ShawnStoddard commented Feb 19, 2025 via email

@Black4rrow
Copy link
Author

But here is the start of my page

`<?php
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

defined('_JEXEC') or define('_JEXEC', 1);
defined('JPATH_BASE') or define('JPATH_BASE', "../../");
defined('DS') or define('DS', DIRECTORY_SEPARATOR);

require_once(JPATH_BASE . DS . 'includes' . DS . 'defines.php');
require_once(JPATH_BASE . DS . 'includes' . DS . 'framework.php');

use Anthias\Security;

$mainframe = JFactory::getApplication('site');
$mainframe->initialise();

$db = JFactory::getDbo();
$user = JFactory::getUser();

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

if (!Security::getInstance()->isLoggedIn()) {
http_response_code(403);
exit;
}
?>

<title>Scanner</title>
<link href="./espace_client/public/dist/css/stocklist.min.css" rel="stylesheet">
<link href="./espace_client/style/remixIcon/fonts/remixicon.css?d=14218" rel="stylesheet">

<script src="https://unpkg.com/[email protected]/html5-qrcode.min.js"></script>
<script src="./espace_client/scanner/quagga.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdn.datatables.net/v/bs4/dt-1.11.1/datatables.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/featherlight/1.7.13/featherlight.min.js" integrity="sha512-0UbR6HN0dY8fWN9T7fF658896tsPgnbRREHCNq46J9/JSn8GonXDZmqtTc3qS879GM0zV49b9LPhdc/maKP8Kg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="./espace_client/scanner/scanner.js"></script>
<script src="/espace_client/stocklist/stocklistJS.js"></script>
`

Is something wrong here ?

@ShawnStoddard
Copy link

ShawnStoddard commented Feb 19, 2025 via email

@Black4rrow
Copy link
Author

Black4rrow commented Feb 20, 2025

I checked, and I have a 'DOCTYPE' header in both cases (I linked some images).

So, this may not be the problem. But I'll show you my Joomla article's configuration below, can this be the problem ?

{source}
<?php

defined('_JEXEC') or define('_JEXEC', 1);
defined('JPATH_BASE') or define('JPATH_BASE', "./");
defined('DS') or define('DS', DIRECTORY_SEPARATOR);

require_once ( JPATH_BASE . DS . 'includes' . DS . 'defines.php' );
require_once ( JPATH_BASE . DS . 'includes' . DS . 'framework.php' );
require_once ( JPATH_BASE . DS . 'espace_client' . DS . 'geoloc' . DS .'stats.php' );

include JPATH_BASE. DS .'espace_client'. DS .'scanner'. DS .'scanner.php';

?>
{/source}

Also, on Joomla's Administrator, it says i'm using an old version of PHP (PHP 7.4.33), do you think it may be the cause ?

Test website :
Image

Joomla website :
Image

Maybe it's a conflict with an Joomla plug-in or extension, I'm searching the problem since yesterday and can't fin it.

@Black4rrow
Copy link
Author

I identified a problem, in my Joomla template (rt_lexicon), there is that instruction $gantry->displayHead();
When I remove it (the website if broken of course), but the error in html5-qrcode.min.js disapear and I can use it.

So now I have to figure out why.

@ShawnStoddard
Copy link

ShawnStoddard commented Feb 20, 2025 via email

@Black4rrow
Copy link
Author

I don't understand, the line is in PHP, so that can't be the problem.
Also, the website works very well, I just can't load html5-qrcode because it creates an error.
Image

@ShawnStoddard
Copy link

ShawnStoddard commented Feb 21, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants