Re: send some result to elemetns

2012-04-15 Thread hoss7
thank you cricket

but i cant undrestand where i must put this code,this is my code:

i have one function in newscontroller like this:

function randomnews(){

$rnews=$this->News-find('first',array('order'=>'Rand()');
$this->set('news',$rnews);
}

i want send this result to some element : Elements/sidebar2.ctp

to show some random news in this element,i dont need user request this 
action,i need show automatic result when page loading 

i hope you can show me how can i edit this code to show result in elements

thanks

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


CakePHP (2.1) Media Plugin - Multi File Upload

2012-04-15 Thread double07
Hi All,

I'm using the cakephp media plugin in my project using the monolithic
style attachments table, i.e. all the attachments go in the one table
with foreign_key, model, group etc. saved with the file details. So my
model looks like:

class ProjectProfile extends AppModel {

var $name = 'ProjectProfile';
var $useDbConfig = 'default';
var $useTable = 'project_profiles';
var $actsAs = array('Media.Transfer', 'Media.Generator');

public $belongsTo = array(
'Project' => array(
'className' => 'Project',
'foreignKey' => 'pjID'
)
);

var $hasMany = array(
  'Photo' => array(
  'className' => 'Media.Attachment',
  'order' => 'Photo.basename, Photo.id',
  'foreignKey' => 'foreign_key',
  'conditions' => array('Photo.model' => 'ProjectProfile',
'Photo.group' => 'Photo'),
  'dependent' => true)
  );

Then a saveAll in the controller when saving my record saves the
attached file(s).

This all works fine, however I'd really like to be able to upload
multiple files at once, which the plugin does support by doing this in
the form:

echo $this->Form->hidden('Photo.0.model', array('value' => 'Photo'));
echo $this->Form->input('Photo.0.file', array('type' => 'file');
echo $this->Form->hidden('Photo.1.model', array('value' => 'Photo'));
echo $this->Form->input('Photo.1.file', array('type' => 'file');
echo $this->Form->hidden('Photo.2.model', array('value' => 'Photo'));
echo $this->Form->input('Photo.2.file', array('type' => 'file');

But I think you'd agree that's a bit cumbersome to have to click
browse for each individual file. The simplist method I could see to to
allow multiple file uploads was to use the HTML5 multiple file section
option - 
http://bakery.cakephp.org/articles/veganista/2012/01/31/html_5_multiple_file_upload_with_cake
:

echo $this->Form->input('files.', array('type' => 'file',
'multiple'));

This allows you to shift click in the file browser to select multiple
files then puts the files into an array to save... however, this field
format isn't handled by the media plugin. Also, there'd be no way to
add the model, group etc. fields on the save as far as I could see.

So, does anybody know how I can handle multi file uploads with the
media plugin using the monolithic model? I'm open to all suggestions.

Thanks in advance.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: How to redirect two pages back?

2012-04-15 Thread lowpass
On first display of the form pass the referer to the view to add it to the form.

echo $this->Form->input('Model.referer', array('value' => $referer));

public function add() {

if ($this->request->is('post')) {

$referer = isset($this->request->data['Model']['referer'])
? $this->request->data['Model']['referer']
: '/';  // or some other fallback route of your choice

// validate ...

if ($this->Model->save()) {

$this->redirect($referer);
}
else {
// flash msg, log, etc.
$this->set(compact('referer'));
}
}
else {
$this->set('referer', $this->referer());
}
}


You have to use the else block to set the view var because if the save
failed it would overwrite it to the empty form. Likewise, you need to
create the $referer method var before attempting to save so that it's
available either way (to redirect or reset the view var).



On Sun, Apr 15, 2012 at 4:15 PM, Daniel  wrote:
> I am using the following code to go back a page, but the problem is
> that the action is an "add" one so it just goes back to an empty "add"
> form:
>
> if ($this->request->is('post')) {
>        // blah blah ...
>        if ($this->Inemail->save($this->request->data)) {
>                // blah blah ...
>                $this->redirect($this->referer());
>
> I think what I need to do is go back two pages.  Is this possible?
>
> Thanks.
>
> --
> Our newest site for the community: CakePHP Video Tutorials 
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: How to redirect two pages back?

2012-04-15 Thread Daniel
On Apr 15, 9:22 pm, Matt Murphy  wrote:
> You need to capture your post array for the form and feed it back into the
> new loaded form.

OK, but how do I do that?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: How to redirect two pages back?

2012-04-15 Thread Matt Murphy
You need to capture your post array for the form and feed it back into the
new loaded form.

Cheers,
Matt
On Sun, Apr 15, 2012 at 4:15 PM, Daniel  wrote:

> I am using the following code to go back a page, but the problem is
> that the action is an "add" one so it just goes back to an empty "add"
> form:
>
> if ($this->request->is('post')) {
>// blah blah ...
>if ($this->Inemail->save($this->request->data)) {
>// blah blah ...
>$this->redirect($this->referer());
>
> I think what I need to do is go back two pages.  Is this possible?
>
> Thanks.
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


How to redirect two pages back?

2012-04-15 Thread Daniel
I am using the following code to go back a page, but the problem is
that the action is an "add" one so it just goes back to an empty "add"
form:

if ($this->request->is('post')) {
// blah blah ...
if ($this->Inemail->save($this->request->data)) {
// blah blah ...
$this->redirect($this->referer());

I think what I need to do is go back two pages.  Is this possible?

Thanks.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Model Validation field names

2012-04-15 Thread lowpass
You could use Cake's translation.

locale/eng/LC_MESSAGES/default.po:

msgid "password_control"
msgstr "Confirm Password"



But I notice you're already using the __() function elsewhere. If
you've already got a multilingual app then this may not be the best
choice (depending on your other field names and whether they appear in
other text messages). If you don't plan to ever make it multilingual,
don't use __() to echo arbitrary text as it'll just slow things down
needlessly.

On Fri, Apr 13, 2012 at 5:06 PM, CyberGlitch  wrote:
> Sort of a unique situation but maybe not? I'm curious if it's possible
> to change the "field" name when being displayed in validationErrors.
> Something that could be set in the model would make the most sense but
> can't seem to find what I'm looking for.
>
> Background. Doing custom flash messages and for bad ones.
>
> $this->set('errors', $this->User->validationErrors);
> $this->Session->setFlash('The user could not be saved. Please, try
> again.','flash_bad');
>
> Then in flash_bad element have.
>
>                                                                                echo $message;
>                                        if (!empty($errors)) { ?>
>                                                
>                                                         are ');?>  php __('error(s) in your submission:'); ?>
>                                                        
>                                                                 ($errors as $field => $error) { ?>
>                                                                 ucfirst($field) .' - '. $error; ?>
>                                                                
>                                                        
>                                                
>                                        
>
> Some of the table field names aren't self explanatory. Easy example in
> doing a password repeat verification.
>
> 2 fields
> password
> password_control
>
> Error message generates
> Password - At least 6 characters
> Password_control - Does not match
>
> So is there a way, again thinking in the model, to set a different
> field name to be shown for the error messages and possibly other
> things.
>
>                'password_control' => array(
>                        'notempty' => array(
>                                'rule' => array('notEmpty'),
>                                'allowEmpty' => false,
>                                'message' => 'Does not match',
> ->                      'displayField' => 'Confirm Password'
>                        )
>
> to then get
> Password - At least 6 characters
> Confirm Password - Does not match
>
> --
> Our newest site for the community: CakePHP Video Tutorials 
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: send some result to elemetns

2012-04-15 Thread lowpass
Disable autoLayout and set the controller's view to the element. If
this is an AJAX request and you're using RequestHandler, it will deal
with the first. Then just render.

$this->set('data', $some_data);

if ($this->RequestHandler->isAjax())
{
$this->viewPath = 'Elements'.DS.'FooBars';
$this->render('element_name');
}


On Sun, Apr 15, 2012 at 3:00 AM, hoss7  wrote:
> hi
> i have news controller,in this contoller i have some function for show
> random news.
> i want send this array result to some element.
> what i am must to do?
>
> thanks
>
> --
> Our newest site for the community: CakePHP Video Tutorials 
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: JSON response!

2012-04-15 Thread lowpass
Sending both concurrently makes no sense. What is it you're trying to do?

On Sat, Apr 14, 2012 at 10:38 AM, Serkan Sipahi  wrote:
> hi,
>
> i remove Router::parseExtensions('json');
>
> My wish is to do something like this:
>
>      class SomeController extends AppController {
>
>     public $components = array(
>     'RequestHandler'
>     );
>
>     public function index(){
>
>             /
>     json response
>     /
>     $this->RequestHandler->setContent('json', 'application/json' );
>     $this->set('test', array(
>     'Hallo World!',
>     ));
>     $this->set('_serialize', array('test'));
>
>             /
>     html response
>     /
>     $this->RequestHandler->setContent('html', 'text/html, */*' );
>     $this->set('test_2', array(
>     'Hallo World 2',
>     ));
>     }
>     }
>
>     is that possible?
>
> 
> Von: stork 
> An: cake-php@googlegroups.com
> CC: Serkan Sipahi 
> Gesendet: 15:56 Samstag, 14.April 2012
> Betreff: Re: JSON response!
>
> If you called Router::parseExtensions() in routes.php, you don't need to
> call $this->RequestHandler->
> setContent() manually - as long as requested URI does have .json extension
> at the end or ajax request was called with proper dataType/accept request
> header.
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at
> http://groups.google.com/group/cake-php
>
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at
> http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Redirect www to non-www

2012-04-15 Thread lowpass
On Sat, Apr 14, 2012 at 2:19 PM, creat1v1ty  wrote:
> cool, thanks euromark. Will you please confirm which .htaccess file this
> should go in, based on my doc root being public_html...

In #1 -- the one directly inside public_html.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


admin/users to /profile route

2012-04-15 Thread shrijan piya
I am newbie to cakephp. 
Currently working on localhost and have url as below 

http://localhost/test/admin/Users

but wants it to be 

http://localhost/test/Users


Note Condition: 
when not login 
http://localhost/test/Users
should work with index.ctp 
when login 
http://localhost/test/Users
should work with admin_index.ctp 

Router::connect('/admin/users',
 
array( 'controller'=>'Users','action' => 'index','profile')); 

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


using other css themes

2012-04-15 Thread sixthpoint
I am using subdomains, each subdomain loads a specific theme folder. I
also have a "global" theme which has global.css in it. I want to be
able to load that theme from my current subdomain location. The issue
is that when I use the html-css helper it loads the current themes
css. How can I load other themes css?

thanks in advance.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Identifying field in Authentication

2012-04-15 Thread hoss7
thank you rodrigo,but i have error.

this is my code:

before:

public $components = array(
'Acl',
'Auth' => array(
'authorize' => array(
'Actions' => array('actionPath' => 'controllers')
)
)
)
after change:
public $components = array(
'Acl',
'Auth' => array(
'authorize' => array(
'Actions' => array('actionPath' => 'controllers'),
'authenticate' => array(
'Form' => array(
'scope' => array('User.valid' => 1)
)
)
)
)

this is my error:

Authorization adapter "authenticate" was not found.

note:
befor i edit my code i can login and logout and  now with this code i can 
only login and when i want logout i see this error.
*i want only valid user(User.valid=1) can login*


-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


404 and other error pages

2012-04-15 Thread heohni
Hi, 

I googled quite some time arround but I only find here and there some hint, 
but I found never a kind of complete instruction how to setup custom error 
layouts for my project.
I am using Cake 2.1.
Does anyone know a good tutorial link?
I aslo read in the book, but I find it also quite hard to start with it
And the most other pages I found in Google are from 2006ish and relate to 
cake 1.2/3

Hope that anyone has a good source!
Thanks!!

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Identifying field in Authentication

2012-04-15 Thread Rodrigo Rodrigues Moyle
USe the scope option in FormAuthenticate

http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#configuring-authentication-handlers

Em domingo, 15 de abril de 2012 06h00min44s UTC-3, hoss7 escreveu:
>
> hi 
> Username and Password is default  filed for identifying users  in 
> cakephp ,how can i check  this field “User.valid  = 1 ” with default 
> filed for identifying user?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


using SSL login leads to 404 Error

2012-04-15 Thread luftlinie
hi everyone,

i want to secure the login with SSL and use the Security Component for
that. cake seems to swith to HTTPS
but has trouble calling the new URL

https://server/users/login

giving me a 404 error. I understand this is fixable with $this-
>Security->blackHoleCallback
but how? what am i doing wrong?

CODE: controller users

function beforeFilter()
{

$this->Security->blackHoleCallback = 'forceSSL';
$this->Security->requireSecure('login');

parent::beforeFilter();
$this->Auth->allow('*');

}



function forceSSL()
{
$this->log('Redirecting user from HTTP to HTTPS', 'https');
$this->redirect('https://' . $_SERVER['SERVER_NAME'] . $this-
>here);

}



appreciate your help. thanks a lot :)

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Identifying field in Authentication

2012-04-15 Thread hoss7
hi
Username and Password is default  filed for identifying users  in
cakephp ,how can i check  this field “User.valid  = 1 ” with default
filed for identifying user?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: CakePHP 2.1.1 Auth/ACL PHPUnit

2012-04-15 Thread rossjha
Hi thanks for getting back to me, yes I stripped back my login action and I 
have setFlash, working and I have the session comp in my app_controller.  If I 
try the auth comp I get the same error.  If I var_dump I can see the mock obj 
are there but with empty values.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re:

2012-04-15 Thread Reza Talamkhani
Note: I have use CakePHP 2.1

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: send some result to elemetns

2012-04-15 Thread hoss7

Note: i have cake php 2.1

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


[no subject]

2012-04-15 Thread Reza Talamkhani
Hi.
I need to fetch all gallery rows in every page in application.
How to fetch?
Note: Gallery Model is defined but i do'nt understand how to do?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


send some result to elemetns

2012-04-15 Thread hoss7
hi
i have news controller,in this contoller i have some function for show
random news.
i want send this array result to some element.
what i am must to do?

thanks

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php