Re: Many to Many with extra data

2013-01-01 Thread Anis Ghabri
Thanks and happy new year,
I'm going to make it as a you said. 

BUT a simple question how can I add new data and update data to the table1 
and the table1_table2 on the same form.

Le lundi 31 décembre 2012 15:54:20 UTC+1, jsundquist a écrit :

 Your joining table needs to be become its own model as a belongs to for 
 Table1 and Table2 and then Table2 has many Table1_Table2 and same for 
 Table1.


 On Mon, Dec 31, 2012 at 5:34 AM, Anis Ghabri ghabr...@gmail.comjavascript:
  wrote:

 Hi
 I couldn't find the to solve this.
 here is my problem

 I have two tables related with many to many relation

 *Table1(id, t1_field1, t1_field2,...);*

 *Table2(id, t2_field1, t2_field2,...);*

 and the association table

 *table1_table2(id,table1_id,table2_id,extra_field1, extra_field2, 
 extra_field3);*

 My problem is how to add these extra fields; When I try it only adds the 
 two tables ids and nothing else.

 Pleas Help

 regards

 -- 
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP
  
 --- 
 You received this message because you are subscribed to the Google Groups 
 CakePHP group.
 To post to this group, send email to cake...@googlegroups.comjavascript:
 .
 To unsubscribe from this group, send email to 
 cake-php+u...@googlegroups.com javascript:.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.
  
  




-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Deleting Data From Other Model/Controller

2013-01-01 Thread Insert Code
Hi all,

I'm new to CakePHP and I could do with some newbie advice please.

I'm creating an invoicing application and the way I have it set up is with 
seperate tables (and so Models and Controlllers) for* Invoices* and *Items*. 
The *Invoice* table holds the data such as 'Invoice Number', 'Date' and  
'Client ID' for example, and the* Items* table stores individual 
records/items that make up each invoice with 'Quantity', 'Unit Price' etc. 
The two are associated correctly.

When I call the 'edit' view for Invoices, obviously passing an ID, I 
retrieve the record and then also loop through the all associated records 
returned from the *Items* table to - all works as planned and are retrieved 
and displayed correctly.

What I want to be able to do from this view though, is to be able to delete 
individual items from the invoice by clicking on a delete button next to 
each - ideally with a confirmation box. How would this be acheived exactly? 
What would be the best method? Would I use a function in the Items 
controller to do this without leaving the page? How would I call the 
function in that controller from the Invoice controller/view? Or would 
another method such as the CakePHP query() function be used for this?

I hope I've explained this setup clearly enough for someone to offer any 
help and/or advice for which I would be very thankful.

Thanks in advance,

Adam

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Admin as a plugin

2013-01-01 Thread Yusuf Abdulla Shunan


 You can use the admin section as a plugin, something like: 
 https://github.com/Maldicore/Admin

 Regards



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Admin Section as plugin

2013-01-01 Thread Yusuf Abdulla Shunan
You can use the admin section as a plugin, something like: 
https://github.com/Maldicore/Admin

Regards

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: cakephp admin app

2013-01-01 Thread Yusuf Abdulla Shunan
You can use the admin section as a plugin, something like: 
https://github.com/Maldicore/Admin

Regards

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Cake Bake cannot connect to my database

2013-01-01 Thread Fernando Fl
Try to use:

Terminal:
sudo mkdir /var/mysql

sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock


Em sexta-feira, 21 de outubro de 2011 13h34min04s UTC-4, Nate escreveu:

 In manually setting everything up, I'm able to successfully add, 
 modify, view, and remove products with scaffolding enabled. 

 However, when I go into Bake, and I choose to create a [C]ontroller - 
 it then asks for my database (default).  I confirm that setting and I 
 get this error: 

 Warning Error: PDO::__construct(): [2002] No such file or directory 
 (trying to connect via unix:///var/mysql/mysql.sock) in [/Users/nate/ 
 Sites/tor.local/html/lib/Cake/Model/Datasource/Database/Mysql.php, 
 line 160] 

 Any ideas? Thanks

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Correct way to handle ajax forms

2013-01-01 Thread Advantage+
Just wondering what is the correct way to handle processing forms submitted
via ajax / json response?

 

What I have been doing is converting my add / edit forms into a single
element and placing them into the view/add/edit where needed so on error all
I need to do is return the form element or on success whatever is needed
success message.

 

In the controller :

 

if ( $this-Model-save($this-request-data, true)) {

 


$response = array(

'status' = true,

'html' =
$this-render($this-autoElement('added_block'))-body(),

'message' = 'Saved!');

} else {

 


$this-set('errors', $this-Model-validationErrors);

$response = array(

'status' = false,

'html' =
$this-render($this-autoElement('form'))-body(),

'message' =  'Please
correct the following errors and try again!' );

}

$this-_ajaxReturn( $response ); //simply encodes $response array to json
that gets passed to the js

 

This way the js can act according to the response status and has all the
HTML info ready to drop into my div or where ever and has all the Cake
inputs with errors. Is this going about it wrong? Or is there an easier way?

Just curious how others are approaching this.

 

Thanks,

 

Dave

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: CAKEPHP 2.1.x on Pagodabox | foreach multiple items for each slide (bootstrap carousel)

2013-01-01 Thread lowpass
Is it possible that the other divs are being generated, but are
hidden? What do the item  active class rules look like? Or maybe some
JS is keeping the others from displaying? Try disabling the carousel
activation code.

On Sun, Dec 30, 2012 at 1:55 PM, SvenP s...@dskbvba.be wrote:
 Yes,

 Each ad relates to a sponsor... works perfect.

 array(
   (int) 0 = array(
   'Ad' = array(
   'id' = '2',
   'sponsor_id' = '0',
   'title' = '...',
   'body' = '...',
   'link' = 'wwwcom'
   ),
   'Sponsor' = array(
   'id' = '8',
   'name' = ...,
   'contact_first_name' = ...,
   'contact_name' = ...,
   'contact_tel' = ...,
   'contact_email' = ...
   )
   ),


 On Sunday, December 30, 2012 7:20:54 PM UTC+1, cricket wrote:

 die(debug($ads));

 Are you certain of the array structure?

 On Sat, Dec 29, 2012 at 5:39 PM, SvenP sv...@dskbvba.be wrote:
  Hi,
 
  I'm looking for a way to show multiple 'Ads' / slide with a foreach loop
  from the db. ( each client has ads tied to them.)
 
  My code now works great but only shows one ad / slide.
 
  Thanks for your time!
 
  Sven
 
  Code:
  ___
 
  div class=carousel-inner
  ?php foreach ($ads as $indexValue = $ad):
  if($indexValue == 0){?
  div class=item active
  a class=adshref href=//?php echo $ad['Ad']['link']??php echo
  $ad['Ad']['title']?/abr
  span class=adslink?php echo $ad['Ad']['link']?/spanbr
  span class=adsbody?php echo
  $ad['Ad']['body']?/spanbr/div?php
  } else { ?
  div class=item
  a class=adshref href=//?php echo $ad['Ad']['link']??php echo
  $ad['Ad']['title']?/abr
  span class=adslink?php echo $ad['Ad']['link']?/spanbr
  span class=adsbody?php echo $ad['Ad']['body']?/spanbr/div
  ?php } endforeach; ?  /div
 
  --
  Like Us on FaceBook https://www.facebook.com/CakePHP
  Find us on Twitter http://twitter.com/CakePHP
 
  ---
  You received this message because you are subscribed to the Google
  Groups
  CakePHP group.
  To post to this group, send email to cake...@googlegroups.com.
  To unsubscribe from this group, send email to
  cake-php+u...@googlegroups.com.
  Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: MY Site not working properlly

2013-01-01 Thread lowpass
Try setting debug to 2 in core.php. Also, check Cake's error.log as
well as the log for Apache.

On Mon, Dec 31, 2012 at 7:51 AM,  rhceb...@gmail.com wrote:
 Hi to all.


 I am new to cakephp, and tryd to upload one site, its based on cakephp frame
 work and hosted in linux  Apache, mysql db. whats the problem means my site
 is now up.

 i have home page in that page login information its asked i give user name 
 password it will redirect to another page.

 But the another page it will only show header information not values from DB
 may i know why?..

 please let me know.

 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: CAKEPHP 2.1.x on Pagodabox | foreach multiple items for each slide (bootstrap carousel)

2013-01-01 Thread Sven Pype
Hi,

The whole thing works perfectly and shows 1 ad for each slide.
My goal is to have 3 ads from the db in 1 slide...

I can't find a solution for it whit a foreach loop...

Thanks anyway.

Sven


On Tue, Jan 1, 2013 at 8:05 PM, lowpass zijn.digi...@gmail.com wrote:

 Is it possible that the other divs are being generated, but are
 hidden? What do the item  active class rules look like? Or maybe some
 JS is keeping the others from displaying? Try disabling the carousel
 activation code.

 On Sun, Dec 30, 2012 at 1:55 PM, SvenP s...@dskbvba.be wrote:
  Yes,
 
  Each ad relates to a sponsor... works perfect.
 
  array(
(int) 0 = array(
'Ad' = array(
'id' = '2',
'sponsor_id' = '0',
'title' = '...',
'body' = '...',
'link' = 'wwwcom'
),
'Sponsor' = array(
'id' = '8',
'name' = ...,
'contact_first_name' = ...,
'contact_name' = ...,
'contact_tel' = ...,
'contact_email' = ...
)
),
 
 
  On Sunday, December 30, 2012 7:20:54 PM UTC+1, cricket wrote:
 
  die(debug($ads));
 
  Are you certain of the array structure?
 
  On Sat, Dec 29, 2012 at 5:39 PM, SvenP sv...@dskbvba.be wrote:
   Hi,
  
   I'm looking for a way to show multiple 'Ads' / slide with a foreach
 loop
   from the db. ( each client has ads tied to them.)
  
   My code now works great but only shows one ad / slide.
  
   Thanks for your time!
  
   Sven
  
   Code:
   ___
  
   div class=carousel-inner
   ?php foreach ($ads as $indexValue = $ad):
   if($indexValue == 0){?
   div class=item active
   a class=adshref href=//?php echo $ad['Ad']['link']??php echo
   $ad['Ad']['title']?/abr
   span class=adslink?php echo $ad['Ad']['link']?/spanbr
   span class=adsbody?php echo
   $ad['Ad']['body']?/spanbr/div?php
   } else { ?
   div class=item
   a class=adshref href=//?php echo $ad['Ad']['link']??php echo
   $ad['Ad']['title']?/abr
   span class=adslink?php echo $ad['Ad']['link']?/spanbr
   span class=adsbody?php echo $ad['Ad']['body']?/spanbr/div
   ?php } endforeach; ?  /div
  
   --
   Like Us on FaceBook https://www.facebook.com/CakePHP
   Find us on Twitter http://twitter.com/CakePHP
  
   ---
   You received this message because you are subscribed to the Google
   Groups
   CakePHP group.
   To post to this group, send email to cake...@googlegroups.com.
   To unsubscribe from this group, send email to
   cake-php+u...@googlegroups.com.
   Visit this group at http://groups.google.com/group/cake-php?hl=en.
  
  
 
  --
  Like Us on FaceBook https://www.facebook.com/CakePHP
  Find us on Twitter http://twitter.com/CakePHP
 
  ---
  You received this message because you are subscribed to the Google Groups
  CakePHP group.
  To post to this group, send email to cake-php@googlegroups.com.
  To unsubscribe from this group, send email to
  cake-php+unsubscr...@googlegroups.com.
  Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.




-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Fixture for the model of a HABTM relationship generates invalid SQL

2013-01-01 Thread lowpass
First, try to stick with Cake's conventions. The class is GroupsMember
so the table should be groups_members. The columns should be member_id
and group_id.

Also, in a join table, you don't set the columns which are foreign
keys to be AUTO_INCREMENT. The columns they point to, in the groups
and members tables, are AUTO_INCREMENT so that the id is generated
automatically. What you want in the join table is the actual value
generated in the source tables. So member_id int(11) NOT NULL is
sufficient.

And in a join table, you can have a separate id column that is
incremented but it's usually unnecessary. Unless you have a good
reason for it you may as well remove that column. And instead of
setting a two-column PK you can make that a UNIQUE key instead.

Finally, you generally don't need to create a class for the join table
as you can use Cake's built-in methods from within the Member or Group
classes:

$this-GroupMember-find(...)


On Mon, Dec 31, 2012 at 8:32 AM,  pyr...@googlemail.com wrote:
 Hey,

 I'm having a slight issue with a fixture I'm attempting to create.

 Basically I have a Member model and a Group model, and they have a HABTM
 relationship, I've specified a custom model to handle this relationship
 'GroupsMember' as I wish to add methods to that model to query the join
 table directly.

 So when I set this table up in the databse (I use MySQL) I set it up like
 this:

 CREATE TABLE IF NOT EXISTS `member_group` (
 `member_id` int( 11 ) NOT NULL ,
 `grp_id` int( 11 ) NOT NULL ,
 PRIMARY KEY ( `member_id` , `grp_id` )
 ) ENGINE = InnoDB DEFAULT CHARSET = latin1;

 This was all working ok until I attempted to create a fixture for the
 'GroupsMember' model. The code I use to do that is as follows:

 class GroupsMemberFixture extends CakeTestFixture
 {
 public $useDbConfig = 'test';
 public $table = 'member_group';

 public $fields = array(
  'member_id' = array('type' = 'integer', 'null' = false, 'key' =
 'primary'),
  'grp_id' = array('type' = 'integer', 'null' = false, 'key' =
 'primary'),
   );

 public $records = array(
 array('member_id' = 0, 'grp_id' = 1),
 );
 }

 However, when I run the test I get the following error:
 SQLSTATE[42S02]: Base table or view not found: 1146 Table
 'instrumentation_test.member_group' doesn't exist

 So I decided to log all the SQL queries being generated, and the last one is
 this:

 CREATE TABLE `instrumentation_test`.`member_group` (
 `member_id` int(11) NOT NULL AUTO_INCREMENT,
 `grp_id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY  (`grp_id`))
 ENGINE=MEMORY;

 If I run that in phpMyAdmin then it fails with the following error:

 #1075 - Incorrect table definition; there can be only one auto column and it
 must be defined as a key

 So the addition of the AUTO_INCREMENT is messing things up, and the primary
 key is only set to be the grp_id not both the grp_id and the members_id.

 Is there any-way I can override the SQL cake is generating for this case?

 If I change it so that I create the table in the test database and tell the
 fixture to import the structure from there (using public $import =
 'GroupsMember';) then cake generates the following SQL:

 CREATE TABLE `instrumentation_test`.`member_group` (
 `member_id` int(11) NOT NULL AUTO_INCREMENT,
 `grp_id` int(11) NOT NULL AUTO_INCREMENT,
 `id` varchar(255) NOT NULL, PRIMARY KEY  (`id`)) ENGINE=MEMORY;

 which apart from adding the extra 'id' column has the same AUTO_INCREMENT
 issue.

 What is it that tells cakephp that those fields should be AUTO_INCREMENT?
 And is it possible for me to make cake specify the primary key as the same
 as it was for the table I generated?

 Thanks,
 Andrew

 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Cake 2.2 Auth login failure

2013-01-01 Thread lowpass
Do you have an entry in the users table with that username and
password = '1630f6b739b730992c43949161a4e4661939921a'?

On Mon, Dec 31, 2012 at 4:40 PM, Martin Halla thegoodb...@gmail.com wrote:
 Hi,

 I have this app that uses the Auth component for login Everything works on
 the local machine, but fails big time live at :

 http://ncln.halladesign.com

 Can you tell me why ?

 Here are more details :

 user : t...@test.com
 password : password
 acl plugin by alexo

 Thanks!

 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Many to Many with extra data

2013-01-01 Thread lowpass
See here:

http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#hasmany-through-the-join-model

On Tue, Jan 1, 2013 at 4:31 AM, Anis Ghabri ghabria...@gmail.com wrote:
 Thanks and happy new year,
 I'm going to make it as a you said.

 BUT a simple question how can I add new data and update data to the table1
 and the table1_table2 on the same form.

 Le lundi 31 décembre 2012 15:54:20 UTC+1, jsundquist a écrit :

 Your joining table needs to be become its own model as a belongs to for
 Table1 and Table2 and then Table2 has many Table1_Table2 and same for
 Table1.


 On Mon, Dec 31, 2012 at 5:34 AM, Anis Ghabri ghabr...@gmail.com wrote:

 Hi
 I couldn't find the to solve this.
 here is my problem

 I have two tables related with many to many relation

 Table1(id, t1_field1, t1_field2,...);

 Table2(id, t2_field1, t2_field2,...);

 and the association table

 table1_table2(id,table1_id,table2_id,extra_field1, extra_field2,
 extra_field3);

 My problem is how to add these extra fields; When I try it only adds the
 two tables ids and nothing else.

 Pleas Help

 regards

 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake...@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+u...@googlegroups.com.

 Visit this group at http://groups.google.com/group/cake-php?hl=en.




 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Deleting Data From Other Model/Controller

2013-01-01 Thread lowpass
You could create a deleteItem action in InvoicesController but the
only reason I would do that is if I needed to do something with the
Invoice at the same time. (And so would pass both the Invoice.id and
Item.id) If not, just create an admin_delete action in ItemsController
and use AJAX.

foreach($data['Item'] as $item)
{
?
div id=item_?= $item['id'] ?

...

?= $html-link(
'delete',
array(
'admin' = 1,
'controller' = 'Items',
'action' = 'delete',
'id' = $item['id']
),
array(
'title' = 'delete this item',
'class' = 'ItemDelete',
'rel' = $item['id']// so we don't need a 
regex to parse the id from URL
)
) ?

/div
?php
}

Basic JQuery:

$('a.ItemDelete').click(function(ev){

ev.preventDefault();

var id = $(this).attr('rel');

$.ajax({
url: $(this).attr('href'),
success:
function(data, textStatus, jqXHR)
{
// ...

$('#item_' + id).remove();
}
});

});

See the manual for howto handle AJAX calls from within your controller actions.

If you don't want to use AJAX, you have to pass the Invoice.id as well
so that Cake knows where to redirect to.

On Tue, Jan 1, 2013 at 8:05 AM, Insert Code cont...@insertcode.co.uk wrote:
 Hi all,

 I'm new to CakePHP and I could do with some newbie advice please.

 I'm creating an invoicing application and the way I have it set up is with
 seperate tables (and so Models and Controlllers) for Invoices and Items. The
 Invoice table holds the data such as 'Invoice Number', 'Date' and  'Client
 ID' for example, and the Items table stores individual records/items that
 make up each invoice with 'Quantity', 'Unit Price' etc. The two are
 associated correctly.

 When I call the 'edit' view for Invoices, obviously passing an ID, I
 retrieve the record and then also loop through the all associated records
 returned from the Items table to - all works as planned and are retrieved
 and displayed correctly.

 What I want to be able to do from this view though, is to be able to delete
 individual items from the invoice by clicking on a delete button next to
 each - ideally with a confirmation box. How would this be acheived exactly?
 What would be the best method? Would I use a function in the Items
 controller to do this without leaving the page? How would I call the
 function in that controller from the Invoice controller/view? Or would
 another method such as the CakePHP query() function be used for this?

 I hope I've explained this setup clearly enough for someone to offer any
 help and/or advice for which I would be very thankful.

 Thanks in advance,

 Adam

 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Correct way to handle ajax forms

2013-01-01 Thread lowpass
I haven't done much AJAX stuff with 2.2.x yet but that's basically
what I've always been doing. Generally, my add and edit templates just
include the form.ctp element. In that I have a
switch($this-params['action']) to decide how to open/close the form.
But the point is to be able to render and return just the form portion
of a view.

On Tue, Jan 1, 2013 at 1:45 PM, Advantage+ movepix...@gmail.com wrote:
 Just wondering what is the correct way to handle processing forms submitted
 via ajax / json response?



 What I have been doing is converting my add / edit forms into a single
 element and placing them into the view/add/edit where needed so on error all
 I need to do is return the form element or on success whatever is needed
 success message.



 In the controller :



 if ( $this-Model-save($this-request-data, true)) {



 $response = array(

 'status' = true,

 'html' =
 $this-render($this-autoElement('added_block'))-body(),

 'message' = 'Saved!');

 } else {



 $this-set('errors', $this-Model-validationErrors);

 $response = array(

 'status' = false,

 'html' =
 $this-render($this-autoElement('form'))-body(),

 'message' =  'Please
 correct the following errors and try again!' );

 }

 $this-_ajaxReturn( $response ); //simply encodes $response array to json
 that gets passed to the js



 This way the js can act according to the response status and has all the
 HTML info ready to drop into my div or where ever and has all the Cake
 inputs with errors. Is this going about it wrong? Or is there an easier way?

 Just curious how others are approaching this.



 Thanks,



 Dave

 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: CAKEPHP 2.1.x on Pagodabox | foreach multiple items for each slide (bootstrap carousel)

2013-01-01 Thread lowpass
But are you only trusting what the browser displays? Are the other
elements there in the source? What do you see when you disable
javascript? What about when you remove the active class?

On Tue, Jan 1, 2013 at 2:10 PM, Sven Pype s...@dskbvba.be wrote:
 Hi,

 The whole thing works perfectly and shows 1 ad for each slide.
 My goal is to have 3 ads from the db in 1 slide...

 I can't find a solution for it whit a foreach loop...

 Thanks anyway.

 Sven


 On Tue, Jan 1, 2013 at 8:05 PM, lowpass zijn.digi...@gmail.com wrote:

 Is it possible that the other divs are being generated, but are
 hidden? What do the item  active class rules look like? Or maybe some
 JS is keeping the others from displaying? Try disabling the carousel
 activation code.

 On Sun, Dec 30, 2012 at 1:55 PM, SvenP s...@dskbvba.be wrote:
  Yes,
 
  Each ad relates to a sponsor... works perfect.
 
  array(
(int) 0 = array(
'Ad' = array(
'id' = '2',
'sponsor_id' = '0',
'title' = '...',
'body' = '...',
'link' = 'wwwcom'
),
'Sponsor' = array(
'id' = '8',
'name' = ...,
'contact_first_name' = ...,
'contact_name' = ...,
'contact_tel' = ...,
'contact_email' = ...
)
),
 
 
  On Sunday, December 30, 2012 7:20:54 PM UTC+1, cricket wrote:
 
  die(debug($ads));
 
  Are you certain of the array structure?
 
  On Sat, Dec 29, 2012 at 5:39 PM, SvenP sv...@dskbvba.be wrote:
   Hi,
  
   I'm looking for a way to show multiple 'Ads' / slide with a foreach
   loop
   from the db. ( each client has ads tied to them.)
  
   My code now works great but only shows one ad / slide.
  
   Thanks for your time!
  
   Sven
  
   Code:
   ___
  
   div class=carousel-inner
   ?php foreach ($ads as $indexValue = $ad):
   if($indexValue == 0){?
   div class=item active
   a class=adshref href=//?php echo $ad['Ad']['link']??php echo
   $ad['Ad']['title']?/abr
   span class=adslink?php echo $ad['Ad']['link']?/spanbr
   span class=adsbody?php echo
   $ad['Ad']['body']?/spanbr/div?php
   } else { ?
   div class=item
   a class=adshref href=//?php echo $ad['Ad']['link']??php echo
   $ad['Ad']['title']?/abr
   span class=adslink?php echo $ad['Ad']['link']?/spanbr
   span class=adsbody?php echo $ad['Ad']['body']?/spanbr/div
   ?php } endforeach; ?  /div
  
   --
   Like Us on FaceBook https://www.facebook.com/CakePHP
   Find us on Twitter http://twitter.com/CakePHP
  
   ---
   You received this message because you are subscribed to the Google
   Groups
   CakePHP group.
   To post to this group, send email to cake...@googlegroups.com.
   To unsubscribe from this group, send email to
   cake-php+u...@googlegroups.com.
   Visit this group at http://groups.google.com/group/cake-php?hl=en.
  
  
 
  --
  Like Us on FaceBook https://www.facebook.com/CakePHP
  Find us on Twitter http://twitter.com/CakePHP
 
  ---
  You received this message because you are subscribed to the Google
  Groups
  CakePHP group.
  To post to this group, send email to cake-php@googlegroups.com.
  To unsubscribe from this group, send email to
  cake-php+unsubscr...@googlegroups.com.
  Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.



 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: CAKEPHP 2.1.x on Pagodabox | foreach multiple items for each slide (bootstrap carousel)

2013-01-01 Thread Sven Pype
Everything from the source is there, like I said, everything works as expected. 
If I remove the if($indexValue == 0) exception then I first get a blank slide 
and then the other Ads in slides.
Now I want to change the code to display 3 Ads in each slide.

Op 1-jan.-2013, om 21:05 heeft lowpass zijn.digi...@gmail.com het volgende 
geschreven:

 But are you only trusting what the browser displays? Are the other
 elements there in the source? What do you see when you disable
 javascript? What about when you remove the active class?
 
 On Tue, Jan 1, 2013 at 2:10 PM, Sven Pype s...@dskbvba.be wrote:
 Hi,
 
 The whole thing works perfectly and shows 1 ad for each slide.
 My goal is to have 3 ads from the db in 1 slide...
 
 I can't find a solution for it whit a foreach loop...
 
 Thanks anyway.
 
 Sven
 
 
 On Tue, Jan 1, 2013 at 8:05 PM, lowpass zijn.digi...@gmail.com wrote:
 
 Is it possible that the other divs are being generated, but are
 hidden? What do the item  active class rules look like? Or maybe some
 JS is keeping the others from displaying? Try disabling the carousel
 activation code.
 
 On Sun, Dec 30, 2012 at 1:55 PM, SvenP s...@dskbvba.be wrote:
 Yes,
 
 Each ad relates to a sponsor... works perfect.
 
 array(
  (int) 0 = array(
  'Ad' = array(
  'id' = '2',
  'sponsor_id' = '0',
  'title' = '...',
  'body' = '...',
  'link' = 'wwwcom'
  ),
  'Sponsor' = array(
  'id' = '8',
  'name' = ...,
  'contact_first_name' = ...,
  'contact_name' = ...,
  'contact_tel' = ...,
  'contact_email' = ...
  )
  ),
 
 
 On Sunday, December 30, 2012 7:20:54 PM UTC+1, cricket wrote:
 
 die(debug($ads));
 
 Are you certain of the array structure?
 
 On Sat, Dec 29, 2012 at 5:39 PM, SvenP sv...@dskbvba.be wrote:
 Hi,
 
 I'm looking for a way to show multiple 'Ads' / slide with a foreach
 loop
 from the db. ( each client has ads tied to them.)
 
 My code now works great but only shows one ad / slide.
 
 Thanks for your time!
 
 Sven
 
 Code:
 ___
 
 div class=carousel-inner
 ?php foreach ($ads as $indexValue = $ad):
 if($indexValue == 0){?
 div class=item active
 a class=adshref href=//?php echo $ad['Ad']['link']??php echo
 $ad['Ad']['title']?/abr
 span class=adslink?php echo $ad['Ad']['link']?/spanbr
 span class=adsbody?php echo
 $ad['Ad']['body']?/spanbr/div?php
 } else { ?
 div class=item
 a class=adshref href=//?php echo $ad['Ad']['link']??php echo
 $ad['Ad']['title']?/abr
 span class=adslink?php echo $ad['Ad']['link']?/spanbr
 span class=adsbody?php echo $ad['Ad']['body']?/spanbr/div
 ?php } endforeach; ?  /div
 
 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP
 
 ---
 You received this message because you are subscribed to the Google
 Groups
 CakePHP group.
 To post to this group, send email to cake...@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+u...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 
 
 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP
 
 ---
 You received this message because you are subscribed to the Google
 Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 
 
 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP
 
 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 
 
 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP
 
 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 
 
 -- 
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP
 
 --- 
 You received this message because you are subscribed to the Google Groups 
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to 
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

-- 
Like Us on 

Re: CAKEPHP 2.1.x on Pagodabox | foreach multiple items for each slide (bootstrap carousel)

2013-01-01 Thread lowpass
If all the slides are there then this isn't a Cake problem.

Also, you can remove the if/else and set the first div to have class
active in your JS.

On Tue, Jan 1, 2013 at 3:32 PM, Sven Pype s...@dskbvba.be wrote:
 Everything from the source is there, like I said, everything works as
 expected.
 If I remove the if($indexValue == 0) exception then I first get a blank
 slide and then the other Ads in slides.
 Now I want to change the code to display 3 Ads in each slide.

 Op 1-jan.-2013, om 21:05 heeft lowpass zijn.digi...@gmail.com het volgende
 geschreven:

 But are you only trusting what the browser displays? Are the other
 elements there in the source? What do you see when you disable
 javascript? What about when you remove the active class?

 On Tue, Jan 1, 2013 at 2:10 PM, Sven Pype s...@dskbvba.be wrote:

 Hi,

 The whole thing works perfectly and shows 1 ad for each slide.
 My goal is to have 3 ads from the db in 1 slide...

 I can't find a solution for it whit a foreach loop...

 Thanks anyway.

 Sven


 On Tue, Jan 1, 2013 at 8:05 PM, lowpass zijn.digi...@gmail.com wrote:


 Is it possible that the other divs are being generated, but are
 hidden? What do the item  active class rules look like? Or maybe some
 JS is keeping the others from displaying? Try disabling the carousel
 activation code.

 On Sun, Dec 30, 2012 at 1:55 PM, SvenP s...@dskbvba.be wrote:

 Yes,

 Each ad relates to a sponsor... works perfect.

 array(
  (int) 0 = array(
  'Ad' = array(
  'id' = '2',
  'sponsor_id' = '0',
  'title' = '...',
  'body' = '...',
  'link' = 'wwwcom'
  ),
  'Sponsor' = array(
  'id' = '8',
  'name' = ...,
  'contact_first_name' = ...,
  'contact_name' = ...,
  'contact_tel' = ...,
  'contact_email' = ...
  )
  ),


 On Sunday, December 30, 2012 7:20:54 PM UTC+1, cricket wrote:


 die(debug($ads));

 Are you certain of the array structure?

 On Sat, Dec 29, 2012 at 5:39 PM, SvenP sv...@dskbvba.be wrote:

 Hi,

 I'm looking for a way to show multiple 'Ads' / slide with a foreach
 loop
 from the db. ( each client has ads tied to them.)

 My code now works great but only shows one ad / slide.

 Thanks for your time!

 Sven

 Code:
 ___

 div class=carousel-inner
 ?php foreach ($ads as $indexValue = $ad):
 if($indexValue == 0){?
 div class=item active
 a class=adshref href=//?php echo $ad['Ad']['link']??php echo
 $ad['Ad']['title']?/abr
 span class=adslink?php echo $ad['Ad']['link']?/spanbr
 span class=adsbody?php echo
 $ad['Ad']['body']?/spanbr/div?php
 } else { ?
 div class=item
 a class=adshref href=//?php echo $ad['Ad']['link']??php echo
 $ad['Ad']['title']?/abr
 span class=adslink?php echo $ad['Ad']['link']?/spanbr
 span class=adsbody?php echo $ad['Ad']['body']?/spanbr/div
 ?php } endforeach; ?  /div

 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google
 Groups
 CakePHP group.
 To post to this group, send email to cake...@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+u...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.



 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google
 Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.



 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.



 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.



 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to 

RE: Correct way to handle ajax forms

2013-01-01 Thread Advantage+
In my form I also do the same thing to switch the open / closing with an if
statement for the add or edit that's being called.

-Original Message-
From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf
Of lowpass
Sent: Tuesday, January 01, 2013 4:32 PM
To: cake-php@googlegroups.com
Subject: Re: Correct way to handle ajax forms

I haven't done much AJAX stuff with 2.2.x yet but that's basically what I've
always been doing. Generally, my add and edit templates just include the
form.ctp element. In that I have a
switch($this-params['action']) to decide how to open/close the form.
But the point is to be able to render and return just the form portion of a
view.

On Tue, Jan 1, 2013 at 1:45 PM, Advantage+ movepix...@gmail.com wrote:
 Just wondering what is the correct way to handle processing forms 
 submitted via ajax / json response?



 What I have been doing is converting my add / edit forms into a single 
 element and placing them into the view/add/edit where needed so on 
 error all I need to do is return the form element or on success 
 whatever is needed success message.



 In the controller :



 if ( $this-Model-save($this-request-data, true)) {



 $response = array(

 'status' = true,

 'html' = 
 $this-render($this-autoElement('added_block'))-body(),

 'message' = 'Saved!');

 } else {



 $this-set('errors', $this-Model-validationErrors);

 $response = array(

 'status' = false,

 'html' = 
 $this-render($this-autoElement('form'))-body(),

 'message' =  'Please 
 correct the following errors and try again!' );

 }

 $this-_ajaxReturn( $response ); //simply encodes $response array to 
 json that gets passed to the js



 This way the js can act according to the response status and has all 
 the HTML info ready to drop into my div or where ever and has all 
 the Cake inputs with errors. Is this going about it wrong? Or is there an
easier way?

 Just curious how others are approaching this.



 Thanks,



 Dave

 --
 Like Us on FaceBook https://www.facebook.com/CakePHP Find us on 
 Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google 
 Groups CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.



--
Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter
http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




queries on HABTM relationships

2013-01-01 Thread Stefano Campanella
Hello all,
this is my first time posting here. I recently started to study how to use 
CakePHP and I'm trying to develop a website.
In my website I am writing a custom authorize component where each user get 
one or more groups and each group has one or more permissions associated to 
it.
I have problems in using the find() method.
This is my structure:
User hasAndBelongsToMany Group
Group hasAndBelongsToMany Perm

I have attached Containable to all the Models (in AppModel)

now in my authorization component I need to check if a group has a specific 
permission, and for this I use find():

if(!isset($this-controller()-Group)){
   $this-controller()-loadModel('Group');
 }
 $n_perm=$this-controller()-Group-find('count',array(
   'conditions'=array('id'=1),
   'contain'=array(
 'Perm'=array(
   'conditions' = array('id'='can_access_admin')
 )
   ) 

));


I would expect this to give me a result =1 if group 1 has the 
'can_access_admin' permission, and =0 if the group has no such permission.
This is not what actually happens, the only query that cakePHP shows is 
this:

SELECT COUNT(*) AS `count` FROM `groups` AS `Group` WHERE `id` = 1

And it is obviously not enough to find what I requested.

Can anyone help me?

Thanks

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: queries on HABTM relationships

2013-01-01 Thread Jeremy Burns | Class Outfit
Have you looked at the inbuilt Auth and ACL components? Might save you a lot of 
time.

Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 1 Jan 2013, at 22:23:58, Stefano Campanella leona...@guildofmessengers.com 
wrote:

 Hello all,
 this is my first time posting here. I recently started to study how to use 
 CakePHP and I'm trying to develop a website.
 In my website I am writing a custom authorize component where each user get 
 one or more groups and each group has one or more permissions associated to 
 it.
 I have problems in using the find() method.
 This is my structure:
 User hasAndBelongsToMany Group
 Group hasAndBelongsToMany Perm
 
 I have attached Containable to all the Models (in AppModel)
 
 now in my authorization component I need to check if a group has a specific 
 permission, and for this I use find():
 
 if(!isset($this-controller()-Group)){
   $this-controller()-loadModel('Group');
 }
 $n_perm=$this-controller()-Group-find('count',array(
   'conditions'=array('id'=1),
   'contain'=array(
 'Perm'=array(
   'conditions' = array('id'='can_access_admin')
 )
   ) 
 ));
 
 I would expect this to give me a result =1 if group 1 has the 
 'can_access_admin' permission, and =0 if the group has no such permission.
 This is not what actually happens, the only query that cakePHP shows is this:
 
 SELECT COUNT(*) AS `count` FROM `groups` AS `Group` WHERE `id` = 1
 
 And it is obviously not enough to find what I requested.
 
 Can anyone help me?
 
 Thanks
 
 -- 
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP
  
 --- 
 You received this message because you are subscribed to the Google Groups 
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to 
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.
  
  

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




CakePHP 1.2 Layout error

2013-01-01 Thread Marcus James
Hi,

I made a custom layout for admin panel. The problem is when i validated my
HTML i am getting an error

** *Non-space characters found without seeing a doctype first. Expected
!DOCTYPE html.*

On Firefox the layout renders perfectly when i inspect it but on google
chrome its showing an empty space inside body tag and all the html tag is
going inside body tag.

Any idea what the problem is?

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.