【问题标题】:How to make a separate Title for Home page? (title tag)如何为主页制作单独的标题? (标题标签)
【发布时间】:2013-02-01 14:04:46
【问题描述】:

我有这个网站,index.php 与 html 合并,我需要为主页设置单独的标题(标题标签),但是每当我将主页名称添加到 index.php 页面时,它都会改变网站上的所有页面都以该名称命名。我正在使用 Joomla 1.5...

这是代码部分:

<head>

<title> Home Page Title </title>

<jdoc:include type="head" />

<?php JHTML::_('behavior.mootools'); ?>

<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/template.css" type="text/css" />

<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/menu.css" type="text/css" />

<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/style.css" type="text/css" />

<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/slideshow.css" type="text/css" />

<script language="javascript" type="text/javascript" src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/js/vns.script.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/js/mootools.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/js/toptool.js"></script>


<!--[if lte IE 6]>

<script type="text/javascript">

var siteurl = '<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/';



window.addEvent ('load', makeTransBG);

function makeTransBG() {

    fixIEPNG ($$('#toptools ul li a'), '', 'crop', 0, 0);

    fixIEPNG ($$('#nav_all ul.menu li ul'), '', 'scale', 0, 0);

    fixIEPNG($$('img'));



}

</script>

<style type="text/css">

#hd p.buttonheading {

    margin:8px 0;

}

#nav_all ul.menu ul a {

    width: 14.8em!important;

}



</style>

<![endif]-->





<style type="text/css">

body{

    font-size: <?php echo $vnsfont = $this->params->get ("vnsfont"); ?>px;

}

</style>



<?php if ($vnsshowcopyright = $this->params->get('showcopyright') == 'yes') { ?>

<style type="text/css">

#cpr{

    display:block;

}

</style>

<?php }else{ ?>

<style type="text/css">

#cpr{

    display:none;

}

</style>

<?php } ?>



<?php if ($vnsshowcomponent = $this->params->get('showcomponent') == 'yes') { ?>

<style type="text/css">

#component{

    display:block;

}

</style>

<?php }else{ ?>

<style type="text/css">

#component{

    display:none;

}

</style>

<?php } ?>

<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/sosdmenu.css" type="text/css" />

<?php if ($vnsmenu = $this->params->get('vnsmenu') == 'moo') { ?>

<script language="javascript" type="text/javascript" src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/js/vns.moomenu.js"></script>

<?php }else{ ?>

    <?php if ($vnsmenu = $this->params->get('vnsmenu') == 'css') { ?>

        <script language="javascript" type="text/javascript" src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/js/vns.cssmenu.js"></script>

    <?php }else{ ?>



    <? } ?>

<? } ?>



<?php if ($vnsmenu = $this->params->get('vnsmenu') == 'none') { ?>

<style type="text/css">

#nav_all{

    display: none;

}

</style>

<?php  }?>



<?php if ($this->countModules('left')==0)  : ?>

<style type="text/css">

#ccenter {

    width:716px;

}

</style>

<?php endif; ?>

<?php if ($this->countModules('right')==0)  : ?>

<style type="text/css">

#ccenter {

    width:734px;

}

</style>

<?php endif; ?>

<?php if (($this->countModules('right')==0)&&($this->countModules('left')==0))  : ?>

<style type="text/css">

#ccenter {

    width:935px;

}

</style>

<?php endif; ?>



</head>

【问题讨论】:

  • 您是否正在为所有页面使用模板?

标签: php html css joomla1.5


【解决方案1】:

由于您使用的是Joomla 1.5,请登录到您的后端,找到主页菜单项(带有星号的菜单项),并在其右侧的属性中设置页面标题

【讨论】:

  • 在说什么?页面标题是文章的标题,而不是网页....你知道在网络浏览器的顶部,html中的标题标签
  • 菜单设置下的页面标题(在菜单管理器中)正好是html中的标题标签,而不是文章的标题。当然,除非您的模板是以非常非标准的方式编写的...
  • 哦,我的误解.....是的,它有效!我想我应该关闭这个线程....谢谢 Marko D
【解决方案2】:

你为什么不创建一个脚本来做这样的事情:

<?php $pages = array( 'index', 'test' ); $thispage = basename($_SERVER['PHP_SELF'], ".php");
if(in_array($thispage,$page)) { $titles = array( 'index' => 'Home Page', 'test' => 'Test Page' ); $title_final = $titles[$thispage]; } else { $title_final = 'Unknown Page'; }
?>

现在是页面部分:

<html><head><title><?php echo $title_final; ?></title></head><body>blablabla</body></html>

【讨论】:

  • 所以我将该脚本添加到 标记中还是什么?
猜你喜欢
  • 2014-10-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-28
  • 2014-06-21
  • 1970-01-01
相关资源
最近更新 更多