Welcome Guest, Not a member yet? Register   Sign In
Questions about transferring data to parse
#1

Now I'm using parse to generate pages, and I attach an array with it, like the following:
Code:
    private $data = array(
        'title'       => 'this is a title',
        'keywords'    => 'this is keywords',
        'description' => 'this is description',
        'css'         => array
        (
            'test'=>'ok',
            'time'=>'now'
        )
    );

As you can see, $data is an array and one of its element, css, is also an array. 
In the template I can use {title} to refer to 'title' element in $data, but how to use css array in view?

Like {css:test} ? It doesn't work.
Reply
#2

Change your array from this:

PHP Code:
private $data = array(
 
       'title'       => 'this is a title',
 
       'keywords'    => 'this is keywords',
 
       'description' => 'this is description',
 
       'css'         => array
 
       (
 
           'test'=>'ok',
 
           'time'=>'now'
 
       )
 
   ); 
 
To this:

PHP Code:
private $data = array(
 
       'title'       => 'this is a title',
 
       'keywords'    => 'this is keywords',
 
       'description' => 'this is description',
 
       'css'         => array
 
       (
 
           array('test'=>'ok','time'=>'now')
 
       )
 
   ); 


In your template you can then loop an array by doing this
Code:
{css} // Start of the array, The parser will see it is an array
   {test} // Your keys
   {time}
{/css} // The end of your array

More info on this in the user guide
http://www.codeigniter.com/user_guide/li...able-pairs
Reply




Theme © iAndrew 2016 - Forum software by © MyBB