[英]Joomla component rendering view <head> to <body>
我已經創建了一個要在Joomla中使用的組件,並且在使用自定義主題時似乎出現了問題。 主頁可以完美運行,但進入組件視圖時,似乎會將應放在首位的內容移動到了body標簽。 我已經嘗試過使用默認主題,但它似乎可以正常工作,因此我非常有信心這是我個人主題的問題。
<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
JHtml::_('jquery.framework');
$doc = JFactory::getDocument();
$doc->addStyleSheet('templates/' . $this->template . '/css/bootstrap.css');
$doc->addStyleSheet('templates/' . $this->template . '/css/style.css');
$doc->addScript('templates/' . $this->template . '/js/bootstrap.js', 'text/javascript');
$doc->addScriptDeclaration (" jQuery('.carousel').carousel({
pause: 'false'
});");
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>" >
<head>
<jdoc:include type="head" />
</head>
<body>
<div class="container-fluid">
<div class="row">
<div id="backspinner">
<div id="back-carousel" class="carousel slide carousel-fade" data-ride="carousel">
<div class="carousel-controls">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#back-carousel" data-slide-to="0" class="active"></li>
<li data-target="#back-carousel" data-slide-to="1"></li>
</ol>
</div>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="/templates/sheffieldford/images/back1.jpg" class="backimage">
<div class="carousel-caption">
...
</div>
</div>
<div class="item">
<img src="/templates/sheffieldford/images/back2.jpg" class="backimage">
<div class="carousel-caption">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-2" id="headleft"></div>
<div class="col-md-8" id="head">
<div class="boundingbox">
<div class="row">
<div class="col-md-2 col-md-offset-1">
<img src="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template;?>/images/fordlogo.png" id="logo" class="fordlogo">
</div>
<div class="col-md-2 col-md-offset-2">
<a href="/"><img src="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template;?>/images/logo.png" alt="Logo" id="logo"/></a>
</div>
<div class="col-md-3 col-md-offset-2" id="callbox">
<div id="callboxtext">
<?php
$article = JControllerLegacy::getInstance('Content')->getModel('Article')->getItem(2);
echo $article->introtext;
?>
</div>
</div>
</div>
</div>
<div class="row">
<div class="centered-pills">
<jdoc:include type="modules" name="navigation" />
</div>
</div>
</div>
<div class="col-md-2" id="headright"></div>
</div>
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="boundingbox">
<jdoc:include type="component" />
</div>
</div>
</div>
<div class="row footerrow" id="footer">
<div class="col-md-8 col-md-offset-2 col-xs-10 col-xs-offset-1">
<div class="boundingbox">
<div class="row" style="margin:0px;">
<div class="col-md-6">
<div class="row">
<div class="col-md-4 footercolumn">
<h3>Accident Repairs</h3>
<ul>
<li>Ford Accident Management</li>
<li>Accident Repairs</li>
<li>Smart Repairs</li>
<li>Dentals Paint Removal</li>
</ul>
</div>
<div class="col-md-4 col-md-offset-2 footercolumn">
<h3>Vehicle Servicing</h3>
<ul>
<li>Ford Blue Service</li>
<li>Service Plans</li>
<li>Ford Warranty</li>
<li>Special</li>
</ul>
</div>
</div>
<div class="row footerrow hidden-xs hidden-sm">
<div class="col-md-4 footercolumn" >
<img src="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template;?>/images/footerlogo.png" class="infoimage footerlogo"/>
</div>
<div class="col-md-4 footercolumn" >
<img src="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template;?>/images/motalogo.png" class="infoimage footerlogo" style="margin-top: 11px;"/>
</div>
<div class="col-md-4 footercolumn" style="margin-top: 6px;">
<div class="footerimg">
<a href="https://www.facebook.com/clarkandpartners" target="_blank"><img src="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template;?>/images/facebook.png" style="display: block;
float: left;"/></a>
<span class="spacer"></span>
<a href="https://twitter.com/clark_partners" target="_blank"><img src="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template;?>/images/twitter.png" style="display: block;
float: left;"/></a>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="col-md-4 col-md-offset-2" id="contactdetails">
<a href="#">Special Offers</a></br>
<a href="#">Ford Warranty</a></br>
<a href="#">About Us</a></br>
<a href="#">Customer Reviews</a></br>
<a href="#">Adaptations</a></br>
<a href="#">News</a></br>
<a href="#">Contact Us</a></br>
</div>
<div class="col-md-6" id="contactdetails">
<?php $article = JControllerLegacy::getInstance('Content')->getModel('Article')->getItem(3);
echo $article->introtext;?>
</div>
</div>
<div class="row footerrow hidden-md hidden-lg">
<div class="row">
<div class="col-xs-6 col-xs-offset-3 footerimgxs">
<a href="https://www.facebook.com/clarkandpartners" target="_blank"><img src="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template;?>/images/facebook.png"/></a>
<a href="https://twitter.com/clark_partners" target="_blank"><img src="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template;?>/images/twitter.png"/></a>
</div>
</div>
<div class="row">
<div class="col-xs-8 col-xs-offset-2 footercolumn" >
<div class="row footerimgxslogo">
<img src="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template;?>/images/footerlogo.png"/>
</div>
<div class="row footerimgxslogo">
<img src="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template;?>/images/motalogo.png"/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
我已經准備好其他人已經解決了將具有BOM的編碼更改為UTF8的問題,但是這似乎並沒有改變我的任何東西。
假設這是您的自定義模板index.php文件,那么問題是如何將站點組件合並到模板中。 當您應該使用Joomla的語句時,您正在手動實例化和呈現組件視圖。
交換此代碼:
<?php $article = JControllerLegacy::getInstance('Content')->getModel('Article')->getItem(3);
echo $article->introtext;?>
對於:
<jdoc:include type="component" />
您的組件應該正確呈現。 實際上,存在許多Joomla集成問題,這些問題只會進一步阻止從管理員儀表板正確管理您的內容。 菜單,登錄,警報和調試等部分均使用模塊分配。
如果您尚未簽出index.php的核心模板之一,我將對其進行審查。 還附加了有關創建Joomla模板的文檔鏈接。
祝好運!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.