I've just started with CakePHP and am having a problem withe the concept of plugins and components.
The main issue is how to include their views in my own app. For example, on the cakephp site, there is a tutorial for plugins, but they never mention how to include it in the output of my own app.
I want to create a login bar that appears on every page of my site. You know, something that either says Username Password or Welcome Fred Flintstone at the top of every page.
It seems a plug-in would be best for this as it could be included in every controller I created. But, as I mentioned, I have no idea how to include the plugin view with my app views.
lee
In this case, you would create an element:
/app/View/Elements/login_bar.ctp
echo $this->Form->create('User');
echo $this->Form->inputs(array('username', 'password'));
echo $this->Form->end('login');
and include it in your views (or layout) with:
echo $this->Element('login_bar');
See: http://book.cakephp.org/2.0/en/views.html#elements
Related
I have a website that has links which, if clicked, should open a new tab and load that particular website.
I've tried using this example:
<?php echo $this->Html->link('CakeBook', 'http://cakephp.org', array('class'=> 'myclass', 'target'=>'_blank')); ?>
The problem is it isn't even clickable. I'm using CakePHP 2.5.5
Has anyone successfully been able to do this?
I want MediaWiki and PHPBB to have the same header and footer as my website (default.ctp)
So instead of
<?php echo $content_for_layout; ?>
I would want to echo PHPBB or MediaWiki.
If you have a code example please paste here,
many thanks
Integrating PhpBB or Mediawiki with Cake will not be a quick job. The easiest thing to do is to install those applications separately and load them in an iframe.
I'm pretty new to CakePHP and i'm running through both the Cake Book and the Apress Book CakePHP from novice to professional, but i can't seem to understand what's going on on my bake console.
I've got it installed and seems to work fine. But when i type in cake bake it shows me this
Welcome to CakePHP v2.0.0 Console
--------------------------------------------------------------------
App: htdocs
Path: W:\xampp\htdocs\
--------------------------------------------------------------------
What is the path to the project you want to bake?
[W:\xampp\htdocs\myapp] >
instead of what the books say it should be
---------------------------------------------------------------
App : app
Path: /path-to/project/app
---------------------------------------------------------------
Interactive Bake Shell
---------------------------------------------------------------
[D]atabase Configuration
[M]odel
[V]iew
[C]ontroller
[P]roject
[F]ixture
[T]est case
[Q]uit
What would you like to Bake? (D/M/V/C/P/F/T/Q)
>
if i follow the questions on my cake console, it asks me the path to the directory layout i wish to copy, and then seems to override everything i have with that skel one.
on the other hand, if i follow the book's steps and type cake bake view or cake bake model it seems to understand that i'm talking about projects named view and model and tell me there's no database configuration for those projects, etc. So, if i type the project path first, i don't get to choose what to do. But if i leave it out, it has no way of knowing. See where this is going?
I'm using the regular Windows cmd.exe, not cygwin as i've seen some people recommending, and can provide more detail if needed. There's probably an easy solution for this, so I appreciate your help!
you are in the wrong path.
If you want to bake internal stuff (models, controllers, views, ...) etc
you need to navigate to the app folder and execute cake there
(or define your app path with -app)
details and hot tip for windows:
http://www.dereuromark.de/tag/cake-console-windows/
I am not a newbie cakephp developer however I won't call myself as an intermediate level cakephp programmer.
I came across a strange behavor what I could not handle.
I've build up an app with default views. First customer needs themeing so I decided to use the cakephp theme feature and started to make a theme with views, layouts etc.
I am using cakephp 1.3.8.
Everything works fine except I can't log in. Cakephp redirects me to an impossible place, the search controller with search results. It simply could not happen.
With the default views everything works fine.
What could be the reason? Could it be a bug in Auth component? Where should I start to debug this and how?
Thanks.
edit:
I made a copy of my default views into a new theme, and changed the $theme variable to this new theme. Everything works, so Auth and Theme facilities are fine, the reason should be my first theme. How a theme, or view file affects on login processing and/or Auth redirections? I still do not know how to find the bug in my views :(. I've set debug to 2, also checked the logs in tmp/logs but there ares now infos. Any idea?
SOLVED
I found the problem, a $this->Form->end() was missing from the searchbox element so the login data was submitted to the products controller search method, therefore the login wasn't processed.
Was my fault.
My CakePHP Folder Structure
1. app / webroot / img
2. cake
3. vendors
4. assets
<?php echo $html->image('cake_logo.png', array('alt' => 'CakePHP'))?>
Is it possible to access my external asset directory with the CakePHP Image helper?
I've never tried this, but I believe that Cake relies on the web server to serve up image assets by default. This would suggest that, no, you can't move your images outside of your web root and still use the HTML helper's image() method.
You can, however, use media views to send binary information to users. It works outside of the core helpers, but might meet your needs.
Try to go up the directory by adding ../ at the front of image file as many times as it is necessary like this:
echo $html->image('../../special_assets_folder/cake_logo.png');
That worked for me in some cases.