Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter Extending Multiple Controllers?
#1

[eluser]Unknown[/eluser]
Probably posted here 100 times but I cannot find it in search.

Can't find a way to do this, possibly because there is another way to do this?

Some of my controllers extend AdminLayout and some of them extend ModLayout but I also need these pages to extend a LoggedIn Controller.

Code:
class Profile extends AdminLayout, LoggedIn {

However looking into there is no way to do this nicely. Is there a workaround?

EDIT:

Another thing, when I use the redirect helper and go:

Code:
redirect('/');

It redirects me to site.com/index.php not site.com, any solutions?
#2

[eluser]PhilTem[/eluser]
A class can only extend one parent-class. But it may however implement multiple interfaces. Before posting too much code, have a look at http://stackoverflow.com/questions/35612...ass-in-php. And don't forget you can have hierarchical extends like a parent-class, a grandparent-class and so on and so forth Wink

On your second question:
Where do you want to redirect to? If you use '/' then it will redirect to base_url() . '/'. If you want to redirect to your base_url(), use

Code:
redirect(base_url());
#3

[eluser]Unknown[/eluser]
Thanks, that solution worked well, although messy haha.

As for the redirect, I am trying to remove the index.php from my URL using htaccess but this code snippet does not work for some reason: (mod_rewrite enabled)

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    
    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>




Theme © iAndrew 2016 - Forum software by © MyBB