Welcome Guest, Not a member yet? Register   Sign In
Using xsl views
#1

[eluser]Kamarg[/eluser]
For quite some time I've been interested in using XSLT for my views instead of html files with php code scattered about them. I also wanted the coding conventions to follow the $this->load->view method as much as possible. Attached are MY_Loader and MY_array_helper files that allow me to use xsl views as if they were normal views. Feel free to use these files in your own projects. Comments on how to improve the code are always welcome.

Code:
// Loads a xsl view. Converts everything in $data['parameters'] to parameters accessible in
// the xsl file. All other items in the $data array are passed to the xsl file as xml.
function xslt() {
    $data = array(
        'PlanList' => array(
            'plan' => array(
                array('plan_nbr' => '350'),
                array('plan_nbr' => '123A')
            )
        ),
        'parameters' => array(
            'page_title' => 'XSLT Test'
        )
    );

    // Load the xsl view. Can take a boolean third parameter to return the
    // view as a string.
    $this->load->xslt('Test/test2', $data);
}




Theme © iAndrew 2016 - Forum software by © MyBB