So I'm new at this whole CakePHP thing, but I'm looking to get the Uploader plugin installed. I'm stuck at the first installation step, after download/placing the files in the correct place: http://milesj.me/code/cakephp/uploader. I see this is the code I need to add somewhere:
// CakePHP 2
CakePlugin::load('Uploader');
App::import('Vendor', 'Uploader.Uploader');
$this->Uploader = new Uploader();
But I don't know where to put it! I'm using the basic "Blog tutorial", but I changed the name from "Posts" to "Media". Where would I put this code to get the plugin included? I'm not sure on the rest of the steps either, so if anyone could help me with that in terms of the default "Blog tutorial" setup, that'd be awesome. Thanks!
EDIT: I have the CakePlugin part working. I'm just unsure about the App:import line. I keep trying to add it inside my MediaController class, but it's just throwing errors. Where would this line go?
EDIT: App:import line is working, now I just need the new Uploader() part
I havn't used this specific plugin, but I have used one similar (MeioUpload).
The CakePlugin::load('Uploader') goes in your bootstrap configuration file (app/config/bootstrap.php)
App::import and the creation are likely to be handled within your "Media" controller.
For example. My Cake App uses App::uses('Sanitize', 'Utility'); in its PostController.
EDIT:
I assume it would be something like this.
<?php
App::import('Vendor', 'Uploader.Uploader');
class MediaController extends AppController {
$this->Uploader = new Uploader();
/* The rest of the controller */
}
But I could be wrong. The explanation for that plugin is weird.
Related
I have used composer to download the Angell EYE PayPal library into my vendor directory. Now I'm trying to call the class within a controller.
I've tried various methods:
Use \angelleye\PayPal;
at the top of page. I've tried using the require() method.
Within the controller I have used
$paypal = PayPal::PayPal($payment);
And a few other ways, but I just get the error Class not found at line 179 and I'm not sure why.
You just need to load a config file (depending on your framework) and the autoloader.
require_once('includes/config.php');
require_once('vendor/angelleye/paypal-php-library/autoload.php');
Of course, adjust the paths to suit where you have those saved, but the autoloader is what makes the classes available to you.
If you want more direct help you can submit a ticket here.
Thanks for response.
I actually managed to get it working on the framework.
I did nt have to load anything or require the class as the composer autoload must do it for me in the framework.
I simply added :
$PayPal = new \angelleye\PayPal\PayPal($PayPalConfig);
and it started to work.
Im guessing if i want to use the PayFlow i would call using:
$PayPal = new \angelleye\PayPal\PayFlow($PayPalConfig);
I will definately post back if the rest of the proccess fails to work.
I had ReDJ plugin v 1.6 working on 2.5 Joomla site. But I'm moving on Joomla 3 and this module don't work now - exception errors appears. In change-logs I found this:
Changed class names for ALL models, controllers and views. So I simply add Legacy suffix to all classes that handles exceptions. And also change JRequest (it is deprecated in v3) on $input=JFactory::getApplication()->input;.
So for now, seems like all is working fine. Except.. component admin panel - i can see component menu, but there is no any content on page.
Here is screenshot: http://tinyurl.com/btfzxux
Main controller controller.php code:
http://pastebin.com/vQjYvYkK
Main component file redj.php code:
http://pastebin.com/gF6icdE3
I found that dont work line parent::display(); in controller.php file. And there is no error in logs and display.
And this line calls JControllerAdmin->display() which is:
/**
* Display is not supported by this controller.
*......................
*......................
*/
public function display($cachable = false, $urlparams = array())
{
return $this;
}
So nothing displayed. I tried to rename extends definition as JControllerLegasy (because it supports display() method), but still nothing in component output.
How can i output component content in admin panel in Joomla 3?
Any help appreciated.
S.G.
UPDATE 1:
I publish my code on GitHub. I'm tying to optimize this plugin for Joomla 3. Any help welcome!
https://github.com/staniaslavg/ReDJ
P.S. Now redirection list displays and adding a new one works fine. But.. there is no items in item list.
UPDATE 2:
Finally, everything works fine (tested jnly by me, but seems like everything is OK..)
P.S. If nothing displays in tabs - check for DataBase columns. I added a few more. Check whis by var_dump errors variable (like $this->get('Errors')) in files views/.../view.html.php
Code on GitHub: https://github.com/staniaslavg/ReDJ
I've posted some updates in the github repo, to show that it's possible to get it working. (for the redirects view sequence). Unforunately some code used in Joomla! 2.5 by the component was already deprecated and was removed in 3.0. Also the GUI looks bad in 3.0, it needs more work.
As much as I would like to help you to get it running, the time involved it huge. I would strongly suggest using Joomla! 2.5 which is still for a good period supported.
Also the developer announces that a Joomla! 3.0 version is underway.
Going over all the code and fixing it makes little sense for me, but here are some examples:
JDatabase::getEscaped() has been removed. Use JDatabase::escape() instead.
$db->getEscaped($orderCol.' '.$orderDirn)
=> $db->escape($orderCol.' '.$orderDirn)
JToolBar no longer supports the 'X' functions (eg, addNewX, editListX) that hide the main menu before doing the function.
and others.
We have used Zend_Log, which is configured in application.ini differently for different circumstances. We initialize it/get it in the bootstrap and store it in the registry:
$r = $this->getPluginResource('log');
$logger = $r->getLog();
But we've subclassed Zend_Log (say, Our_Log) to add customized features, and want to get it the same way. So then we have to make a new Resource Plugin. That seems quite easy - just copy Application/Resource/Log.php, rename the file to Ourlog.php, rename the class to class Zend_Application_Resource_Ourlog. For now, let's not worry about "Our_Log", the class -- just use the new Resource Plugin to get a Zend_Log, to reduce the variables.
So then, our new code in the bootstrap is:
$r = $this->getPluginResource('ourlog');
$logger = $r->getLog();
but of course this doesn't work, error applying method to non-object "r". According to the documentation,
"As long as you register the prefix path for this resource plugin, you
can then use it in your application."
but how do you register a prefix path? That would have been helpful. But that shouldn't matter, I used the same prefix path as the default, and I know the file is being read because I "require" it.
Anyway, any guidance on what simple step I'm missing would be greatly appreciated.
Thanks for the pointers -- so close, so close (I think). I thought I was getting it...
Okay, so I renamed the class Xyz_Resource_Xyzlog, I put it in library/Xyz/Resource/Xyzlog.php
Then, because I don't love ini files, in the bootstrap I put:
$loader=$this->getPluginLoader();
$loader->addPrefixPath('Xyz_Resource','Xyz/Resource/');
$r = $this->getPluginResource('xyzlog');
if (!is_object($r)) die ('Not an object!!');
Sudden Death. So, okay, do the ini:
pluginPaths.Xyz_Resource='Xyz/Resource/'
The same. No help. I believed that the basepaths of the plugin paths would include the PHP "include" paths. Am I mistaken in that? Any other ideas? I'll happily write up what finally works for me to help some other poor soul in this circumstance. Something to do with Name Spaces, maybe?
Plugin classes are resolved using the plugin loader, which works slightly differently to the autoloader; so just requiring the class in doesn't help you here. Instead, add this to your application.ini:
pluginPaths.Application_Resource = "Application/Resource"
you should then be able to use the class as normal. Since your path above will be checked before the default Zend one, you can also name your class 'Log' and still extend the Logger resource to override the standard functionality.
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 never had problems with CakePHP's theming system in the past, but now, errors galore. My main issue is that all theme resources (those in /app/views/themed/MyTheme/webroot/*) fail to load. I've set up a custom AppController in /app to set the theme.
var $view = "Theme";
var $theme = "MyTheme";
When I go to any page, I can see that it's utilizing my theme's default.ctp layout and the HTML is fine. Any and all page resources, CSS, JavaScript, images, anything in the theme webroot, fails to load and instead gives me an error like the following (let's say I tried to access http://example.com/theme/MyTheme/img/bg.png):
Error: ThemeController could not be found.
Error: Create the class ThemeController below in file: app/controllers/theme_controller.php
<?php
class ThemeController extends AppController {
var $name = 'Theme';
}
I've never received an error like this in my time with CakePHP. I'm running the latest stable version at 1.3.7.
I've finally found a solution. CakePHP didn't like my uppercase theme name. In fact, any theme name that I tried that included uppercase characters failed to work. I changed my folder name and internal theme name from "MyTheme" to "my_theme" and it worked perfectly. Could possibly be a bug, but it could be undocumented, yet expected functionality.