GC not working, css files missing

Hi @johnny,
I have installed a brand new CI 4.3.6 using Composer, then I followed the instructions to install GC Enterprise. I get the (in)famous message “Ooooops, something went wrong!” and I couldn’t solve the issue, although I red all the instructions and watched the Youtube explanations.

It seems that the JS files are properly loaded (which proves that I copied correctly the assets folder), but CSS files are completely missing.

Another thing that I noticed:
In the installation documentation there is a code line in the controller that seems to point to a file that does not exist:

include(APPPATH . 'Libraries/GroceryCrudEnterprise/autoload.php');

There are no other references to this file in the documentation (such as creating it manually), nor such a file is generated during the installation.

Please advise.

Hi,
normally to solve such problems is enough don’t forget to copy
/vendor/grocery-crud/enterprise/public/vendor/grocery-crud
folder to
/public/vendor/grocery-crud
in CodeIgniter progect tree.
You don’t need anything of GC-files in app/Libraries if you use composer with CI 4.3.6.
Have you installed your CI 4.3.6 via composer too?

Hi rrit,
The required assets are in place. As you may see in my screenshot above, the JS files are found by GC in public/vendor/static/js folder. The css files are also in public/vendor/gocery-crud/css folder, but GC does not load them for unknown reasons. I also checked the access rights of the respective files under the webserver. Everything looks ok.

The theme I have configured for GC is bootstrap-v5, and I can access the css file through its url: {base_url}/vendor/grocery-crud/css/bootstrap-v5/bootstrap.min.css. I am completely puzzled.

And yes, I have installed CI 4.3.6 using composer.

Thanks.

Hello Sorin
I have been struggling with the same issue for the past 2 hours. This was the fix for me: Move the script which loads the JS files just before the body close tag and it shoudl all load fine for you.

You’re right, this is how it seems to work. But only the scripts, the styling is not loaded as requested. Instead the head section of the page contains this:
<link id="gc-css-font-awesome-v5" rel="stylesheet" href="https://{base_url}/vendor/grocery-crud/icons/font-awesome-v5/css/all.min.css">
<link id="gc-css-bootstrap-v5" rel="stylesheet" href="https://{base_url}/vendor/grocery-crud/css/bootstrap-v5/bootstrap.min.css">
<style data-jss data-meta="Unthemed"> [...] </style>

They seem to be some sort of “emergency” styling injected by GC because the actual css files are not found. Although there is no error in the browser console, which means that the css file is there :slight_smile: . I know this because I put a data-source attribute to the requested css files, which is missing from the html output:
<?php foreach($css_files as $file): ?>
<link type="text/css" rel="stylesheet" data-source="requested-css" href="<?php echo $file; ?>" />
<?php endforeach; ?>

Also, in the <head> there are some additional js files loaded automatically by the GC, not by the view, probably some internal logic of the js files.

I am pretty sure it is a bug. I’m waiting for @johnny to clarify this, he would know the answer.

My header has the foreach for the foreach for the css files jjust under the charset meta, but it does not load anything as you say. However when the Crud loads and I look at the source: I get a script showing .

My guess is this is what loads the CRUD and the CSS. Now, I am using the latest Enterprise version so it may be different for you?

Hello @Aserfozo72 ,

You are right. Currently at the latest Grocery CRUD version 3, you don’t need to load the CSS files since they are getting loaded dynamically through JavaScript.

I may remove in the documentation the CSS foreach statements since they may confuse people in the future.

Does your CSS load now as expected?

Regards
Johnny

So, is not a bug, is an undocumented feature :slight_smile:

I think that more importantly is to specify in the documentation the position of the js files loading, which should be at the end of the body element. That discovery of @Aserfozo72 was the trick that made it work.

1 Like

Hi, yes everyting is working as it supposed to. Thank You.

1 Like

Yes everything is working as expected. I want to update the documentation with those details and also make sure that people are using the Wizard since it seems very helpful from the feedback that I have. In case you don’t know what I mean this is the URL for the Wizard: Grocery CRUD Enterprise installation wizard

It has been proven a better step by step guidance than the one that we currently have in the website.

Thank you by the way for your valuable feedback :hugs:

Regards
Johnny