I am using cakephp 2.x to make one site multilingual and I am using the i18n extract and the TranslateBehavior Core Library.
The i18n works fine and the TranslateBehavior Core Library works fine when I try to save data. But when I want to read it I have to say to the controller the specific locale with:
$this->Home->locale = 'spa';
or
$this->Home->locale = 'eng';
Instead the core library makes it automatically by me. I have to specify all the times the locale? Or does exist something that do it automatically?
Thank you very much
There is a detailed article about i18n on Cakephp 1.3, I hope your 2.x will also work on this say theory so you can have a try with that http://codeatomic.com/developing-cakephp-multilingual-website/
Related
I've developed a bug tracker using CakePHP 2.4.4. I made this as a standalone cakephp app but now I wanna transfer it to a plugin, in order to reuse it in other projects.
As I already read at the docs (http://book.cakephp.org/2.0/en/plugins.html), I have followed the instructions from there and created the correct folder and files structure. This is what i've done so far: https://github.com/lubbleup/BugCake/tree/plugin
But now,when i try to use the plugin in a separate cakephp installation, I cannot understand how to make of the plugin and, for example, use it's controllers and functionality etc.
can anyone help me out here?
ps:this is my first time trying to create a cakephp plugin
Thank you in advance!
You have to load the plugins your parent app in APP/Config/bootstrap.php
CakePlugin::loadAll();
You do not need AppModel or AppController in your plugin. Your plugin has an own AppController/-Model named PluginNameAppController/PluginNameAppModel.
You can call your plugin at http://host/plugin_name/controller/action/[...]. In your case http://host/bug_cake/issues/view/1 for instance.
But you can also use custom routes in your plugin with plenty of options.
Hope that answers your question—if not, comment.
What's a good why to use CakePHP 1.3 for my website, but I have no database, since the site is pretty static?
You can use simple HTML to develop a site which is having all Static Content. And if it having a single contct page or something which you can develop in simple PHP. You don't need to use CakePHP for that.
CakePHP framework is used for web application that needs to interact more with databases.
Although I generally agree with gvLearner's point if you'd like to have a static html site, but still use some of CakePHP's abilities and be able to easily transform the site to a dynamic one in the future you can use Cake's built in Pages Controller.
The CakePHP core ships with a default controller called the Pages Controller that is generally used to serve static pages. Check out the documentation link I sent, I hope it'd would do you good.
Cheers,
Borislav.
I am using a couple of plugins in a CakePHP application that come with predefined translations in their Locale directories.
However, despite I have set the language setting, messages from these plugins are not being translated.
First question: can CakePHP retrieve those plugin translations by default or do I have to create my own translation files every time I use a plugin in a different application?
If CakePHP should retrieve the translations in plugin's Locale directory, is there something else I have to do besides setting Configure::write('Config.language', 'spa')?
Thank you!!
UPDATE: I am using CakePHP 2.1
I found this great article:
http://bakery.cakephp.org/articles/kalileo/2010/06/08/creating-pdf-files-with-cakephp-and-tcpdf
And it works fine with CakePHP 1.2, but I tried it with CakePHP 2.0 and the same Code results just a page with many strange characters.
Obviously there has something changed in CakePHP 2.0, but what is it?
Latest TCPDF works fine with Cakephp 2.0. The 'problem' you are having is mostly likely the browser displaying the PDF inline as html. It is caused by spurious whitespace at the end of controller/view files that causes the browser to assume text/html mimetype instead of PDF.
There have been a lot of 'breaking changes' from CakePHP versions 1.x to 2.x.
I have only looked at the TCPDF code briefly, but I would recommend you trying to update the code so that it works with 2.0. The main relevant changes are naming conventions and loading of Vendor files.
Follow the migration guide, and if you do manage to get it working, contact the author and share the code! Good luck :)
I am working on a project based on cakePHP 1.2.5. Now I need to use new JS helper defined in cakePHP 1.3.7.
I want to use some methods of JS helper like $this->Js->buffer("some code"),
$this->Js->writeBuffer()...
Is it possible to include this JS helper only to cakePHP 1.2.5? and How?
Thanks
I don't think you can because the basic way of calling the class has changed. In 1.2.5 the helper classes were not attached to the $this object in your view.
I think the better question would be to see if you can upgrade from 1.2 to 1.3. What are the requirements keeping you from upgrading, if any.
I would update your project to the current version of cakephp. A lot of bugs were fixed and other things were optimized.
But you can use the normal php or javascript functions...or build your own methods to solve your problem...
You could try to copy the JsHelper and its dependencies (HtmlHelper, FormHelper, and the engine helper for the Javascript framework you use) to the helpers folder of your application, though I don't know whether this will work...
However, even if this should work it is a hack, and I would consider to upgrade to CakePHP 1.3.x or to write your own helper providing the desired functionality.