phpcodeignitertemplatessmarty

Smarty Templates with CodeIgniter, can't load template when too many directories in hierarchy


I'm using CI Smarty

https://github.com/Vheissu/Ci-Smarty

There are two issues with this as far as I have noticed. but the issue for which I opened this question is that I cant load a .tpl file if that .tpl file is inside the directory of another directory.

E.g. this is my current directory structure for SmartyTemplate

--Themes
  --SomeOtherThemeName
  --Default //Default theme directory I am currently using
    --css
    --js
    --images
    --views
      --admin (directory)
          --sitesettings (directory)
            --site-settings.tpl (template file) //This template file will not work

If I move this Template file to parent directory which is admin, it will work if I call it, but if I call it from inside sitesettings directory it will not work.

Here is how I call it.

function functionName(){
    $data['title']="Some Title";
    $this->parser->parse('admin/sitesettings/site-settings.tpl',$this->data);
}

Simply, Smarty only allows me to have 1 extra Directory in hierarchy under views folder, I want to know if there is any fix for this so that I can have unlimited or at least more directories in hierarchy so I don't have messed up file system.

Update

Here is my project:

https://github.com/pakistanihaider/HouseRentSystem

Database regarding this project:

http://www.mediafire.com/view/1jp9u906r8i10u0/houserentsystem.sql


Somehow found the main problem thanks to @Sauryabhatt. I think problem exists in {{extends file='adminLayout.tpl'}}. How does it know where the file exist, I mean if I move the file inside most inner directory how it will know where the main layout file exit to which it will be a child? do I need to define a path when extending a file?

Update

Also tried to define the path to the layout, but seems that it also didn't work out for me.

$this->parser->parse('extends:layouts/adminLayout.tpl|file:systemConfigurationSitePreferences.tpl',$this->data);

it works if I put the fail in admin directory, but stops working if I move the file inside in another directory of admin directory.


Solution

  • OMG, Aftr this long time, i tried almost everything, i even downloaded the zebra CMS to see why there code is working and not mine, xD i even tried changing there code with mine even knowing that it wont gonna solve anything but just was hoping. xD

    But in the end finally i got my eyes on the Real Problem, When i tried to put the template file inside another directory of a directory the relative path got disturbed in admin layout.

    I had some File Components like menus tabs in separate files which i was including in the Master Layout File. e-g:

    {{include file="../admin/ui_components/user-media.tpl" name="user media"}}
    

    so template was working if it was inside 1 directory but when i tried to add 1 more directory and put file inside it, the path gave error.

    The Biggest Problem with CI Smarty is, it never gives error only give White Blank Page if there is any error regarding the tpl files.

    If the error system would have been good i might would have found the solution faster.

    Anyhow, now just Added the Base Path, so no matter how many directories i go in, it will not gonna give any problem..

    Thanks for All your Support. Looks like my Bounty Got Wasted xD..