问题
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.
回答1:
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
来源:https://stackoverflow.com/questions/16023865/joomla-getting-variables-passed-in-url