Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8595923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:33:19+00:00 2026-06-12T00:33:19+00:00

My goal is to save on database the url referer and keywords when entering

  • 0

My goal is to save on database the url referer and keywords when entering on any page of our store. I checked this question and its answer to try to get some light into my problem.

The approach I’m following is:

  1. To have a block that will stick on the default layout so it will be loaded on each page (tested, is working). This block will read the referer by using the following code:

    $request[‘url’] = $this->getRequest()->getServer(‘HTTP_REFERER’);

  2. Then call function passing the $request to a controller:
    This step I still do not know how to do it, using redirect? Or maybe by calling a dispatchEvent and on the controller having a postAction function?

    //on the phtml file
    <div>
         <?php
              $request['url'] = getRequest()->getServer(‘HTTP_REFERER’);
              Mage::dispatchEvent("allpagescontroller", $request);
         ?>
    </div>
    
  3. The controller will instantiate my model and call the setters to update/insert neeeded values

    //on the controller
    function postAction ($params)
    {
        $referer = $this->getRequest()->getPost();
    }
    
  4. On the model I will have all the appropiate code to do the CRUD operations

Is this correct? I’m trying to follow the Magento MVC approach by following these steps. For now I’ve all the code on the phtml file. I’m getting the referer, splitting it and instantiating the model to save everything. But I know this is not correct.

On config.xml for now I have:

<?xml version="1.0"?>
<config>
    <modules>
        <Dts_Allpages>
            <version>0.1.0</version>
        </Dts_Allpages>
    </modules>
    <global>
      <models>
          <allpages>
              <class>Dts_Allpages_Model</class>
              <resourceModel>allpages_mysql4</resourceModel>
          </allpages>
          <allpages_mysql4>
                  <class>Dts_Allpages_Model_mysql4</class>
                <entities>
                  <keywords>
                      <table>keywords</table>
                  </keywords>
                  <referencedpages>
                      <table>referencedpages</table>
                  </referencedpages>
              </entities>
          </allpages_mysql4>
        </models>
        <blocks>
            <allpages>
                <class>Dts_Allpages_Block</class>
            </allpages>
        </blocks>
        <helpers>
            <allpages>
                <class>Dts_Allpages_Helper</class>
            </allpages>
        </helpers>
        <resources>
            <allpages_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </allpages_write>
            <allpages_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </allpages_read>
        </resources>
    </global>>
    <frontend>
      <routers>
          <allpages>
              <use>standard</use>
              <args>
                  <module>Dts_Allpages</module>
                  <frontName>allpages</frontName>
              </args>
          </allpages>
      </routers>
        <layout>
            <updates>
                <allpages>
                    <file>allpages.xml</file>
                </allpages>
            </updates>
        </layout>
    </frontend>  
</config>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:33:20+00:00Added an answer on June 12, 2026 at 12:33 am

    Your logic is not correct in terms of Magento MVC flow. Template is the last stop of the program flow, you should not insert ANY logic in templates, because your system will transform into unstable mess.

    The logic you’re trying to achieve does not require any view at all. It doesn’t require even Controller. As you know, Magento utilizes an Event-Observer pattern, and your task is just asking for it.

    You should create your Observer and listen to some event from the initial request flow. You can listen to any event that is triggered on every page request, but it shouldn’t be too early – when system itself is still not yet initialized, and it shouldn’t be too late, when some of the other system logic can redirect, forward or make some changes to referrer. I think controller_action_predispatch will suit your needs.

    In the Observer you can get the HTTP_REFERER and save it in the DB using your Model layer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I turned this case into a simple PHP page that submits to itself. My
So, I'm building an application which save locations to a database using lat/lon coordinates.
I have a question on how to update an existing row in my database
Goal: Save a notepad file in the computer. (C#) Problem: I don't know how
I have GPS Tracking application main goal is saving GPS coordinate to backed database
Goal : I wants when I drag image it become fade so we can
Goal is to make a dialog that appears on menu_key pressed, but it keeps
Goal: Once i click on the start button on my user interface, i currently
Goal: Produce an Excel document with information from 3 associated models that is similar
Goal I am building an Eclipse plugin targeting the 3.7 environment and would like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.