ShopEx customSchema 定制可以根据客户的需求对网站进行相应功能的添加修改或者删除
生活随笔
收集整理的這篇文章主要介紹了
ShopEx customSchema 定制可以根据客户的需求对网站进行相应功能的添加修改或者删除
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
站內錨文本制作 1.修改config.php,在文件末尾加入以下內容
define('CUSTOM_CORE_DIR',BASE_DIR . '/custom'); 2.增加custom文件夾(與core同目錄),再新建文件夾 include ,并新建文件 customSchema.php 增加內容如下
<?php
$cusmenu['tools'] = array(
'items'=>array(
array(
'type'=>'group',
'label'=>'站內錨文本',
'position'=>'after|begin|end|before',
'reference'=>'工具箱',
'items'=>array(
array(
'type'=>'menu',
'label'=>'錨文本管理',
'link'=>'index.php?ctl=custom/anchor&act=anchorList'
)
)
)
)
);
?> 3.新建控制器文件 ctl.anchor.php 4.新建模型文件 mdl.anchor.php 5.修改文章控制器 ctl.article.php 修改以下代碼
$this->pagedata['article']['content'] = implode('',$tmpContent); 為以下代碼
/*
**錨文本自動替換功能
**注意:如果確實包含字符但又沒成功替換,請注意頁面編碼問題
**如果有必要的話,您可以自定義樣式來突出顯示錨點內容,如 .anchor{color:red;}
*/
$tmpContent = implode("",$tmpContent);
$anchorObj = &$this->system->loadModel('custom/anchor');
$anchor = $anchorObj->getAnchorList();
$j = 0;
for($i = 0;$i<count($anchor);$i++){
if($j >= 5){break;}
$anchorName = trim($anchor[$i]['name']);
$anchorUrl = trim($anchor[$i]['url']);
if(strpos($tmpContent,$anchorName) !== false){
$str = "<a href='". $anchorUrl ."' target='_blank' class='anchor'>". $anchorName ."</a>";
$tmpContent = preg_replace('/'. $anchorName .'/',$str,$tmpContent,1);
$j++;
}
}
$this->pagedata['article']['content'] = $tmpContent; 完整實例,可點擊這里下載:
站內錨文
總結
以上是生活随笔為你收集整理的ShopEx customSchema 定制可以根据客户的需求对网站进行相应功能的添加修改或者删除的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: DISCUZ 品牌空间恼人的游客评论名称
- 下一篇: Apache htaccess的简单总结