简体   繁体   English

更改PHP生成的标题

[英]Changing title generated by PHP

I have a small PHP based directory indexor on my site. 我的网站上有一个基于PHP的小型目录索引器。 One of the templates handles the title tag as follows: 其中一个模板按以下方式处理标题标签:

<title>{info:dir}</title>

The generated title tag starts with "./" for instance "./dir1/dir2/and_so_on". 生成的标题标签以“./”开头,例如“./dir1/dir2/and_so_on”。 What I want is to get rid of the "./" at the begining. 我想要的是一开始就摆脱“ ./”。

The PHP classes are here: [removed] PHP类在这里:[已删除]

Please advice? 请指教?

Template.php, line 121, replace with Template.php,第121行,替换为

 '{info:dir}'=>(isset($dir)?preg_replace('#^\./#','',Url::html_output($dir)):''),

if it always has ./ in front you could use also 如果它总是./在前面你也可以使用

 '{info:dir}'=>(isset($dir)?substr(Url::html_output($dir),2):''),

Very hard to provide you with a proper answer without having more information. 如果没有更多信息,很难为您提供正确的答案。 However, i've provided a few basic solutions below. 但是,我在下面提供了一些基本的解决方案。

Assuming that the template engine you are using is Smarty (or something with similar syntax), you can replace the value of the title tag with the following: 假设您使用的模板引擎是Smarty(或类似语法的东西),则可以将title标记的值替换为以下内容:

<title>{info:dir|replace:'./':''}</title>

Alternatively, you can edit the template.php file and do a substr() or str_replace() on line 121. 或者,您可以编辑template.php文件并在第121行上执行substr()或str_replace()。

I recommend making the change in the html template rather than the PHP file. 我建议在html模板而不是PHP文件中进行更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM