将javascript添加到Joomla网站的负责人 [英] Adding javascript to head of Joomla website

查看:61
本文介绍了将javascript添加到Joomla网站的负责人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了一些Joomla教程,我不了解Joomla的工作原理。我从来没有遇到过它的每一个方面都逃避我的事情。我不是要求免费乘车..只是去哪里或基本了解这是如何工作的。

I have gone through some Joomla tutorials and I am not understanding how Joomla works. I have never encountered something where every aspect of it evades me. I'm not asking for a free ride.. just where to go or a basic idea of how this works.

我只需将Panoramio javascript添加到< head>< / head> 部分joomla网站。在Word Press中,我只需下载header.php模板和代码。

I simply need to add a Panoramio javascript into the <head></head> section of a joomla website. In Word Press I simply download the header.php template and code away.

了解Joomla令人困惑。我知道不要直接粘贴到文章页面,所以我必须安装某种扩展或工具,甚至让它工作?

It's so confusing understanding Joomla. I do know not to paste directly into an "Article" page so do I have to install some sort of extension or tool to even get this to work?

我在模板中阅读编辑index.php,但我甚至找不到。我是唯一一个根本无法理解Joomla的人吗?即使是初学者文档似乎也假设我知道他们的系统。提前谢谢。

I read to edit the index.php in my templates but I can't even find that. Am I the only person that can't understand Joomla at all? Even the beginner documentation seems to assume I know their system. Thank you in advance.

推荐答案

请注意添加代码的文件。编辑模板文件夹中的index.php等核心文件可能不是最佳解决方案。如果有模板更新怎么办?该文件将被覆盖。所以请记住这一点。

Be careful about which files you add code to. Editing core files like the index.php in the templates folder might not be the best solution. What if there is a template update? The file will get overridden. So just bare that in mind.

在添加脚本之前,最好先获取当前模板的名称:

Before you add the script, it is good idea to get the name of current template:

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

您可以使用以下内容导入 .js 提交< head> 标签:

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

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

或者您可以在那里添加Javascript然后如下:

or you can add the Javascript there and then like so:

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

希望这会有所帮助

这篇关于将javascript添加到Joomla网站的负责人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆