Welcome Guest, Not a member yet? Register   Sign In
Can you load data into a view, then parse it?
#4

[eluser]Braden Schaeffer[/eluser]
Thanks for the quick replies.

@Colin That's what I was thinking... so I looked at the Parser library and it's so easy to implement I can't believe its not an option.

All you have to do is remove/change the line where $template is loaded as a view. I added a parameter called $is_string so you still have the option of parsing a view file. Here's the edited Parser.php parse function:
Code:
function parse($template, $data, $return = FALSE, $is_string = TRUE)
    {
        $CI =& get_instance();
        
        if($is_string == FALSE)
        {    
            $template = $CI->load->view($template, $data, TRUE);
        }
        
        if ($template == '')
        {
            return FALSE;
        }
        
        foreach ($data as $key => $val)
        {
            if (is_array($val))
            {
                $template = $this->_parse_pair($key, $val, $template);        
            }
            else
            {
                $template = $this->_parse_single($key, (string)$val, $template);
            }
        }
        
        if ($return == FALSE)
        {
            $CI->output->append_output($template);
        }
        
        return $template;
    }

It's working now, thanks for the suggestion!!!


Messages In This Thread
Can you load data into a view, then parse it? - by El Forum - 09-23-2009, 05:40 PM
Can you load data into a view, then parse it? - by El Forum - 09-23-2009, 06:03 PM
Can you load data into a view, then parse it? - by El Forum - 09-23-2009, 07:26 PM
Can you load data into a view, then parse it? - by El Forum - 09-23-2009, 09:29 PM
Can you load data into a view, then parse it? - by El Forum - 09-23-2009, 10:25 PM



Theme © iAndrew 2016 - Forum software by © MyBB