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

(11-09-2018, 02: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

// 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);


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

(11-09-2018, 07:20 AM)php_rocs Wrote: @marwin,

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


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.


Sorry, I meant database views not coding views.

you mean through models? yes that has been implemented.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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