Results 1 to 2 of 2

Thread: frontend template database connection

  1. #1
    New user
    Join Date
    07-25-09.
    Posts
    1

    Default frontend template database connection

    Hi all,

    I was trying hard but could not find an answer to this.

    I have a custom e frontend page template and I'd like to get some data from the Database inside.
    But I don't know how to communicate withj the database within a page template. Do I really have to make a new connection myself with mysql_connect ? Or is there a smarter way.
    The value of $this->Database is NULL ??

    Any idea ?

  2. #2
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: frontend template database connection

    In TL, you normally would create a new FE (front-end) Module, that will make the connection, setup the template variables and then output the template, which in turn will load the template file, e.g. mytemplate.tpl and render it with your custom variables passed to it. This is the way all FE modules are done. Templates are purely designed to format the data already passed to it by the Module (with minor logic to deal with missing or empty data in variables). The template is not the place to load classes, connect with the database to get new data, as that is the purpose of the module.

    You can of course hack away and do your own thing, but that won't be blending with the existing structure of TL which is based on the ZEND framework, a Model, View, Controller (MVC) architectural pattern. In MVC, the model represents the information (the data) of the application; the view corresponds to elements of the user interface such as text, checkbox items, and so forth; and the controller manages the communication of data and the business rules used to manipulate the data to and from the model.

    http://en.wikipedia.org/wiki/Model–view–controller

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •