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

[eluser]developer10[/eluser]
Is there anyone who managed to successfully combine these 3 libraries into CI 2.x.x?
If yes, how does his directory structure look like?

I'm going to point some stuff out:
- I need a separate auth module: /modules/auth where the tank_auth will reside
When I need this auth functionality, I should be able to call that module
- as per Template library, I think it would be great if I can have only one Template.php in /system (as in normal CI install using this library)
- in each module, I should have /module/config/template.php and also multiple (when needed) template HTML file themselves in each module (just like in ordinary CI install with Template library)

I think this should be possible to implement. I googled a lot today but... no success. I've also posted at stackoverflow.com so if anyone is interested in it, just go to:

http://stackoverflow.com/questions/91670...te-library

and give your answer/advice/opinion there.

Thanks!
#2

[eluser]wiredesignz[/eluser]
@developer10, There is an archive file for a "Tank Auth" HMVC module linked below.

http://---DELETED---

NOTE:
The captcha files (not included above) still need to be located in a publicly accessible "captcha" directory.
#3

[eluser]developer10[/eluser]
@wiredesigns, thank you for the help. I'm new to HMVC but I like the concept and I'm now trying to set everything up to be used in a mid-size project.

At the moment I believe one issue is solved. Because you've sent me that auth module I suppose I can rest assured it contains Tank_Auth files that are configured correctly to work with HMVC.

The remaining issue is Template library. It would be great if its author, Colin Williams stumbles upon this thread and throws in some good advice.

Regular Template installation is simple.
Template.php goes into /system/libraries
template.php (config file) goes into /application/config (in this file you define areas in an array form)
and finally you have to put, eg. mainTemplate.php somewhere in your /views folder (this name is predefined in /application/config/template.php obviously).
============================

What I've already tried to do is:
Leave the library in /systen/libraries BUT change its path to the config/template.php
from something like APPPATH.'config/'.$filename to APPPATH.'modules/auth/config'.$filename
In this case, I move template.php from app/config to /app/modules/auth/config

What confuses me is this error I'm getting when the above is done:
Code:
./application/modules/auth/config/template.php does not contain a valid config array

It seems like the array cannot be read correctly although the library is pointing to the right location and file.

Anyone here who successfully combined HMVC and Template library?
#4

[eluser]wiredesignz[/eluser]
@developer10, CI "system" files or directories should never be modified. User defined classes should always be located in the appropriate "application" or "modules" directories.
#5

[eluser]developer10[/eluser]
[quote author="wiredesignz" date="1328634338"]@developer10, CI "system" files or directories should never be modified. User defined classes should always be located in the appropriate "application" or "modules" directories.[/quote]

I agree. I changed the code when trying to get the Template library work along these two other libraries (HMVC and Tank Auth).

What would be an equivalent of APPPATH for a module in HMVC? Where do I declare it so I can use name similar to that which represent one of my modules?
That is something I believe I will have to use in Template.php library to tell it to look for module specific config and master template files depending on the current module a user is in.
#6

[eluser]wiredesignz[/eluser]
[quote author="developer10" date="1328635018"]... What would be an equivalent of APPPATH for a module in HMVC? ...[/quote]
Code:
APPPATH.'modules/the_module_name/'
#7

[eluser]developer10[/eluser]
[quote author="wiredesignz" date="1328635624"][quote author="developer10" date="1328635018"]... What would be an equivalent of APPPATH for a module in HMVC? ...[/quote]
Code:
APPPATH.'modules/the_module_name/'
[/quote]

Well, yes, I've done that before. But isnt there any way of putting something that will be true for any module a user is in so that a single Template.php in /system/libraries serves any module a user might be in.

For example:
Code:
APPATH.MODULEPATH.'views/'.$filename.EXT

Couldnt I define somewhere MODULEPATH and use it like in the above example?
#8

[eluser]wiredesignz[/eluser]
Constants can not be altered once they are defined.

Your can call $this->router->fetch_module() to obtain the name of the current module.

Or you can access the protected $_module variable in the currently active "MX_Loader" object by using a "MY_Loader" extension and making that variable public or adding a method to return it's value.
#9

[eluser]developer10[/eluser]
[quote author="wiredesignz" date="1328637064"]Constants can not be altered once they are defined.

Your can call $this->router->fetch_module() to obtain the name of the current module.

Or you can access the protected $_module variable in the currently active "MX_Loader" object by using a "MY_Loader" extension and making that variable public or adding a method to return it's value.[/quote]

I guess it is not possible to use
Code:
$this->router->fetch_module()
inside this
Code:
/system/libraries/Template.php
file? That's where I need it so the code in it always knows in which module to search for a "views" directory.

Another question:
When used
Code:
$username
in Auth module (view file) I get this (showing screen I get):

Code:
Hi,
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: username

Filename: views/welcome.php

Line Number: 1

! You are logged in now.

If I use
Code:
$this->session->userdata('username')
the username is showing OK. What causes $username not to display properly?
#10

[eluser]wiredesignz[/eluser]
Why is the Template library located in the "system/libraries/" directory?
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 work with user defined libraries and how they should interact with the other CI classes.




Theme © iAndrew 2016 - Forum software by © MyBB