aoepeople/aoe_sessionvars 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aoepeople/aoe_sessionvars

最新稳定版本:v0.3.2

Composer 安装命令:

composer require aoepeople/aoe_sessionvars

包简介

Capture variables coming in from outside

README 文档

README

Description

The purpose of this module is to provide a generic way to "capture" variables coming in from outside (via url parameter or cookie) and store them in the specified session, so it can be consumed by other modules from there

Authors/Contributors

Usage

On every page hit incoming variable should be evaluated and validated against the regex pattern. Then stored in the session. If a value already exist in the session and a new value is being provided then the new one should overwrite the existing one.

How it works

Add the variables in your module's config.xml which needs to be set in session

<frontend>
	<aoe_sessionvars>
		<vars>
			<var1><!-- this is the internal name of the variable that's used to store/access the value from the core/customer/checkout session -->
				<getParameterName /><!-- if empty this parameter can't be captured by url -->
				<cookieName /><!-- if empty this parameter can't be captured by cookie -->
				<validate /> <!-- Regular expression to validate the value of parameter -->
				<scope /><!-- if empty core will be used -->
				<defaultValue /><!-- fallback if parameter wasn't captured before -->
				<defaultValue_STOREID /><!-- fallback if parameter wasn't captured before. Replace the storeId with actual STORE ID -->
			</var1>
		</vars>
	</aoe_sessionvars>
</frontend>

Example:

<frontend>
	<aoe_sessionvars>
		<vars>
			<coupon_code>
				<getParameterName>cp</getParameterName>
				<cookieName>MAGENTO_CP</cookieName>
				<validate><![CDATA[/^[^$|\s+$]/]]></validate>
				<scope>customer</scope>
			</coupon_code>
		</vars>
	</aoe_sessionvars>
</frontend>

In above example, If URL contains the parameter as 'cp' or 'MAGENTO_CP' cookie is set, value of 'cp' or 'MAGENTO_CP' will be set in specified session (scope).

It also come with a concept to easily consume the session variable in CMS blocks (or other text that's processed with the template filters).

Example:

Incoming request: http://www.example.com/?lang=en-ca&country=ca

CMS content: Click here

<frontend>
	<aoe_sessionvars>
		<country>
			<getParameterName>country</getParameterName>
			<cookieName />
			<validate><![CDATA[/^[A-Za-z]{2}$/]]></validate>
			<scope />
			<defaultValue>en</defaultValue>
			<defaultValue_1>en-us</defaultValue_1>
		</country>
		<lang>
			<getParameterName>lang</getParameterName>
			<cookieName />
			<validate><![CDATA[/^([A-Za-z]{2})-([A-Za-z]{2})$/]]></validate>
			<scope />
			<defaultValue>en-us</defaultValue>
		</lang>
	</aoe_sessionvars>
</frontend>

统计信息

  • 总下载量: 562
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 37
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: OSL-3.0
  • 更新时间: 2015-08-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固