1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Reading a table from database and displaying data on xenforo

Discussion in 'XenForo Development Discussions' started by anmol dubey, Oct 27, 2015.

  1. anmol dubey

    anmol dubey Member

    Hello All,

    I have a forum where i record the user external click information via an redirect script. (Is there a better way to record the external click information?)

    I Store this information in an external database (non-xenforo) table - ClickHistory.

    What I am trying to achieve:

    Requirement 1: Add a tab or menu item in user menu - Something similar to below


    Requirement 2 :

    When the user clicks on above menu item he should be displayed all his click information by firing a select query to external database

    • Connect to external db
    • fire select query - select click details where user id = '';
    • Retrieve and display with pagenation
    I am from not a heavy programming background. Any help here would be appreciated.

    Many Thanks
  2. Robust

    Robust Well-Known Member

    I have no clue what you mean by external click information, but if possible I would use data stored in XF. Well, what you're going to need to do is create a new controller (and a route for the controller). In the controller, you want to send the params of the information from the query. So you're going to be using a model for database interaction. You can 'init' a new db using Zend_Db::factory() and go from there for getting data from your external db. You get the information, you send it to the view, the view does some magic with it and makes it look accessible for you to create an XF template to present it however you want.

    To achieve this, you will need to know PHP, HTML and CSS, and a basic understanding of XF's templating system. You don't need a 'fluent' understanding, precisely, but you do need some understanding. Honestly, I'd just get a custom development request done if you're not too sure. It'd save time and money in the longer run I suppose, if you don't know any PHP that is. Otherwise, give it a shot I suppose. Lemme know if you need a hand.
  3. anmol dubey

    anmol dubey Member

    @Robust Thanks for the reply

    - I am talking about link clicks which are outside of my forums. I store it using my own interstitial php page to an external database.

    I have developed a custom page (see www.dealschintu.com first page)

    Thanks for this - I would need it for sure.

    I am starting by reading the tutorial for "reading the database"
  4. Robust

    Robust Well-Known Member

    I see. Then yeah, I'd keep that separate. What you may want to consider is adding an API, so do the queries locally and send them off using JSON, then make a JSON request using the Http client instead. It may end up being faster. Use an API key for additional security if you like, and limit it to your IP. An API key is just as secure as a MySQL password can be, just a bit more limited. Plus, it helps you avoid opening up your MySQL externally.

Share This Page