如何在ExpressionEngine 2的浏览器标题栏中自动显示条目/文章的标题? [英] How to automatically show Title of the Entries/Articles in the Browser Title Bar in ExpressionEngine 2?

查看:55
本文介绍了如何在ExpressionEngine 2的浏览器标题栏中自动显示条目/文章的标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在ExpressionEngine中输出条目的标题并将其显示在浏览器的标题栏中?

How would I output the title of an entry in ExpressionEngine and display it in the browser's title bar?

这是我页面标题的内容:

Here is the content of my page's header:

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Test Site</title>
    <link rel="stylesheet" href="{stylesheet=site/site_css}" type="text/css" media="screen" />
</head>

我需要的是每个页面在浏览器的标题栏中显示条目的标题—.我该如何实现?

What I need is for each page to display the title of the entry in my browser's title bar — how can I achieve that?

这是我的操作方式:

{exp:channel:entries channel="news_articles" status="open|Featured Top Story|Top Story" limit="1" disable="member_data|trackbacks|pagination"}

{embed="includes/document_header" page_title=" | {title}"}

<body class="home">
<div id="layoutWrapper">
    {embed="includes/masthead_navigation"}
    <div id="content">
        <div id="article">
            <img src="{article_image}" alt="News Article Image" />
            <h4>{title}</h4>
            <h5><span class="by">By</span> {article_author}</h5>
            <p>{entry_date format="%M %d, %Y"} -- Updated {gmt_edit_date format="%M %d, %Y"}</p>                    
            {article_body}    
{/exp:channel:entries}
        </div>

您怎么看?

推荐答案

如果只想显示ExpressionEngine网站的名称(如CP Home> Admin> General Configuration中所定义),请使用

If you want to show just the name of your ExpressionEngine site (as defined in CP Home > Admin > General Configuration) use the site name global variable:

<title>{site_name}</title>

如果您只想显示给定频道中的当前条目标题,请使用以下命令:

If you want to display just the current entry title from a given channel use the following:

<title>
    {exp:channel:entries channel="channel_name" limit="1" dynamic="yes"}
        {title}
    {/exp:weblog:entries}
</title>

许多Web开发人员将使用带有嵌入式模板的嵌入变量来传递` {entry_title}到全局嵌入模板,以允许动态页面标题:

Many Web Developers will use an Embed Variable with an Embedded Template to pass the `{entry_title} to a global embed template, allowing for a dynamic page title:

{embed="includes/header" title="{exp:channel:entries channel="{channel_name}"}{title}{/exp:channel:entries}"}

如果您使用的是EE2,则 SEO Lite模块会处理所有问题只需一行代码即可为您完成辛苦的工作:

If you're using EE2, the SEO Lite Module takes care of all the hard work for you with a single line of code:

<html lang="en">
<head>
    <meta charset="utf-8" />
    {exp:seo_lite url_title="{url_title}"}
</head>

其他解决方案包括低标题插件 (EE1,EE2).

这篇关于如何在ExpressionEngine 2的浏览器标题栏中自动显示条目/文章的标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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