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

More
11 years 3 months ago - 11 years 3 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: 11 years 3 months ago by hede.

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

More
11 years 3 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...

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

More
11 years 3 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
11 years 3 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...

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

More
11 years 3 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
11 years 3 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...

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

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.424 seconds
Save
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