I have a cron job that is running through some cases and if there is an error it should send an e-mail.
My code for creating the view to the e-mails looks like this (it's in my model class):
$layout = new Zend_Layout();
$view = $layout->getView();
$view->case = $case;
$view->forms = $forms;
echo "One\n";
$view->addScriptPath(APPLICATION_PATH .'/modules/case/views/scripts');
echo "Two\n";
$returnview = $view->render('index/print.phtml');
echo "Three (it never comes here)\n";
return $returnview;
It never comes to the Three (as it says) (it doesn't gives a error, it just looks like it exit() there).
Anyone know why it never gets there?
we are using Zend FrameWork 1.12
As you are able to just render a view with $view = new Zend_View(); and the rest of the code can use this :)
from docs they are setting the template like this enter link description here
$returnview->setTemplate(APPLICATION_PATH
.'/modules/case/views/scripts/index/print.phtml);
return $returnview;
I think you are are confused with zend version < 2.0
Make sure that your display_error setting is set properly to see the error message
since you are using zend f-1.12 you can simply use $this->render("view"); from controller
You can access the view object from any where using
$returnview = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
Related
I am learning CakePHP.I want to pass fetched data from controller to view page.
Controller (ProfileController)
public function download_result($poll_id)
{
$this->_checkVipSession();
$this->Poll->bindModel(array('hasMany' => array('PollAnswer' => array('foreignKey' =>'poll_id'))), false);
$condition = "Poll.id = ".$poll_id." AND Poll.isdeleted = '0' ";
$poll_info = $this->Poll->find('first',array('conditions'=>$condition));
$this->set('poll_info',$poll_info);
Configure::write('debug', '2');
}
View(download_result.ctp)
<?php
echo "<pre>";
print_r($poll_info);
?>
It gives an error like :
Missing View
Error: The view for ProfileController::download_result() was not found.
Error: Confirm you have created the file: /home/webbrain/public_html/cake/app/views/profile/download_result.ctp
Notice: If you want to customize this error message, create app/views/errors/missing_view.ctp
So how can I resolve it?
Note : I have used CakePHP version 1.3.13
Place your view download_result.ctp into cake/app/views/profile/
Now, I would recommend for you to stop using such an older version and start learning with versions 3.x, the newest would be better, Cakephp 3.2.
It's not necessary to start with an old version, specially because the changes between them are big (and because new stuff is almost better).
What I want to accomplish
I am altering a PrestaShop module that currently uses a form submitted by a user to generate files to be a stand alone CRON job. The module works perfectly in the back office, and involves nothing more than a user clicking a button; a repetitive task that should instead be handled by a CRON job (the action, not the clicking of the button of course).
What I am trying
if (!defined('_PS_VERSION_')) {
// Initialize prestashop
require_once '../../config/config.inc.php';
require_once '../../init.php';
define('_PS_MODE_DEV_', true);
echo 'This gets echoed';
$exporter = new order_exporter;
echo 'This does not get echoed';
}
class order_exporter extends Module
{
// Rest of code here. Works when used with back office.
}
The behavior I am getting
The first echo works, but once I call $exporter = new order_exporter;, I get this error. PHP Fatal error: Class 'order_exporter' not found in C:\wamp\www\addressstamps\modules\order_exporter\order_exporter.php. This isn't on the screen and only in my error log. As I've understood in the past, this is the correct way to use OOP. I'm not sure if I'm misunderstanding something about Prestashop, OOP, or Scope, but after much research and tweaking, I have made no progress past this point.
This is not an OOP issue, but a PrestaShop design decision.
Try with:
$exporter = Module::getInstanceByName('order_exporter');
instead of:
$exporter = new order_exporter;
Here 'order_exporter' is your module name (i.e the name property from the class).
I am learning how to use codeIgniter as my php framework. I am reading through the documentation and watching the intro video and just generally following along with the first tutorial, but it's not working for me.
I have created a controller called "test.php" and a view called "test_view". The controller for this class is exactly like "welcome.php" and the view file just has some static html. However, when I go to index.php/test I get a 404 error.
I have also tried manipulating the original welcome files so that instead of calling a view it just echos "testing", yet I still see the original welcome message! I've tried clearing my browsing cash and refreshing, but to no avail.
Any suggestions? Thanks.
Edit: Here's the code for controllers/test.php
<?php
class Test extends Controller {
//Just trying to get it to echo test
public function index()
{
echo "test";
//$this->load->view('test_view');
}
}
?>
Try looking at this page in the documentation - this might solve your problem.
This basically means you should try typing index.php?/test/ instead (notice the question-mark).
First of all, check the above link. Might be useful.
If not, then...
Try changing the default controller in the config file ('routes.php') to something else (probably, to 'test'), then try loading index.php. Just to test whether the whole system works (or not).
Check whether mod_rewrite is loaded (in your server .conf-file, if you're using Apache).
Try using the latest build of the framework. AFAIK, the name of the controller class for now is "CI_Controller".
Finally, try removing the word 'public' before the declaration of the function. AFAIR, CI enable you to make private functions in controllers just by using prefix (which is set in the config file) at the beginning of the name of the function (thus making all the other functions public).
But most certainly the problem is with the mod_rewrite. If not, try debugging with die('Page found'); instead of echo - this will allow you to track possible redirects on the page.
I've just started looking at PHP Frameworks after spending loads of wasted time doing everything from scratch. I thought I would give Codeigniter a go after a friend recommended it to me.
I worked through the first tutorial and there were no issues but I'm getting stuck with the second one.
At first my code was identical to the tutorial:
<?php
class Blog extends CI_Controller{
function Blog()
{
parent::CI_Controller();
$this->load->scaffolding('entries');
}
public function index(){
$data['title'] = "My Blog Title";
$data['heading'] = "An intresting title";
$data['todo'] = array('create media player','design site','finish project');
$this->load->view('blog_view',$data);
}
}
?>
But I got an internal server error. After looking at the user guide it shows a different way for using the constructor.
I changed the code to the document spec.
<?php
class Blog extends CI_Controller{
public function __construct() {
parent::__construct();
$this->load->scaffolding('entries');
}
public function index(){
$data['title'] = "My Blog Title";
$data['heading'] = "An intresting title";
$data['todo'] = array('create media player','design site','finish project');
$this->load->view('blog_view',$data);
}
}
?>
But I still get an internal error. I don't know if my code is wrong or I misconfigured something else. Some advice would be good, thanks.
Edit:
To clarify - I only get an internal error when I add the constructor to the class.
This will most likely because you're trying to load scaffolding in the latest version of CodeIgniter.
Scaffolding has been depreciated since version 1.6. It was removed in 2.0, and the latest version is now 2.0.2
In terms of which of your provided snippets to use, the latter form of declaring a constructor (__construct) is preferred over using the Class name (Blog). This method is also consistent with the Core Classes of CodeIgniter since 2.0.
As an aside, I've got no idea why CodeIgniter are including such out-of-date samples in their tutorials. EllisLab's seem to have lost total interest in the CI project recently, which is a shame :(
Internal error means there's mis-server configuration.
Usually .htaccess file or apache settings. Try this:
Enable rewrite module in apache.
Make sure .htaccess file is configured correctly. It should look like this: https://gist.github.com/ce2914e79193896590bc
This also removes index.php, which you should look into.
I am trying to write a short Rest Service with Zend Framework. But the documentation is not the best at this Part.
I have an ApiController extended Zend_Rest_Controller with all needed abstract methods. My goal is to get Post data and return something.
My client looks like this:
public function indexAction()
{
$url = 'http://localhost/url/public/api';
$client = new Zend_Rest_Client();
$client->setUri($url);
$client->url = 'http://www.google.de';
$result = $client->post();
}
but the provided "$client->url" is not inside the post array on Server side. Does I have to use Zend Rest Server inside the postAction on my ApiController?
If someone has an example how to send and to get the data with Zend Rest, that would be great.
Maybe this tutorial Create RESTful Applications Using The Zend Framework can help.
Have you tried setting it to access 127.0.0.1 rather than localhost? I know this can cause issues sometimes.