0

Joomla 3.x The following code is not working

unset($doc->_styleSheets[JURI::root(true).'/media/mod_languages/css/template.css']);

thank you

2 Answers 2

1

The code is correct and I tested it, it's working fine. Possibly you are running it in a plugin event after the head is rendered, or you have cached the page and the code is not really running.

In either case, try to put it at the component level, clear cache, and it should work


Update

to identify the component: turn SEF off, and look at the URL it shows as option=com_componentname; to identify the module, simply rename the modules folder, and update the site; if it works, it's a module. For plugins, rename the plugins/system and plugins/content first, then drill down until you spot it. Alternatively, but much slower, you can turn modules and plugins on and off from the backend, until you find the culprit.

Sign up to request clarification or add additional context in comments.

Comments

0

A variation which I've used with success in the past:

unset($doc->_styleSheets[$this->baseurl.'/media/mod_languages/css/template.css']);  

Update

Here's an alternate method using a module override which should work for you.

  • if it doesn't already exist, create a new directory titled html in your template's folder, ie: /templates/your-template/html/
  • inside this, create an new mod_languages folder, ie /templates/your-template/html/mod_languages/
  • copy the file from joomla-site-root/modules/mod_languages/tmp/default.php to the folder above, ie /templates/your-template/html/mod_languages/default.php
  • open this file with a text editor and around line 12 look for the line where JHtml is loading the mod_languages CSS, and comment it out.

    // JHtml::_('stylesheet', 'mod_languages/template.css', array(), true);

That's it, hopefully, this will do the trick for you.

Overriding Joomla core output using this method is safe and you won't loose your work with future Joomla updates.

More info about Joomla overrides:
https://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core

Good luck!

5 Comments

To clarify, are you adding this code to the site template or is it somewhere else?
In index.php of the template
In your template's index.php, do you have $doc = JFactory::getDocument(); before you are adding this unset?
Would an extension like JS CSS Control be an option for you? extensions.joomla.org/extensions/extension/core-enhancements/…
of course I can use extensions.joomla.org/extensions/extension/core-enhancements/… to achieve it, but I can unset everything without extra extension , only this mod_language

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.