Table of Contents
{$rs.title}
回复讨论(解决方案)
Home Backend Development PHP Tutorial 关于浏览器标签显示为文章标题的问题

关于浏览器标签显示为文章标题的问题

Jun 23, 2016 pm 02:01 PM

公司一个新闻管理系统,发布新闻后打开各个页面显示的都还是一个网站名称。想修改一下打个各新闻后显示为文章标题。这也适合微信等工具传播。
谢谢之。
这是打开连接时的地址http://192.168.0.253:8088/business/index.php?m=index&a=actionClass&actype=content&fid=2&cid=2  它是通过cid=X这个来判断是打开某个文章的。

这是显示文章的模板源码

<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=9"><title><?php  echo $SITETITLE;?></title>  //就是这里修改为显示所显示文章标题<link href="[!CSS]test.css" rel="stylesheet" type="text/css"></head></html><body><div class="wrapper">  <div class="content">     <!--头部开始-->    <div class="header">      <h1><a href="[!ROOT]"><img src="/static/imghw/default1.png"  data-src="[!IMG]logo.jpg"  class="lazy"   alt="logo" /></a></h1>      <!--头部导航-->      <ul class="maniNav">        <menu id="rs" lim="10" >          <li><a href="{$rs.url}">{$rs.title} </a></li>        </menu>      </ul>      <!--头部导航结束-->       <span class="header-msg">公司文章管理系统</span> </div>    <!--头部结束-->     <!--中间开始-->    <div class="aimee-box cFloat"> </div>    <!--end aimee-box-->     <!--文章内容开始-->        <div class="text-content">      <view id="rs" cid='$cid'>        <h3 id="rs-title">{$rs.title}</h3>        <p>编辑 {$rs.aut} / {$rs.time|date="Y-m-d",###}</p>        {$rs.content} </view>    </div>        <!--文章内容结束-->     <!--中间结束-->     <!--底部开始-->     <include file="default:foother" /><!--底部结束-->   </div></div></body></html>
Copy after login



这是我打开一个文章时的效果


回复讨论(解决方案)

那就在php后台通过cid=2去数据库查询文章的标题出来 赋值给$SITETITLE传到页面就行了

{$rs.title}把这个放到的地方

{$rs.title}把这个放到的地方 不行。已经试过了。

那就在php后台通过cid=2去数据库查询文章的标题出来 赋值给$SITETITLE传到页面就行了

我通过什么方式查询到当前网页打开的cid编号呢?


那就在php后台通过cid=2去数据库查询文章的标题出来 赋值给$SITETITLE传到页面就行了

我通过什么方式查询到当前网页打开的cid编号呢?
你不是通过链接打开的吗?http://192.168.0.253:8088/business/index.php?m=index&a=actionClass&actype=content&fid=2&cid=2?
$cid = $_GET['cid'];

你说的是一种得到cid的方法,还有一种可以用substr
$Model=new Model();
$Model->query("select nr_name from ai_content where id=$_GET['cid']");

无法调出对应标题来。

还希望指点。数据ai_centent id 对应cid 要显示的标题对应rn_name

这是通过thinkphp开发的。还希望指点。谢谢。



那就在php后台通过cid=2去数据库查询文章的标题出来 赋值给$SITETITLE传到页面就行了

我通过什么方式查询到当前网页打开的cid编号呢?
你不是通过链接打开的吗?http://192.168.0.253:8088/business/index.php?m=index&a=actionClass&actype=content&fid=2&cid=2?
$cid = $_GET['cid'];

thinkphp我没用过 你看下你其他调用数据库是怎么调用的 参考下就行了 都一样的

$rs.title其实就是$rs['title']
所以<?php echo $rs['title'];?>
还不行的话绝对是你代码没遵循正常的TP框架流程走。。
其实还有一种笨方法应急。
就是用JQUERY取标题代替title中的内容
$(function(){
$('title').text($('h3').text());
})

$rs.title其实就是$rs['title']
所以<?php echo $rs['title'];?>
还不行的话绝对是你代码没遵循正常的TP框架流程走。。
其实还有一种笨方法应急。
就是用JQUERY取标题代替title中的内容
$(function(){
$('title').text($('h3').text());
})

昨天晚上和今天早上把它的thinkphp的开发文档看完了。研究了一下。确实这个没有太遵循正常框架走。看了源代码还没有找出头续。
你的第二种方法试了一下是可行的。谢谢!!

今天情急之下用了个最笨的方法,也是最简单的方法来解决,即然这段代码可以取得文章的标题、内容、发布人和发布时间,那么我为什么不用这段代码来取标题呢?!!

<div class="text-content">      <view id="rs" cid='$cid'>        <h3 id="rs-title">{$rs.title}</h3>        <p>编辑 {$rs.aut} / {$rs.time|date="Y-m-d",###}</p>        {$rs.content} </view>    </div>
Copy after login

试了一下这段代码尽然取得了文章的标题。但是不知道后继会不会对其它产功能或性能产生影响还需要测试一上。
<title><view id="rs" cid='$cid'> {$rs.title}</view></title>
Copy after login


不管怎么样,谢谢你的帮助。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Describe the SOLID principles and how they apply to PHP development. Describe the SOLID principles and how they apply to PHP development. Apr 03, 2025 am 12:04 AM

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to automatically set permissions of unixsocket after system restart? How to automatically set permissions of unixsocket after system restart? Mar 31, 2025 pm 11:54 PM

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

How to debug CLI mode in PHPStorm? How to debug CLI mode in PHPStorm? Apr 01, 2025 pm 02:57 PM

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

Explain the concept of late static binding in PHP. Explain the concept of late static binding in PHP. Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

How to send a POST request containing JSON data using PHP's cURL library? How to send a POST request containing JSON data using PHP's cURL library? Apr 01, 2025 pm 03:12 PM

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

See all articles