ecmall插件开发可以使用的钩子

可以通过搜索包含”_hook”的php文件找到

ecmall hook

可以看到可以使用的钩子有

on_load_adminmenu

after_opening

after_register

on_run_action

end_run_action

on_display

end_display

Posted in php | Tagged | 1 Comment

apache和nginx去除index.php

需求:网站首页统一url
apache

RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC]
RewriteRule ^index\.php(.+) $1 [R=301,L]

nginx添加到location里面

if ($request_uri = /index.php) {
   rewrite ^  http://$host? permanent;
}
Posted in linux | Tagged | Leave a comment

gocart 自定义url实现原理

gocart 自定义url实现原理,可以借鉴下使用到自己的CI项目中, 后台添加分类和产品的slug后可以看到数据库如下:

id   slug          route
 1   girls_jeans   cart/category/1
 2   smal_jeans    cart/category/2
 3   slug          cart/product/1

产品的路由形式为:

$route['slug'] = "cart/product/1";

分类的路由为下面的形式:

$route['girls_jeans/(:num)'] = "cart/category/1/$1";
$route['smal_jeans/(:num)'] = "cart/category/2/$1";

分类的路由是考虑到分页的数字 从上面需求分析可以在gocart/config/routes.php找到实现的代码 主要代码片段如下:

while($row = mysql_fetch_array($routes))
{
	//if "category" is in the route, then add some stuff for pagination
	if(strpos($row['route'], 'category'))
	{
		$route[$row['slug']] = $row['route'];

		$row['slug'] 	.= '/(:num)';
		$row['route'] 	.= '/$1';
	}

	$route[$row['slug']] = $row['route'];
}
Posted in php | Tagged | Leave a comment

dedecms当前栏目ID调用

dedecms系统调用当前栏目ID

{dede:type}[field:ID /]{/dede:type}

应用实例:
栏目页调用RSS地址
代码如下:

<a href="{dede:global.cfg_basehost/}/data/rss/{dede:type}[field:ID /]{/dede:type}.xml">RSS</a>
Posted in php | Tagged | 1 Comment

dedecms 文章页面添加本文链接

dedecms添加类似转载请注明本文地址之类的链接,也许对seo有一定帮助
只需要在文章模板添加代码:

转载请添加本文链接:<a href="{dede:global.cfg_basehost/}{dede:field name='arcurl' /}">{dede:global.cfg_basehost/}{dede:field name='arcurl' /}</a>
Posted in php | Tagged | Leave a comment