Can't get my controller to work
Permalink
I'm a newbie to both c5 and php.
I'm working on a single page. I'm learning from the tutorial on "Handling Requests with Page Controllers". I've done every single step, so everything is the same (but the name on my single page).
I have the "Wiadomosci" ("News" in English) page:
/single_pages/wiadomosci/view.php
/controllers/wiadmosci/controller.php
In the view.php file I have the following content:
And in my controller.php file I have the following lines:
When I'm clicking the "Search" button, the "Page Not Found" is displayed. The addres my browser is trying to reach is "http://localhost/concrete/index.php/wiadomosci/<?=$this->action('search_user')?>.
What's wrong?
I'm working on a single page. I'm learning from the tutorial on "Handling Requests with Page Controllers". I've done every single step, so everything is the same (but the name on my single page).
I have the "Wiadomosci" ("News" in English) page:
/single_pages/wiadomosci/view.php
/controllers/wiadmosci/controller.php
In the view.php file I have the following content:
<form method="post" action="<?=$this->action('search_user')?>"> <input type="text" name="uName" value="" /> <input type="submit" value="Search" /> </form>
And in my controller.php file I have the following lines:
<?php class WiadomosciController extends Controller { public function search_user() { print 'I am running!'; } }
When I'm clicking the "Search" button, the "Page Not Found" is displayed. The addres my browser is trying to reach is "http://localhost/concrete/index.php/wiadomosci/<?=$this->action('search_user')?>.
What's wrong?
If not, go here: /dashboard/pages/single/ and type the page path in the form at the bottom of that page.
Yes, I have installed it. I've done everything described in the mentioned "tutorials" from the c5 site.
I don't know, why my controller is not working. I started working on a web app, that should provide the functionality I need, though. And I realized, that since this web app is written in PHP, its code can be placed directly in my single page. This way, I can make "a bunch" of single pages, which will work as a web app (written in PHP) working right on the site I'm working on. I don't need any "controllers".
At least, I think so. (I'm a PHP and C5 newbie, so I can be wrong.)
I don't know, why my controller is not working. I started working on a web app, that should provide the functionality I need, though. And I realized, that since this web app is written in PHP, its code can be placed directly in my single page. This way, I can make "a bunch" of single pages, which will work as a web app (written in PHP) working right on the site I'm working on. I don't need any "controllers".
At least, I think so. (I'm a PHP and C5 newbie, so I can be wrong.)
Not sure if you're still having this issue or not (I was until a few moments ago). but I've found something that worked for me.
most of the documentation I read states to do something like this:
I changed mine to the following:
now I actually get a url in my generated HTML that works for me at least
Hope that helps
most of the documentation I read states to do something like this:
<form method="post" action="<?=$this->action('some_function')?>">
I changed mine to the following:
<form method="post" action="<?php echo $this->action('some_function')?>">
now I actually get a url in my generated HTML that works for me at least
Hope that helps
Looks like PHP short tags are not enable on your server, enter the following line on your htaccess file;
php_flag short_open_tag on
or on your php.ini file;
short_open_tag=1
and you should be able to use;
php_flag short_open_tag on
or on your php.ini file;
short_open_tag=1
and you should be able to use;
<?=$this->action('whatever');?>