Customized 404 Error extending class |
[eluser]Jorgeska[/eluser]
Hello. I'm starting with CI 2.1.3. I am trying to compose my custom error 404 page. These are the steps I followed (just in case I forgotten someone): 1 - route.php Code: $route['default_controller'] = 'pages'; 2 - errors.php Code: <?php 3 - MY_Exceptions.php (Prefix 'MY_' as in config/config.php) Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); 4 - I put http://www.example.com/wrong on the browser and it takes me to the following page ... Code: MIERROR ... where, as you can see, there is MIERROR but no MIEXCEPTIONCLASS. It is ignoring my MY_Exceptions. Does anybody know why? Does my folder structure has anything to be with the problem? This is (short version) the following: Code: www.example.com This is the tutorial recomended folder structure for more than one aplication in the same codeigniter project. I have unsuccessfully tried too putting MY_Exceptions.php into ci001_tutorial/libraries. What am I doing wrong? Thank you everybody!
[eluser]CroNiX[/eluser]
I haven't used multiple applications like you are there, but each app might be expecting it to be in it's own core dir. Like --------ci001_tutorial/core/MY_Exceptions.php and --------ci002_otra_aplicacion/core/MY_Exceptions.
[eluser]Jorgeska[/eluser]
I know. But the structure I have put is the way CI documentation says it goes. It should work, according to the tutorial. It makes sense if you pretend to re-use code among applications as much as posible, but I have found out that it doesn't work at least for core extensions. I must tell that my MY_Exceptions works successfully in the simplified folder structure, the standard one, I mean the one for a single project. So I came back to this. Anyway I would prefer to start working in a multi-project structure, I mean a middle point between each CI app in a whole CI structure and all the apps mixed in an only one CI structure. I think the profit of this is the possibility of easy code re-using eventhough application are clearly separated. Somebody in the Forum said that he usually put this folder levels for a multiproject environment ... Code: www.example.com Probably it works, but that way we can't share much code, can we? OK, it saves a duplicated 'system', but just this. What's your prefered folder structure thinking of multiple applications?
[eluser]CroNiX[/eluser]
If I have to do this I just create a new folder in the /application/controllers dir for code separation. I guess it also has a lot to do with terminology. I don't really consider different things accessing common code necessarily as "separate apps". If they share a lot of common code, I consider it the same app but maybe a different module, like an administrative module, in which case I'd do something like: /application/controllers/admin /application/controllers/admin/controller1.php /application/controllers/admin/controller2.php /application/models/admin/admin_model.php (if it shares NO code with common models, if not it just goes in /application/models) /application/views/admin/view1.php etc. I realize this isn't as modular as some people want (drag/drop a "module" folder with self contained controllers/models/views/etc) into an existing project, but I don't write code for the masses where they'd need to do something like that and this structure works perfectly fine for my clients needs. There is HVMC (not part of CI core) that offers this kind of modularity within CI where everything is self contained, but I haven't had the need to try them so I can't really advise there. If I truly create a separate application, it gets it's own virtual host and the only thing it shares with other apps is the system folder set in the index.php. |
Welcome Guest, Not a member yet? Register Sign In |