Welcome Guest, Not a member yet? Register   Sign In
Access functions or session data from a config file
#1

(This post was last modified: 07-24-2015, 06:12 AM by Lykos22.)

Hi all, I'd like to ask a question please.

I'm having the content (title, text etc) of my web pages stored in arrays like this:

PHP Code:
$this->data['homepage_content'] = array(
 array(
 
'id' => 'simple',
 
'icons' => array('icon-1''icon-2''icon-3'),
 
'title' => 'This is my Page Title',
 
'text' =>  array(
 
'Lorem ipsum text lorem ipsum text lorem ipsum text lorem ipsum text lorem ipsum text lorem ipsum text lorem ipsum text lorem ipsum text ' anchor('somelink''blah') . 'lorem ipsum text lorem ipsum text lorem ipsum text'.
 ),
 
'link' => array(
 
'url' => 'somepage',
 
'label' => 'Link text',
 ), 
 )
 ); 

So in my views I echo the array keys in order to display the content.

In order to avoid to put too much content in my controllers, I though to store all this page content in a config file.
My question is if its possible to do something like that in cases where I have some session data or some functions in my content too.

Example:

PHP Code:
$this->data['another_page_content'] = array(
 array(
 
'id' => 'simple',
 
'icons' => array('icon-1''icon-2''icon-3'),
 
'title' => 'Hello ' $this->session->userdata('username'),
 
'text' =>  array(
 
'Lorem ipsum text lorem ipsum text lorem ipsum text lorem ipsum text lorem ipsum text lorem ipsum text lorem ipsum text lorem ipsum text ' anchor('somelink''blah') . 'lorem ipsum text lorem ipsum text lorem ipsum text' my_function('foo'),
 ),
 
'link' => array(
 
'url' => 'somepage',
 
'label' => 'Link text',
 ), 
 )
 ); 
Reply


Messages In This Thread
Access functions or session data from a config file - by Lykos22 - 07-24-2015, 06:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB