[solved] $doc->addScript does not work in layout templates

More
12 years 5 months ago - 12 years 5 months ago #39388 by hede
In item.php I substituted this:
Code:
JFactory::getDocument()->addStyleSheet(...
with
Code:
$document = JFactory::getDocument(); $document->addStyleSheet(...
Why does my solution not work? cheers

FF on Win10, FLEXIcontent version 3.0.10 on Joomla 3.4
Last edit: 12 years 5 months ago by hede.

Please Log in or Create an account to join the conversation.

More
12 years 5 months ago #39389 by ggppdk
Hello,

i guess you mean, item.php of a FLEXIcontent template ...

there is no real reason why this will not work, since this is a call made BEFORE the HTML head is created, (after it is created you can only add things to header via get HTML source and making a regular expression replacement)

Reasons for not work
e.g. you have this code inside an IF statement and you have full page caching enabled

e.g. you have this code inside an IF statement and IF statement is not entered

e.g. you edit wrong item.php (don't take this wrongly it has happened to me too, but i am sure you checked this)

e.g. a system plugin is removing your code

e.g. it is there but your CSS rule are wrong

anyway
this is not a FLEXIcontent related question


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

More
12 years 5 months ago #39392 by hede
Thanks! That is very strange since this is only a substitution I thought ...

i guess you mean, item.php of a FLEXIcontent template ...

correct.
What I am actually trying to do is getting the language of the current page with:
Code:
<?php echo JFactory::getDocument()->language;?>
... but this interferes with your statements at the top of the file (they dont work any longer when I add my statement) and that is why I tried the $document version. So now I am stuck. Any idea how I could solve this? cheers

FF on Win10, FLEXIcontent version 3.0.10 on Joomla 3.4

Please Log in or Create an account to join the conversation.

More
12 years 5 months ago #39394 by ggppdk
Hello

i test this code and it works?

what "exactly" do you get , an error message, a blank page what?


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

More
12 years 5 months ago #39398 by hede
You are right, it works in 2.1.0 but it does not work in 2.0.2. I realized that some minutes ago when I updated to 2.1.0.

The error was that your css and script were not included anymore.

cheers

FF on Win10, FLEXIcontent version 3.0.10 on Joomla 3.4

Please Log in or Create an account to join the conversation.

More
12 years 5 months ago #39400 by ggppdk
Hello

i just must mention this that there is no reason why it will not work with v2.0.2,

but you have not answered my question, when you say it does not work?
you get a PHP fatal error?
you get a blank page ? other error?


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

More
12 years 5 months ago #39401 by hede
I did nothing else than upgrading, so Im pretty sure there is a difference in the new version.

I thought this answered your question:

The error was that your css and script were not included anymore.

Apart from that no error.

FF on Win10, FLEXIcontent version 3.0.10 on Joomla 3.4

Please Log in or Create an account to join the conversation.

More
12 years 5 months ago #39402 by ggppdk
Hello

what is files are not included?

what do you mean not include, you checked the HTML page source and they are not there OR the CSS are not applied?

maybe there was a JS error in v2.0.2, but this may cause JS code not to be executed but it will not prevent files for being included in the header,

in short FLEXIcontent version could never prevent CSS / JS from being included in the HTML header, and you have not answered me if you viewed the page source, also i ask for doing "view page source" because IE will not use more than 32 CSS files


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

More
12 years 5 months ago #39403 by hede
"not included" means that those two lines were not executed:
Code:
JFactory::getDocument()->addScript( JURI::base().'components/com_flexicontent/assets/js/tabber-minimized.js'); JFactory::getDocument()->addStyleSheet(JURI::base().'components/com_flexicontent/assets/css/tabber.css');
I cant do any debugging anymore on 2.0.2 now since I upgraded already to 2.1.0 and the new version works as expected.

cheers

FF on Win10, FLEXIcontent version 3.0.10 on Joomla 3.4

Please Log in or Create an account to join the conversation.

More
12 years 5 months ago #39408 by ggppdk
Hello,

anyway the addStyleSheet() cannot depend on FLEXIcontent version, you have made some other mistake here, it just add something to a PHP array that is later used to add the array content to HTML head


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Save