From within the plugin, you could examine the request to see if the user came to your site from a search engine. If so, set a cookie to indicate this. Then, check the cookie to see if its true and if it is append a new action to the action stack.
I would hook into routeStartup or one of the other hooks that only run once per request.
SearchEngineDetector.php
<?php
class SearchEngineDetector extends Zend_Controller_Plugin_Abstract
{
protected $_searchHit = false;
public function RouteStartup(Zend_Controller_Request_Abstract $request)
{
if ($_COOKIE['search_hit'] OR preg_match('/google.com/', $request->getServer('HTTP_REFERER'))) {
// Set cookie
$_COOKIE['search_hit'] = true;
// Save value in plugin
$this->_searchHit = true;
}
if (true ===$this->_searchHit) {
$actionStack = Zend_Controller_Front::getPlugin('Zend_Controller_Plugin_ActionStack');
$actionStack->pushStack(// your specialized action goes here //);
}
}
}
In bootstrap or whever you set up your plugins:
<?php
$front = Zend_Controller_Front::getInstance();
$front->registerPlugin(new SearchEngineDetector());
-Hector
On Fri, Jan 23, 2009 at 6:20 AM, Raavi Raaj <raaviraaj77@gmail.com> wrote:
Hi,I would like to...- Serve additional content if my user is a search visitor.For which...- I need to set a cookie; after verifying she is indeed a search visitor based on the referrer.- For the first request: Read a variable in my view helper to render additonal content and- For subsequent requests: Read the cookie in my view helper to render the additional contentMy problem...- I dont know where to set my cookie?- How to get hold of the variable in the first request?Use case...Show a prominent "Subscribe to our newsletter" form to only search visitors; on landing page and all subsequent pages.I hope I have been able to explain myself. I can give ot another try of this does not make any sense :)Can someone share some thoughts in this. All help is appreciated.-RP.S.- I have a conventional setup- I have a base controller My_Action which all my controllers extend.
没有评论:
发表评论