Welcome Guest, Not a member yet? Register   Sign In
Trying to combine 3 CI libraries: HMVC-Template-Tank_Auth
#11

[eluser]developer10[/eluser]
[quote author="wiredesignz" date="1328644494"]Why is the Template library located in "system/libraries/"?
I mentioned above that you should never need to alter, or add to, the CI system files.

I think you need to review the CI user guide again to discover how to use user defined libraires and how they should interact with the other CI classes.
[/quote]

That library was developed by Colin Williams if I remember correctly. If you believe that the library should not have been put there, then I don't know which one of you two is right.

Do you have the answer to my question from the end of my previous post? Thanks a lot, I really appreciate your help!
#12

[eluser]wiredesignz[/eluser]
[quote author="developer10" date="1328644905"]... That library was developed by Colin Williams if I remember correctly. ...

Do you have the answer to my question from the end of my previous post? Thanks a lot, I really appreciate your help![/quote]

Well you should really ask Colin Williams where the library should be located. OR maybe just read the CI user guide.

Your issues when using Tank Auth are not something I can help with. I merely offered a modular solution to get you started.

#13

[eluser]developer10[/eluser]
[quote author="wiredesignz" date="1328645258"][quote author="developer10" date="1328644905"]... That library was developed by Colin Williams if I remember correctly. ...

Do you have the answer to my question from the end of my previous post? Thanks a lot, I really appreciate your help![/quote]

Well you should really ask Colin Williams where the library should be located. OR maybe just read the CI user guide.

Your issues when using Tank Auth are not something I can help with. I merely offered a modular solution for you to get started with.

[/quote]

Alright, fair enough! Thanks again. If you want, just take a brief look at his site dedicated to the library. It is only now that I see he actually tells users to put that Template.php to either Application/libraries OR system/libraries. So probably he should drop that other option out from the installation instructions.
#14

[eluser]developer10[/eluser]
Should anyone else have the same issue with "template.php does not contain valid config array" here's what I have done.

In config file /config/template.php, configuration options look like this:
Code:
$template['active_template'] = 'default';

I changed $template into $config in all of those. It was needed to alter main Template.php file as well. Now I have it working when I have config file in /application/modules/modulename/config/

Note that I have moved my Template.php library from /system/libraries to /application/libraries hoping that it would make somehow easier for me to use the path to the current module in Template.php, which would enable to use single Template.php for all of my modules.

At the moment, I'm looking for a way to have something similar in Template.php

Code:
// current code
      // Load the template config file and setup our master template and regions
      include(APPPATH.'modules/auth/config/template'.EXT);

// needed code
      // instead of specifying module name, I need to somehow get the current module name
      include(APPPATH.'modules/'.CURRMODULENAME.'/config/template'.EXT);

If this is possible somehow, let's discuss it here!
I am going now to ask @Colin Williams to take a look at this thread, as I think he might have the solution, as the author of the library.
#15

[eluser]Colin Williams[/eluser]
My suggestion is to take a step back, try setting up another CI app with only vanilla CI and the Template Library. See if you can get that running no problem. Then, try incorporating HMVC, and if things break at that point, you should have some more insight into where problems are occurring.
#16

[eluser]developer10[/eluser]
[quote author="Colin Williams" date="1328742822"]My suggestion is to take a step back, try setting up another CI app with only vanilla CI and the Template Library. See if you can get that running no problem. Then, try incorporating HMVC, and if things break at that point, you should have some more insight into where problems are occurring. [/quote]

First of all, thank you Colin for your reply.

Honestly, this is the very first time I hear about Vanilla CI but I suppose Google will show me the way.

If nothing helps, I was thinking of a pretty radical move - to have Template.php library in /application/libraries for each module I have. So I might end up having Tplauth.php, Tplblog.php, etc. In each of them I will have to provide module name in which it has to lookup /views folder.

Since modules should be able to have their own /config/autoload.php, it shouldn't create unnecessary overhead because the module will autoload only its own template library.

Anyone has an opinion on this solution? Acceptable? Not too elegant? Can be improved?

I'm off to google for Vanilla CI!
#17

[eluser]developer10[/eluser]
I've just remembered an idea that came to my mind earlier today.

Colin's Template.php has functions like this:
Code:
function set_master_template($filename)

and HMVC author @wiredesignz suggested using this for getting current module name:
Code:
$this->router->fetch_module();

The thing is I'm not able to fetch module in Template.php where I actually need it.

So I was thinking, what if I fetch module name first and then pass it as an extra parameter to each function?

Something like this:

Code:
// this is controller

    $currmodule = $this->router->fetch_module();

    $this->template->write('title', 'auth hmvc!', $currmodule);
    $this->template->write_view('content', 'login_form', $data, $currmodule);
    $this->template->render();

Then in Template.php I would use that value as a replacement for module name, like in:
Code:
function write_view($region, $view, $data = NULL, $overwrite = FALSE, $currmodule)
   {
      $args = func_get_args();

      // Get rid of non-views
      unset($args[0], $args[2], $args[3]);

      // Do we have more view suggestions?
      if (count($args) > 1)
      {
         foreach ($args as $suggestion)
         {
            if (file_exists(APPPATH .'modules/'.$modulename.'/views/'. $suggestion . EXT) or file_exists(APPPATH .'modules/'.$modulename.'/views/'. $suggestion))
            {
               // Just change the $view arg so the rest of our method works as normal
               $view = $suggestion;
               break;
            }
         }
      }

      $content = $this->CI->load->view($view, $data, TRUE);
      $this->write($region, $content, $overwrite);

   }

I don't know if this approach would work but I feel this must be close to the final solution. My suggestion goes for @Colin to add support for HMVC in a manner that is similar to this because I believe many people would like to use his library with HMVC!
#18

[eluser]Colin Williams[/eluser]
@developer10, sorry for the "vanilla CI" confusion. "Vanilla" is an American idiom that means "plain" or "basic".

If someone ever submits a mod to Template that plays nicely with the HMVC module (and without it) I'll happily roll it in and release a new version. But, I won't be spending any time on it.




Theme © iAndrew 2016 - Forum software by © MyBB