refering site's URL parameter?
I am struckted here. I want to get the url parameters of external site (in my case Google). For example if i search for lorem, then refererig url is something like
Code:
http://www.google.com/search?q=lorem
In my module, I have used $_SERVER["HTTP_REFERER"] and sort out the query parameter. This works fine on all pages except on index page. (The difference here is, apart from index page which ends in '/' all other pages have ending .html/.htm). On the index page the $_SERVER["HTTP_REFERER"] is internally written and you lost all the parameters!
Can anyone tell me how to get the
1. refering site's url parameter on index page
2. refering site, ok for this one $this->getReferer() works 99%.
Note: No, i didn't turn on the page cache function.
Re: refering site's URL parameter?
Hello,
you can find a working code for this in the extension [url=http://www.contao.org/extension-list/view/searchenginebox.en.html]searchenginebox[/box]. It reads the parameter from searches (not only Google) and displays user a special message on the Contao page.
What do you want to do with the Parameter? Perhaps I can include it in that extension?
Jan
Re: refering site's URL parameter?
Hi Jan,
thanks for the reply. Actually i came to this need from extensions searchengineBox. The searchengineBox will not work on index page. i.e. on page -> www.example.com
Are you by any chance author, of that module?
Regards
Re: refering site's URL parameter?
Hello,
correct, I'm the module author and maintainer. ;-)
On my installations the extension works on the index page too. What other extension do you use? Are you sure you included the module in the layout for the index page?
Jan
Re: refering site's URL parameter?
Hello there,
No i didn't include it in page layout, But as a content element module on index page. I think it should not make difference right?
regards
Tenzin
Re: refering site's URL parameter?
Hi Tenzin,
that should be fine too. Can you send me the URL of your page and a search query that will list your index page?
Jan
Re: refering site's URL parameter?
Hi Jan,
I owe you a feedback, I must have tried many times before to post the content below, but every time forum crashed. Lets hope this time it works this time. Anyway here is the feedback.
Thanks for your module and having patience with me. It seems to work now I can't tell you why. I was testing here http://alturl.com/jezySeven
But I have some improvement to suggest you.
1. There should be a counter field in database to count number of times the same keyword/phrase is searched, instead of writing every search into database.
for example:
Code:
if ($keyword != false) {
//check if the keyword is in DB allready
$objKeyword = $this->Database->prepare("SELECT id,times FROM tl_searchEngineBox WHERE keyword=? AND searchengine=?")
->limit(1)
->execute($keyword, $searchengine);
if (!$objKeyword->numRows)
{
// Save Entries in DB if its not there in keyword
$this->Database->execute('INSERT INTO tl_searchEngineBox (tstamp, searchengine, keyword) VALUES ('.time().',"'.$searchengine.'","'.$keyword.'")');
} else {
$this->Database->prepare('UPDATE tl_searchEngineBox SET times=? WHERE keyword=?')->execute($objKeyword->times + 1, $keyword);
}
where 'times' in above code is a field in DB
Code:
`times` int(10) unsigned NOT NULL default '1',
May be you can improve it.
Regards
Tenzin