【问题标题】:How to modify an existing Joomla template to Joomla 3.x template?如何将现有的 Joomla 模板修改为 Joomla 3.x 模板?
【发布时间】:2014-04-11 08:37:21
【问题描述】:

我是 Joomla 的初学者! 我必须将 Joomla 2.5.x 版本的站点升级到最新版本的 Joomla。 我检查了 2.5.19 版所有现有组件/模块/插件的兼容性,它们在 Joomla 3.x 中都兼容。 唯一的问题是模板。 我只是不知道如何进行以及从哪里开始修改它。

这是我的 templateDetails.xml 中的一些行:

<extension version="2.5" type="template" client="site">
    <name>Harpo</name>
    <version>1.0.0</version>
...
<files>
        <filename>index.php</filename>
        <folder>css/</folder>
        <folder>images/</folder>
        <filename>templateDetails.xml</filename>
        <filename>error.php</filename>
    </files>
    <images>
        <filename>template_thumbnail.png</filename>
    </images>
...
<positions>
        <position>newsflash</position>
        <position>hornav</position>
        <position>breadcrumbs</position>
        <position>banner</position>
        <position>left</position>
        <position>right</position>
        <position>top</position>
        <position>user1</position>
        <position>user2</position>
        <position>user3</position>
        <position>user4</position>
        <position>user5</position>
        <position>footer</position>
        <position>syndicate</position>
        <position>debug</position>
    </positions>

</extension>

这是我的 index.php 文件中的一些行:

<head>
<link rel="shortcut icon" href="<?php echo $app->getCfg( 'live_site' ); ?>templates/<?php echo $this->template ?>/images/favicon.ico"/>
<meta http-equiv="Content-Type" content="text/html;" />
<link href="<?php echo $app->getCfg( 'live_site' ); ?>templates/<?php echo $this->template ?>/css/template_css.css" rel="stylesheet" type="text/css" media="all"/>
<!-- <link href="css/template_css.css" rel="stylesheet" type="text/css" media="all"/> -->
<jdoc:include type="head" />
<meta name="verify-v1" content="PynT0gVSXBh484xuIjQakd0YZS+sHAYmOK+CRTa1aJI=" />
<script type="text/javascript" src="<?php echo $app->getCfg( 'live_site' ); ?>templates/<?php echo $this->template ?>/flashobject.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>
<script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-32944659-1']);
    _gaq.push(['_trackPageview']);

    (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
     })();

    jQuery.noConflict();
...
...
...
<body>
<div class="out">
    <div class="main">
    <!--Toparea Start-->
        <div class="top">
          <div class="logo_space">
              <div class="boxlogin"><jdoc:include type="modules" name="user2" /></div>
          </div>
          <div class="header">
            <img src="<?php echo $app->getCfg( 'live_site' ); ?>templates/<?php echo $this->template ?>/images/img_header.jpg" alt="sfondo_header" align="top" style="float:left;"  />
            <div id="flash" style="float:right; width:550px; height:132px;"></div>
            <script type="text/javascript">
                var fo = new FlashObject("<?php 
                    $flashPath = $app->getCfg( 'live_site' )."templates/".$this->template."/flash/animazione.swf";
                    echo $flashPath; 
                ?>", "Menu", "550", "132", "8", "#FFFFFF", "transparent");
                fo.write("flash");
            </script>

            <!-- <img src="<?php echo $app->getCfg( 'live_site' ); ?>templates/<?php echo $this->template ?>/images/img_headerright.jpg" alt="sfondo_header" align="top" style="float:right;" width="550" height="132"  /> -->
            <!-- <div class="boxlogin"></div> -->
        </div>

        <div class="topmenu">
            <?php if ($this->countModules( "top" )) { ?>
                <jdoc:include type="modules" name="top" />
            <?php } ?>
        </div>
    </div>
...
...
...

欢迎提出任何建议!

【问题讨论】:

  • 您究竟需要在模板中更新什么?在不知道任何细节的情况下很难说。可能有多个代码 sn-ps 需要更改或可能什么都不更改
  • 正如@Lodder 所说,可能有多个代码 sn-ps 需要更改或可能没有。几周前,我更新了一个 Joomla 网站,但我遇到了一些组件的问题,但该模板就像一个魅力。因此,您应该做的是更新站点(如果需要,在测试环境中),并解决您可能遇到的任何特定错误(如果有)。
  • 我已经编辑了我的问题......正如我所说,我只是不知道从哪里开始以及首先检查什么......我还尝试升级网站,后端部分是好的,但是前端显示错误
  • 你需要修改你的CSS,你的索引应该没问题。

标签: php templates joomla joomla3.0


【解决方案1】:

好的,看了你的代码,这里有一些东西。

首先,您的 XML 文件很好,不需要任何更改。

要在 noConflict 模式下导入 jQuery 并确保只执行一次,你应该替换这个:

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>

用这个:

JHtml::_('jquery.framework'); // this is PHP so wrap it in PHP tags

完成后,您可以删除此代码:jQuery.noConflict();

要从 configuration.php 文件中获取值,请不要使用 $app-&gt;getCfg(),因为它已被弃用。请改用$app-&gt;get()。所以在你的情况下,替换这个:

$app->getCfg('live_site')

有了这个

$app->get('live_site');

除此之外,我没有发现代码有任何其他问题。

【讨论】:

  • 我刚刚做了你建议的更改,但我得到了“500 - JHtmlBehavior::mootools not found”
  • 啊,我没有在你的问题中看到该代码,将代码中的那一行替换为JHtml::_('behavior.framework')
  • OK 通过替换 JHtmlBehavior::mootools(); 解决了这个问题;与 JHtml::_('behavior.framework');
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-10-17
  • 2018-05-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-10-08
  • 1970-01-01
相关资源
最近更新 更多