gpt4 book ai didi

javascript - 为什么方法 addStyleSheet 不会将我的 css 文件添加到我在 joomla 3.4 中的网页

转载 作者:行者123 更新时间:2023-11-28 06:37:14 26 4
gpt4 key购买 nike

我想通过以下来源将 cssjs 文件添加到我的模板 joomla3.4:但是,当我运行 joomla temp 时,在 fire fox view source 网页中,bootsrap 和 js 文件在源中不存在 并且我的 temp 没有 bootstap 和 js 文件,可以吗帮帮我?

<html>
<head>
<meta charset="UTF-8">
<title>mymagazine</title>
<?php

defined('_JEXEC') or die;

$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$user = JFactory::getUser();
$this->language = $doc->language;
$this->direction = $doc->direction;

// Getting params from template
$params = $app->getTemplate(true)->params;

// Detecting Active Variables
$option = $app->input->getCmd('option', '');
$view = $app->input->getCmd('view', '');
$layout = $app->input->getCmd('layout', '');
$task = $app->input->getCmd('task', '');
$itemid = $app->input->getCmd('Itemid', '');
$sitename = $app->get('sitename');

if($task == "edit" || $layout == "form" )
{
$fullWidth = 1;
}
else
{
$fullWidth = 0;
}

// Add JavaScript Frameworks
JHtml::_('bootstrap.framework');
$doc->addScript($this->baseurl . '/templates/' . $this->template . '/js/template.js');

// Add Stylesheets
$doc->addStyleSheet($this->baseurl . '/templates/' . $this->template . '/css/bootstrap.min.css');

// Load optional RTL Bootstrap CSS
JHtml::_('bootstrap.loadCss', false, $this->direction);

// Adjusting content width
if ($this->countModules('position-7') && $this->countModules('position-8'))
{
$span = "span6";
}
elseif ($this->countModules('position-7') && !$this->countModules('position-8'))
{
$span = "span9";
}
elseif (!$this->countModules('position-7') && $this->countModules('position-8'))
{
$span = "span9";
}
else
{
$span = "span12";
}

// Logo file or site title param
if ($this->params->get('logoFile'))
{
$logo = '<img src="' . JUri::root() . $this->params->get('logoFile') . '" alt="' . $sitename . '" />';
}
elseif ($this->params->get('sitetitle'))
{
$logo = '<span class="site-title" title="' . $sitename . '">' . htmlspecialchars($this->params->get('sitetitle')) . '</span>';
}
else
{
$logo = '<span class="site-title" title="' . $sitename . '">' . $sitename . '</span>';
}
?>

我的结果在这里:

<html>
<head>
<meta charset="UTF-8">
<title>mymagazine</title>


</head>
<body>
<div class="page-header"><h1>web design</h1></div>

</body>
</html>

最佳答案

回复在这里:

http://www.inmotionhosting.com/support/edu/joomla-3/create-template/add-css-and-js

<?php

$doc = JFactory::getDocument();

$doc->addStyleSheet('templates/' . $this->template . '/css/style.css');
$doc->addScript('/templates/' . $this->template . '/js/main.js', 'text/javascript');

?>

尽量不要在函数中使用:$this->baseurl:addStyleSheetaddScript

关于javascript - 为什么方法 addStyleSheet 不会将我的 css 文件添加到我在 joomla 3.4 中的网页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34564851/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com