I'm following CodeIgniter's tutorial "Create a blog in 20 minutes" and I am having trouble getting the helper, anchor and Scaffolding functions to work.
I can't seem to create links on my HTML page using the helper and anchor functions.
I put
$this->load->helper('url');
$this->load->helper('form');
in the constructor under
parent::Controller();
and
<p><?php echo anchor('blog/comments','Comments'); ?></p>
within the foreach loop as specified in the tutorial. But Im not getting the links to appear.
When I viewed the source as instructed in the video, this line was missing (but it was in in the video):
<form method= "post" action = "http://www.example.com/CodeIgniter/index.php/blog/comment_insert">
Secondly, I keep getting a 404 Page Not Found error whenever I try to access CodeIgniter's Scaffolding page in my browser, like so:
localhost/codeignitor/index.php/blog/scaffolding/mysecretword
I can access
localhost/codeignitor/index.php/blog
just fine. I followed CodeIgnitor's instructions in their "Create a blog in 20 minutes" by storing my database settings in the database.php file; and automatically connecting to the database by inserting "database" in the core array of the autoload.php; and I've added both
parent::Controller(); and $this->load->scaffolding('myTableName') to blog's constructor. It still gives me this 404.
Any assistance will be appreciated. Thanks in advance?
Scaffolding is deprecated, but it hasn't been removed until 2.0, and still works in 1.7.2.
You have /scaffolding/ in the URL which isn't necessary, you just use your scaffolding trigger.
I'm not sure why your helpers aren't working, your syntax looks good, unless you don't have any data in your foreach loop. the <form...> line comes from calling <?php echo form_open('form_controller_or_whatever'); ?>
localhost/codeignitor/index.php/blog/mysecretword
is just enough ....
check out this site:http://www.schobbing.de/user_guide/general/scaffolding.html you'll get a clear understanding ....
Related
I'm following the tutorial at Phalcon's page (https://docs.phalconphp.com/en/3.4/tutorial-base) and I got stuck at creating the /view/signup/index.phtml.
When I access the /signup/index.phtml page it only shows me the HTML tags, that is, "Sign up using this form". None of the $this->tag show. I copied the linkTo tag from the /views/index/index.phtml to the signup view but it didn't work as well, even though it's working perfectly in the index/index.phtml. Somehow no Tag is working at the /signup view.
Does anyone know why?
The codes
/app/controllers/SignupController.php
<?php
use Phalcon\Mvc\Controller;
class SignupController extends Controller
{
public function indexAction()
{
}
}
/app/views/signup/index.phtml
<h2>Sign up using this form</h2>
<?php echo $this->tag->form("signup/register"); ?>
<p>
<label for="name">Name</label>
<?php echo $this->tag->textField("name"); ?>
</p>
<p>
<label for="email">E-Mail</label>
<?php echo $this->tag->textField("email"); ?>
</p>
<p>
<?php echo $this->tag->submitButton("Register"); ?>
</p>
Views are not supposed to be accessed directly. Try to use Phalcon Developer Tools to set up your app skeleton or use the simple MVC example. Notice that you must have mod_rewrite enabled (if you are working in Apache). Then continue following the tutorial (create the Loader, DI with view, etc) and you will be surprised by the magic of Phalcon. Good luck!
Check your URL
Are you using /signup/index.phtml in your browsers address bar?
You should have something like localhost/tutorial/signup
You will be able to visually see templates by going to their path directly, but the php will not run.
Not all resources being included
If you are using the URL paths seen in the tutorial, check that all resources are being loaded into the SignupController correctly by doing the following:
var_dump($this->tag)
This should display something in regards to "form" or a whole bunch of text. If you see nothing the `Phalcon\Tag' class is not loading in correctly.
You probably may even have a typo somewhere. I would recommend copying and pasting the tutorial instead of typing, only while bug checking, to make sure there are no typos. You can use a tool like a diff checker to compare your files to their tutorial.
Online diff checker : https://www.diffchecker.com/
I'am templating the website under the Joomla 3.2.0 for HikaShop ecommerce component, and would like to find out which file is loaded with following code, so I could correctly override the styles for specific file.
The filename I'a working with is root\templates\MY_TEMPLATE\html\com_hikashop\user\registration.php. Inside that file there is a small part of code which underloads custom fields I would like to override with custom styles:
<div class="address-fields">
<?php
$this->type = 'address';
echo $this->loadTemplate();
?>
</div>
Anyone knows which filepath is exactly loaded with the following $this->loadTemplate(); ?
Not sure if you are using it the same way as it is used here, but they explain it as if the parameters you pass in the function loadTemplate(), actually as loadTemplate(address) would be files in your case found in registration_address.php
hey, It's worth a shot checking it out
SEE HERE
The CodeIgniter has a very simple default error 404 message:
404 Page Not Found
The page you requested was not found.
Instead of using this error message on totally blank page, I want to wrap this message in between my header and footer view, so that the error message have similar look to the other pages.
For that purpose, I have created an error view? For example:
my404_view.php
<? $this->load->view('header'); ?>
404 Page Not Found
The page you requested was not found.
<? $this->load->view('footer'); ?>
Now, How can I use this my404_view.php as a default view to display 404 messages instead of using the CodeIgniter default error message.
You should change your routes.php. For example:
in application/config/routes.php
$route['404_override'] = 'welcome/_404';
in application/controllers/welcome.php
function _404(){
$this->load->view("my404_view");
}
And this should be sufficient in the current version of CI.
Including headers and footers in the default error 404 page seems to be a common problem for CodeIgniter users. I would like to add this link: Simon Emms's comments at http://www.simonemms.com/2011/05/06/codeigniters-404-override-problem/ because he describes the problem so clearly.
I have tried the suggestions at http://maestric.com/doc/php/codeigniter_404 and played around with Simon Emms's ideas, and others, but just can't implement them. I'm a bit of a novice at PHP and CodeIgniter, so that might be because of ignorance. That said, it is difficult to ensure that you put the suggested subclasses in the right places and configure, for instance, routes.php correctly. After 3 days of trying the various rather complicated ideas, it occurred to me that I could just use an include statement in the default error 404 page. The only difficulty was figuring out the path to pass to the include statement.
In /system/core/Exceptions.php line 146, I found the CodeIgniter developers use APPPATH. You then just have to append the path to the header and footer pages you want to include.
My new default error 404 page now looks like this:
<?php
include APPPATH.'/views/templates/header.php';
?>
<div id="container">
<h1><?php echo $heading; ?></h1>
<?php echo $message; ?>
</div>
<?php
include APPPATH.'/views/templates/footer.php';
?>
This seems a much easier solution to me than trying to change the core classes in CodeIgniter.
There is quite a bit of information on this.
http://maestric.com/doc/php/codeigniter_404
http://www.nickyeoman.com/blog/apache/90-htaccess-404-page
http://hasitha.posterous.com/customising-error-pages-on-codeigniter (archived)
http://codeigniter.com/wiki/ReCAPTCHA/
Okay. So I download the code. Move all the files to the appropriate folders. Set the keys in the config/recaptcha.php file. Then where I have my form submit logic I put in the
$this->form_validation->run()
function.
Then in the HTML I do what?? I need to display the captcha for user input. I see google's code for adding the php recaptcha into non-code igniter documents, but I'm not sure which parts of that are relevant. And I'm not sure how I'm supposed to be making calls to particular files. Right now
<? $this->load->view('recaptcha.php');
$publickey = "thekeynumbersandgibberish";
echo get_html($publickey);
?>
this currently breaks my HTML page, I figure I'm not calling the file and function correctly using code igniter syntax. What is the proper syntax? This was not included in the code igniter documentation.
Insight would be appreciated.
You need to call this in your controller first
//In your Controller
$data['recaptcha'] = this->recaptcha->get_html();
$this->load->view('my_view',$data); //try it with the test page first
//In your View
$this->load->view('recaptcha.php');
The instructions in the wiki are pretty straightforward. Don't load the files in the view. Assign the HTML in the controller.
This is the normal process when working on MVC.
There's a basic CI tutorial here : http://net.tutsplus.com/tutorials/php/codeigniter-basics/
I am using a framework called qcodo (which forked as qcubed) and is a PHP framework.
I want to do a very simple popup using the Facebox jquery plugin.
When someone clicks on the link and shown below in line 47.
Here is the file: http://github.com/allyforce/AF-upload/blob/master/Templates/profile_activity.tpl.php
<a href="complete_profile_popup.php?allyId=<?= $this->objAllyUser->Id?>" rel="facebox" title="Complete Profile" >Invite as Ally</a><br />
The Facebook installation worked fine, tested it just opening plain html and php files.
I just want to be able to render a working page within the Facebox pop-up.
But the current error is that it cannot recognize the method, even though it appears it has been defined.
UPDATE: Per one suggestion, used iFrame, but still getting nothing:
You should print the error you get. I will try to guess: have you declared your method as public? In the template you can access only public properties and methods. This is a very common mistake.
This issue/topic is being discussed in depth at http://www.qcodo.com/forums/forum.php/3/4007/