CodeIgniter Forums
Need help to my controller :( - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Need help to my controller :( (/showthread.php?tid=42935)



Need help to my controller :( - El Forum - 06-24-2011

[eluser]tunabelly14[/eluser]
Sorry for this simple question. It just happen that I'am new using the codeigniter. This is my question, Im getting a 404 error because of my controller although I already put the name of the controller into the line. Im using codeigniter 1.7.2 for this. Thank you in advance guys..
http://localhost/globedez/index.php/globedez/main

here are the codes that I used.

//Controller file: globedez_controller.php

<?php
class Globedez extends Controller
{
function Globedez()
{
parent::Controller();
}

function main()
{
$this->load->library('MyMenu');
$data['menu']=$menu->show_menu();
$data['webtitle']='Globedez|Portfolio';
$data['webfooter']='copyright step by step';
$this->load->view('globedez_home',$data);
}
}
?>


//this is my code at my library: globedez_library.php
<?php
class MyMenu
{
function show_menu();
{
$obj=& get_instance();
$obj->load->helper->('url');
$menu="<ul>";
$menu.="<li>";
$menu.= anchor("globedez/main","Home");
$menu.="</li>";
$menu.="</ul>";
return $menu;

}
}
?&gt;


//this is the code of my view. globedez_home.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;&lt;?php echo $webtitle;?&gt;&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;?php echo $menu;?&gt;
&lt;/body&gt;
&lt;/html&gt;



Need help to my controller :( - El Forum - 06-24-2011

[eluser]jalalski[/eluser]
make the name of the file 'controllers/globedez.php' and it should get picked up.

HTH


Need help to my controller :( - El Forum - 06-24-2011

[eluser]tunabelly14[/eluser]
I already change the filename but it doesn't allow controllers/globedez.php so I just save it as globedez.php

It shows now different error indicating: "An Error Was Encountered

Unable to load the requested class: mymenu"

I dont know how does it happen because "MyMenu" is the name of the class inside of the library. I hope we can solve this problem.

Can you please also explain to me why the globedez.php works while the previous name of controller doesn't work. Thank you again.


Need help to my controller :( - El Forum - 06-24-2011

[eluser]jalalski[/eluser]
Naming of files is very important. Take a look at:
http://ellislab.com/codeigniter/user-guide/general/controllers.html
Similar concerns apply to Libraries and to Models.

HTH


Need help to my controller :( - El Forum - 06-27-2011

[eluser]tunabelly14[/eluser]
Thank you very much sir!