• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Session Data vs. Config Variables

#11
(11-09-2018, 03:07 AM)Pertti Wrote: $custom_config_data = '<\?php ';
It was incase me beeing stupid. I echoed the result and didnt write it - so that is why the code didnt show. I appologise!

All working fine now. I think I format it with some linebreaks though.

I also missed an array in the build code. If anyone wants to use the code, this is the final and working version. I just run a cronjob on the function in my heartbeat controller to update this regularly. I think once daily in the night will be best.

// Load model
$this->load->model('Page_m');

// Prepare custom config file
$custom_config_data = '<?php'.PHP_EOL;
$custom_config_data = $custom_config_data . 'defined(\'BASEPATH\') OR exit(\'No direct script access allowed\');'.PHP_EOL;
// overviews
$category = $this->Page_m->get(array('hidden' => 0, 'released' => TRUE), 'category');

foreach ($category as $key_fow => $value_fow)
{
// Get number of contents within origin

$subentries = $this->Page_m->count_subnavigation($value_fow['id']);
$custom_config_data = $custom_config_data . '$config[\'sub_navigation_entries_' . $value_fow['id'] . '\'] = '.var_export($subentries, true).';'.PHP_EOL;
}

// Write config file
@file_put_contents('./application/config/sub_navigation_entries.php', $custom_config_data);
}
Reply

#12
@marwin,

Are you using MySQL? Also, have you considered using VIEWs?
Reply

#13
(11-09-2018, 08:20 AM)php_rocs Wrote: @marwin,

Are you using MySQL?  Also, have you considered using VIEWs?

Hi,

yes MySQL and I am making extensive use of views but the menu is standard across all views with dynamic alterations.

Actually I think in design one could have placed the information inside the settings table of the database (which is called anyway) and update the count whenever a new content is inserted.

Honestly I would have preferred that but it would require a lot of recoding for every add-view and is rather messy because the project is already live. Thus I hope my approach provided a quick and easy solution even if it's a bit hacky. It's already implemented and updates through a cronjob now.
Reply

#14
@marwin,

Sorry, I meant database views not coding views.
Reply

#15
you mean through models? yes that has been implemented.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2018 MyBB Group.