Joomla获取在URL中传递的变量 [英] Joomla getting Variables passed in URL

查看:66
本文介绍了Joomla获取在URL中传递的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当它们传递到我们的网站时,我正在尝试从Joomla中的URL字符串中提取值.一个例子是:

?source = SEARCH%20& utm_source = google& utm_medium = cpc& utm_term =& utm_content = {creative}& utm_campaign =& cpao = 111& cpca =& cpag =& kw =

因此,我将希望抓取VAR = utm_source,utm_medium等.

我想在网站上保留这些值,并至少保留到访问者点击提交到表单上为止,以便将这些值与表单一起传递以跟踪这些区域,以查看它们来自何处,使用了哪些关键字等.

任何帮助将不胜感激.

解决方案

要获取URL(和POST)值,请使用JRequest或JInput. JRequest在Joomla 3.0中已弃用,因此最好使用JInput :-) JRequest: http://docs.joomla.org/Retrieving_and_Filtering_GET_and_POST_requests_with_JRequest::getVar JInput: http://docs.joomla.org/Retrieving_request_data_using_JInput

Joomla还可以将值存储到用户会话中.如果要跟踪多个页面上的内容,或者想要保留用户进行的某些设置(例如订购),这将很方便.这些称为用户状态,文档位于此处: http://docs.joomla.org/How_to_use_user_state_variables

I am trying to pull values from a URL string in Joomla when they are passed into our site. an example is:

?source=SEARCH%20&utm_source=google&utm_medium=cpc&utm_term=&utm_content={creative}&utm_campaign=&cpao=111&cpca=&cpag=&kw=

so out of this I will want the VAR=utm_source grabbed, utm_medium grabbed etc.

I want to carry these values across the sites and held at least until the visitor hits submit on a form so these values will be passed with the form to track these areas to see where they came from, what keywords were used etc.

any help will be appreciated.

解决方案

To get URL (and POST) values you use either JRequest or JInput. JRequest is depreceated with Joomla 3.0 so better use JInput :-) JRequest: http://docs.joomla.org/Retrieving_and_Filtering_GET_and_POST_requests_with_JRequest::getVar JInput: http://docs.joomla.org/Retrieving_request_data_using_JInput

Joomla also has the possibility to store values into the user session. This is handy if you want to track something over multiple pages, or want to preserver some settings (like ordering) a user made. These are called UserStates and the doc is here: http://docs.joomla.org/How_to_use_user_state_variables

这篇关于Joomla获取在URL中传递的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆