Welcome Guest, Not a member yet? Register   Sign In
Calling function in view from Controller or Model
#1

[eluser]geshan[/eluser]
The title might be confusing, but here is the scenario. I need a system with pluggable (copy paste and work , PnP) type themes, like in Drupal CMS. The themes/template will be copied to the views/themes folder and most probably parsed using Samrty. So the settings about the themes say the no. of regions to display content will be in the settings.php file in the themes/theme_name folder with page.tpl and other tpl files and css files.

I need to call a function in the setting.php file that resides in say views/themes/theme1/setting.php from a controller or even model is it possible, if yes how?? Help needed.

Geshan
#2

[eluser]xwero[/eluser]
I think you are making it hard on yourself. Why not put the setting.php in the config directory with the name theme1.php then you can call the setting is the view file with the config_item function.

Another option is to include the file in your controller and pass the settings to the view.
#3

[eluser]geshan[/eluser]
IF you are familiar with Drupal, its like copy the folder to themes folder and you are done. If I make it hard to copy files to different locations it will be complicated, so thinking of getting it this way. As themes will be changeable in real time each file shouldn't be copied to the config dir overwriting the existing theme setting?????
#4

[eluser]Colin Williams[/eluser]
Write a Theme library that knows what to do. Shouldn't be too big of a deal.
#5

[eluser]geshan[/eluser]
Thats what I 'm trying to write, so asking how to?
#6

[eluser]Colin Williams[/eluser]
Code:
class Theme {
  var $theme;
  var $regions = array();

  function Theme()
  {
    // Read default theme from a config file
    // Load up theme's settings.php file
    // Update $regions from settings.php
  }

  function get_regions()
  {
    return $this->regions;
  }

  function set_regions($regions)
  {
    $this->regions = $regions;
  }

  function set_theme($theme)
  {
    $this->theme = $theme;
    // Read $theme's settings.php file and call $this->set_regions
  }

}

See where this is going... it's pretty cut-n-dry

You also might want to check out my Template library as a start.. it's kinda like drupal's regions approach.. would be dead easy to add the theming capabilities (considered doing it myself once... didn't like how it locked people into using Template if they wanted themes [couldn't use load->view() with theme])
#7

[eluser]louis w[/eluser]
Why can't it just be a config file?
#8

[eluser]geshan[/eluser]
it will be longer process by using the config file.
#9

[eluser]geshan[/eluser]
Problem loading setting.php file

I tried this
Code:
$this->load->file(theme_base_path().$theme_name.'/setting.php');

but it returned an error:

Code:
An Error Was Encountered

Unable to load the requested file: setting.php

the file exists in the defined path but it is not included. What should I do?
#10

[eluser]xwero[/eluser]
Are you sure the theme_base_path() and the $theme_name have the desired output?




Theme © iAndrew 2016 - Forum software by © MyBB