CodeIgniter Forums
Controller IDENTITY issue - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Controller IDENTITY issue (/showthread.php?tid=59791)

Pages: 1 2 3 4


Controller IDENTITY issue - El Forum - 11-18-2013

[eluser]v4et[/eluser]
I want a piece of code on the index of my Code Igniter's script so I can change the identety or 'name' of my controller from agent69 to agent007_and_supergirl,and also a way to beat any rule that pages might have against using underscore to separate words as an amendment.

In other words I want that all the calls that the processor of my server has inside my code igniter for agent69 be translated to calls to agent007_and_supergirl

So it is like other person is taking the calls but is just me but with other name,get it?,just like the son of Sadam Hussein did ,he had a clon that did all the danger exhibits,yes its a change of identity because the son of Hussein certainly became other person but people didnt know it,so what I want is just a change of identity for the controller and that is just that.

Is just a change of identety for the controller without altering the main controler's functionality and without getting my hands dirty with coding.


Thanks in advanced


Controller IDENTITY issue - El Forum - 11-18-2013

[eluser]CroNiX[/eluser]
You can do that with routes.

Code:
$route[what-you-want-to-accept-as-the-url] = 'the_real_controller/the_real_method';

So,
Code:
$route['agent007_and_supergirl'] = 'agent69';

If someone went to www.yoursite.com/agent007_and_supergirl it would actually trigger the agent69 controller's index method (since we didn't specify a method in the route).


Controller IDENTITY issue - El Forum - 11-20-2013

[eluser]v4et[/eluser]
Working on config/routes.php yelded miserabe results on past,remember that is an identity matter

And I want all the calls of agent69 be sent to agent007_and_supergirl that is its new identity

What was successfull on the past about this mattar was controller and file cloning,it worked masterfully
but this only intercepted few server calls so for me to get all the server calls, I need to clone every
single fie on the script so I feel silly teling you again thats why I didnt want to get my hands dirty with code
because is plenty of code.

Well hope that you can help me master this code that goes on the index of my code igniter script

<?PHP header("($customControllerName): $this->agent69 = ['agent007_and_supergirl']"); exit ?>






Controller IDENTITY issue - El Forum - 11-20-2013

[eluser]v4et[/eluser]
Please also do help me perfect this other little piece of code:

$config['controller_customName','agent69'] = 'agent007_and_supergirl',TRUE;


Controller IDENTITY issue - El Forum - 11-20-2013

[eluser]CroNiX[/eluser]
I'm not sure how to easily do what I think you are wanting to do without using routes. What's the problem with routes? That's the mechanism CI provides to change the default routing of "the_controller/the_method/the_parameters" to whatever URL you want without having to alter (or clone) your existing controllers and it happens very early on in the bootstrap process before most of CI is loaded.

As for your $config, I'm sorry but I have no idea what you are trying to do there. You have separate arguments (comma) in the key as well as the value. I've never seen a PHP array like that.


Controller IDENTITY issue - El Forum - 11-20-2013

[eluser]v4et[/eluser]
Thank Cronix men for taking the time ,appreciate.
You mean that the controler stays the same as we intend but the
personality or "URL" identity changes,

Iam getting to think is not merely redirect,but that as we intended
to change the identity of agent69 to agent007_and_supergirl as we had
been taking in this thread,along to translating all server calls from
agent 69 to become calls to agent007_and_supergirl ,well from your
wording Im kinda understanding this is possible url wise,or that.......

agent69 will always be agent007_and_supergirl on my browser bar isntit?

-which would be fair

Like I told you Ive done testing about this for which is hard for
me to believe but maybe my syntax was unproper.

Can we go square by square and can you please provide a copy
of your config/routes.php ,sure changing any personal facts ,no prob men
yes so I can see the exact syntax because I tried this
$route['agent007_and_supergirl'] = 'agent69';
but you know that on some server files rules change
isnt it like this?:
route['agent007_and_supergirl'] = 'agent69';


Controller IDENTITY issue - El Forum - 11-20-2013

[eluser]Tpojka[/eluser]
Can you explain this?

[quote author="v4et" date="1384990904"]
but you know that on some server files rules change
isnt it like this?:
route['agent007_and_supergirl'] = 'agent69';[/quote]

CroNiX explained well everything. Check this one.

In native CI instalation you have this controller:

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends MY_Controller {

public function __construct()
{
  parent::__construct();
}

public function index()
{
  
  $this->load->view('welcome_message');
}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */

If you in application/config/routes.php put

Code:
$route['agent007_and_supergirl'] = "welcome";

typing
Code:
http://example.com/agent007_and_supergirl
will lead you to welcome message.
If you are not using rewriting index.php part of URL, than you have to type
Code:
http://example.com/index.php/agent007_and_supergirl

What is your question related to this?


Controller IDENTITY issue - El Forum - 11-20-2013

[eluser]v4et[/eluser]
not underestimate men but I think Cronix was connecting well with me ,I think Im gonna wait for his reply by the way Im on a Centos 5 32 bits

All in all I think theres some missunderstanding here tpojka helped me realize this routes page handles just specific calls but not all

I mean

how you do
$route['agent007_and_supergirl'] = "agent69"; <--how you do so all calls inside script relating this resolve to['agent007_and_supergirl']

I mean is not only typing mydomain/agent69 that will lead me to mydomain/agent007_and_supergirl but I mean all functions inside the script pages where controller agent69 that woud end up ressolving on agent007_and_supergirl

This makes me reailize the only solution is altering all codes inside CI or cloning them simply by changing wherever is agent69 to
agent007_and_supergirl, I mean is the only solution Ive tested to prove that can handle all server calls ,what tpojka depicted was a simple basic analog server call

thank you


Controller IDENTITY issue - El Forum - 11-20-2013

[eluser]v4et[/eluser]
In other words is hard for me to believe that all functions inside the script with this
$route[‘agent007_and_supergirl’] = “agent69”;
where agent 69 is involved
would end up ressolving in diferent types of urls containing one way or another this
agent007_and_supergirl
If you all can guarantee that this will happen please confirm,
Im waiting for your confirmation breathen


Controller IDENTITY issue - El Forum - 11-20-2013

[eluser]v4et[/eluser]
This along with facts like Class names must start with an uppercase
makes me not know what to think of you