Thule - 0.9.6
  • Welcome
  • Introduction
  • - MVC(Model-View-Controller)
    - Architecture of Framework
    - Flow Chart of Application
    - Services In One Server
    - Developing Guide
    - Features
  • Installation
  • Getting Started
  • - Direct Access HTTP
    - Router Access HTTP
    - Router Direct Access HTTP
    - Reserved Function
    - Convention
    - Bootstrap
    - Pack Javascript , CSS
  • Basic Modules
  • - Model
    - View
    - Controller
  • Libraries
  • - Router
    - Config
    - Response
    - Request
    - Database
    - Query
    - Cache
    - Debug
    - Log
    - Unit Test
    - Registry
    - Profile
  • Helper
  • - Auth
    - Calendar
    - Date
    - Error page
    - Email
    - Form
    - GeoIP
    - Google
    - Html Element
    - Html
    - Http
    - I18n
    - Image
    - Json
    - Jquery
    - Login
    - Layout
    - Locale
    - PHP to Javascript
    - Paging
    - Payflow
    - Soap
    - Text
    - Table
    - Uri
    - Upload
    - Validation
  • Plugins
  • - Smarty Template Engine
  • History
  • Home > PHP to Javascript Helper

    This Helper is very useful to build the site when you pass the variable from php to javascript, we sometimes need to pass and receive the data in site between client and server.
    For This helper, there is view file (views/include/userjs.php)

    In View

    Add the below to view file

    $Frontend->phptojs(); //default file path
    $Frontend->phptojs('include/userjs');

    Will be like this.

    <script type="text/javascript"> var variable=value; </script>

    In Model

    Load the helpr and pass the data to javascript, when you send the name ,pay attention to the prefix of name you can set in helper.

    $this->loadHelper("phptojs");
    $this->Phptojs->passTojs("thule","wow");
    $this->Phptojs->passTojs("thuleint",1);

    Useful options to Buffer

    There are several useful options to Buffer,below is a example.If you have a look the Phptojs class, you can catch.

    $this->Phptojs->serializeToBuf("thule","wow");
    $this->Phptojs->bufferFlush();