Part of the EllisLab Network
   
1 of 2
1
Trying to combine 3 CI libraries: HMVC-Template-Tank_Auth
Posted: 06 February 2012 06:24 PM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  186
Joined  07-04-2008

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/9167076/codeigniter-tank-auth-used-as-a-hmvc-module-along-with-the-template-library

and give your answer/advice/opinion there.

Thanks!

 Signature 

Visit Business Directory - Poslovni Imenik // BiH

Profile
 
 
Posted: 06 February 2012 08:40 PM   [ Ignore ]   [ # 1 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  3216
Joined  06-10-2007

@developer10, There is an archive file for a “Tank Auth” HMVC module linked below.

http://wiredesignz.co.nz/files/tank_auth_module.tar

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

 Signature 

URI Language Identifier | Modular Extensions - HMVC | View Object | Widget plugin | Access Control library

Profile
 
 
Posted: 07 February 2012 06:18 AM   [ Ignore ]   [ # 2 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  186
Joined  07-04-2008

@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:

./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?

 

 Signature 

Visit Business Directory - Poslovni Imenik // BiH

Profile
 
 
Posted: 07 February 2012 12:05 PM   [ Ignore ]   [ # 3 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  3216
Joined  06-10-2007

@developer10, CI “system” files or directories should never be modified. User defined classes should always be located in the appropriate “application” or “modules” directories.

 Signature 

URI Language Identifier | Modular Extensions - HMVC | View Object | Widget plugin | Access Control library

Profile
 
 
Posted: 07 February 2012 12:16 PM   [ Ignore ]   [ # 4 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  186
Joined  07-04-2008
wiredesignz - 07 February 2012 12:05 PM

@developer10, CI “system” files or directories should never be modified. User defined classes should always be located in the appropriate “application” or “modules” directories.

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.

 Signature 

Visit Business Directory - Poslovni Imenik // BiH

Profile
 
 
Posted: 07 February 2012 12:27 PM   [ Ignore ]   [ # 5 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  3216
Joined  06-10-2007
developer10 - 07 February 2012 12:16 PM

... What would be an equivalent of APPPATH for a module in HMVC? ...

APPPATH.'modules/the_module_name/' 
 Signature 

URI Language Identifier | Modular Extensions - HMVC | View Object | Widget plugin | Access Control library

Profile
 
 
Posted: 07 February 2012 12:34 PM   [ Ignore ]   [ # 6 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  186
Joined  07-04-2008
wiredesignz - 07 February 2012 12:27 PM
developer10 - 07 February 2012 12:16 PM

... What would be an equivalent of APPPATH for a module in HMVC? ...

APPPATH.'modules/the_module_name/' 

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:

APPATH.MODULEPATH.'views/'.$filename.EXT 

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

 Signature 

Visit Business Directory - Poslovni Imenik // BiH

Profile
 
 
Posted: 07 February 2012 12:51 PM   [ Ignore ]   [ # 7 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  3216
Joined  06-10-2007

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.

 Signature 

URI Language Identifier | Modular Extensions - HMVC | View Object | Widget plugin | Access Control library

Profile
 
 
Posted: 07 February 2012 02:42 PM   [ Ignore ]   [ # 8 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  186
Joined  07-04-2008
wiredesignz - 07 February 2012 12:51 PM

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.

I guess it is not possible to use

$this->router->fetch_module() 
inside this
/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

$username 

in Auth module (view file) I get this (showing screen I get):

Hi,
A PHP Error was encountered

Severity
Notice

Message
Undefined variableusername

Filename
views/welcome.php

Line Number
1

You are logged in now

If I use

$this->session->userdata('username'

the username is showing OK. What causes $username not to display properly?

 Signature 

Visit Business Directory - Poslovni Imenik // BiH

Profile
 
 
Posted: 07 February 2012 02:54 PM   [ Ignore ]   [ # 9 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  3216
Joined  06-10-2007

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.

 Signature 

URI Language Identifier | Modular Extensions - HMVC | View Object | Widget plugin | Access Control library

Profile
 
 
Posted: 07 February 2012 03:01 PM   [ Ignore ]   [ # 10 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  186
Joined  07-04-2008
wiredesignz - 07 February 2012 02:54 PM

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.

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!

 Signature 

Visit Business Directory - Poslovni Imenik // BiH

Profile
 
 
   
1 of 2
1