Adding javascript to the top of the Joomla website

I looked through some Joomla tutorials and I don’t understand how Joomla works. I have never come across something where every aspect of it shies away from me. I am not asking for a free ride ... just where to go, or a basic idea of ​​how it works.

I just need to add javascript Panoramio to <head></head>the joomla website section . In Word Press, I just load the header.php template and code.

This is such a confusing understanding of Joomla. I know that I don’t embed directly on the "Article" page, so I need to install some kind of extension or tool to even make it work?

I read index.php for editing in my templates, but I can't even find it. Am I the only person who cannot understand Joomla at all? Even the beginner documentation seems to know their system. Thank you in advance.

+5
source share
6 answers

Be careful what files you add code to. Editing core files, such as index.php in the templates folder, may not be the best solution. What if the template update? The file will be overridden. So just think about it.

Before adding a script, it is advisable to get the name of the current template:

$app = JFactory::getApplication();
$template = $app->getTemplate();

You .jscan use the following tags to import a file <head>:

$doc = JFactory::getDocument(); //only include if not already included
$doc->addScript(JUri::root() . 'templates/' . $template . '/file.js');

or you can add Javascript there, and then like this:

$doc = JFactory::getDocument();
$js = "
       //javascript goes here
      ";
$doc->addScriptDeclaration($js);

Hope this helps

+6
source

. Joomla , , , .

script index.php , , , . , . , Joomla, !

Joomla ( Joomla) . . , , , index.php. , header.php Wordpress. script .

, , Extensions- > Template Manager . . "" "". , , .

0

, :

  • Joomla! /templates ( )
  • index.php( )
  • html- PHP
  • <head>

:

$doc->addScript($this->baseurl.'/templates/'.$this->template.'/javascript/YOURSCRIPT.js', 'text/javascript');

, :

$doc = JFactory::getDocument();

: , Joomla! , , Joomla! 2.5, LTS.

P.S. script "" <head>.

0

index.php css ..

: - >

TAB

: " ". .

Joomla, .

0

JavaScript, AJAX, . , JavaScript , . , , .

1) - >

2) . JavaScript ()

3) "" " ", " ", " " " "

4) < script type = "text/javascript" src= "http://yourdomain.com/yourscript.js" > </script>

, , - (, Google Analytics), .

0

Joomla is very different from Wordpress. Index.php is actually useless when setting up the joomla template. You will need to examine the blocks of the template in the blocks of folders found in your template. For example, to add scripts to the header, simply edit header.php in the directory your_template / blocks.

-1
source

All Articles