Re: CakePHP 1.3 - Plugin asset loading - override Core.php compression rewrite

2013-11-06 Thread Jamie
What about putting symlinks in the main application's webroot that point to 
the plugin assets? Then the assets are still technically in the plugin 
folder structure, but are served from the 'real' webroot (and thus you can 
take advantage of that).

On Wednesday, November 6, 2013 2:25:36 PM UTC-8, Jas3n wrote:
>
> My current workaround is to load the plugin assets as elements. 
> I've placed them in the following path "/plugin_name/views/elements/css/", 
> name them in the following format: "*filename.css.ctp*" and then call 
> them from the view(s) using the following:
>
> element('css/filename.css'); ?>
>
> This allows me to keep all the plugin assets within the plugin directory 
> so that it is completely separate from the main application.
>
>
> On Tuesday, October 29, 2013 10:48:47 AM UTC-4, Jas3n wrote:
>>
>> I'm working with an existing CakePHP (ver. 1.3) application.  The main 
>> application utilizes CSS and JS compression via the /config/core.php file. 
>>  My project is to develop proprietary functionality into this application 
>> which I'm integrating as a CakePHP plugin.  Now there have been very few 
>> hitches while developing as a Plugin, but the issue below is one that I 
>> haven't been able to locate a solution for.
>>
>> Since the compression config option is enabled in the main CakePHP 
>> core.php file, anytime I try to load CSS or JS within the plugin files to 
>> it's internal plugin assets location (/app/plugins/plugin_name/webroot/) 
>> it's automatically rewriting the folder to the cached folder 
>> "/plugin_name/webroot/ccss" or "/plugin_name/webroot/cjs" as it's supposed 
>> to for the main application.  This is the case regardless if I load via the 
>> cake helpers or using standard tagging.
>>
>> Now I do not have any issues loading plugin image assets using the helper 
>> and the plugin path "/plugin_name/img/".  So, I can only assume that this 
>> is all related to the rewriting of the CSS and JS paths for the compression 
>> option.
>>
>> So, is there a way to override the path rewriting for the plugin assets?  
>> Can my plugin define it's own config to compress its CSS and JS files 
>> separately (this would be nice to implement later on, but not necessary)? 
>> Am I just completely off-base with my approach to this situation 
>> altogether, lol? 
>>
>> I would like to keep all the plugin files (including the assets) inside 
>> the plugin folder for numerous reasons.  Therefore, I'd like to avoid the 
>> alternative solution that would require files to be placed in the main 
>> application (not inside the plugin folder) if at all possible.
>>
>> Thanks in advance for your responses!
>>
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Best Practice Question - Components

2013-11-06 Thread Reuben Helms
I would say that calculations, and verification of amounts would be perfect
functionality to place on the model.  You wouldn't normally need a
controller to determine the sum of items in an order, so why put it in a
controller.

For a shopping cart, you still might use a model to store the cart contents
and cart items.  You might query the cart to see what the total value is.
 This is not a calculation that the controller would need to make, so you
wouldn't need to do it in a component either.  All business logic for an
entity should stay with the entity, and the model is the perfect place for
that.

What you might put in the component is functionality to load a cart that is
attached to the session, or clear the cart from the session, if the user
requests it, or save cart modifications to the session at the end the
controller lifecycle.

Interesting to note, in CakePHP 3.0, the model will be split between an
Entity and a Table.  The Table will take care of the schema, and typical
database/CRUD operations, while the Entity will concentrate more on the
business logic side of things.

Regards
Reuben Helms


On Thu, Nov 7, 2013 at 10:08 AM, Kristen M  wrote:

> Yeah, the point of the exercise is to do things the "Cake Way" and take
> advantage of all things automagical and Cake. ;)
>
> After puzzling over the docs for a bit and realizing it's not bad form to
> have a controller use multiple models, I decided that splitting the
> existing classes into a model and a component was probably the "correct"
> solution. The model handles all the data, while the component contains
> common functions all controllers that use the model will need, like
> calculations and verification of amounts.
>
>
>
>
>  --
> 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 a topic in the
> Google Groups "CakePHP" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/cake-php/M6i0tin0b5Q/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> cake-php+unsubscr...@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Best Practice Question - Components

2013-11-06 Thread Kristen M
Yeah, the point of the exercise is to do things the "Cake Way" and take 
advantage of all things automagical and Cake. ;) 

After puzzling over the docs for a bit and realizing it's not bad form to 
have a controller use multiple models, I decided that splitting the 
existing classes into a model and a component was probably the "correct" 
solution. The model handles all the data, while the component contains 
common functions all controllers that use the model will need, like 
calculations and verification of amounts. 




-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Re: CakePHP 1.3 - Plugin asset loading - override Core.php compression rewrite

2013-11-06 Thread Jas3n
My current workaround is to load the plugin assets as elements. 
I've placed them in the following path "/plugin_name/views/elements/css/", 
name them in the following format: "*filename.css.ctp*" and then call them 
from the view(s) using the following:

element('css/filename.css'); ?>

This allows me to keep all the plugin assets within the plugin directory so 
that it is completely separate from the main application.


On Tuesday, October 29, 2013 10:48:47 AM UTC-4, Jas3n wrote:
>
> I'm working with an existing CakePHP (ver. 1.3) application.  The main 
> application utilizes CSS and JS compression via the /config/core.php file. 
>  My project is to develop proprietary functionality into this application 
> which I'm integrating as a CakePHP plugin.  Now there have been very few 
> hitches while developing as a Plugin, but the issue below is one that I 
> haven't been able to locate a solution for.
>
> Since the compression config option is enabled in the main CakePHP 
> core.php file, anytime I try to load CSS or JS within the plugin files to 
> it's internal plugin assets location (/app/plugins/plugin_name/webroot/) 
> it's automatically rewriting the folder to the cached folder 
> "/plugin_name/webroot/ccss" or "/plugin_name/webroot/cjs" as it's supposed 
> to for the main application.  This is the case regardless if I load via the 
> cake helpers or using standard tagging.
>
> Now I do not have any issues loading plugin image assets using the helper 
> and the plugin path "/plugin_name/img/".  So, I can only assume that this 
> is all related to the rewriting of the CSS and JS paths for the compression 
> option.
>
> So, is there a way to override the path rewriting for the plugin assets?  
> Can my plugin define it's own config to compress its CSS and JS files 
> separately (this would be nice to implement later on, but not necessary)? 
> Am I just completely off-base with my approach to this situation 
> altogether, lol? 
>
> I would like to keep all the plugin files (including the assets) inside 
> the plugin folder for numerous reasons.  Therefore, I'd like to avoid the 
> alternative solution that would require files to be placed in the main 
> application (not inside the plugin folder) if at all possible.
>
> Thanks in advance for your responses!
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Can anybody help me with this postLink() delete?

2013-11-06 Thread kushal i s
Thanks els.
You saved my time...

On Wednesday, 8 August 2012 18:24:12 UTC+5:30, els wrote:
>
> Hi amprodes,
>
> I had the same problem. The cookbook states that you should not use 
> postlinks inside another form.
> I think removing the Account form will do the trick.
>
> hope this helps,
> Els
>
>  
> Move the postlink
> On Friday, August 3, 2012 3:32:33 PM UTC+2, amprodes wrote:
>>
>> * What I did*
>>
>> *1.- This is my model:*
>> *
>> --
>> *
>>
>>   
>>  class Account extends AppModel {
>>  public $name = 'Account'; 
>>  public $belongsTo = array(
>>  'Client' => array(
>> 'className' => 'Client',
>> 'foreignKey' => 'client_id'
>> ),
>> 'Accounttype' => array(
>> 'className' => 'Accounttype',
>> 'foreignKey' => 'accounttype_id'
>> )
>> );
>>  
>>  public $hasMany = array(
>>  'Event' => array(
>> 'className' => 'Event',
>> 'foreignKey' => 'account_id',
>> 'dependent'=> true
>> ), 
>> 'Plot' => array(
>> 'className' => 'Plot',
>> 'foreignKey' => 'account_id',
>> 'dependent'=> true
>> ),
>>  'Widget' => array(
>> 'className' => 'Widget',
>> 'foreignKey' => 'account_id',
>> 'dependent'=> true
>> )  
>>  ); 
>>  
>>  
>> }
>> 
>>
>> *
>> --
>> *
>> *
>> *
>> *2.- **This is my controller:***
>> *
>> --
>> *
>>
>> 
>>
>> class AccountsController extends AppController {
>> public $helpers = array ('Html','Form');
>>
>>  
>> function index($client_id) {
>> $this->set('accounts', $this->Account->find('all', 
>> array('recursive' =>1, 'conditions' => 'Account.client_id ='. $client_id)));
>> $this->set('client_id', $client_id);
>> }
>>
>> public function view($id = null) {
>> $this->Account->id = $id;
>> $this->set('account', $this->Account->read());
>> }
>> public function add($client_id) { 
>> if ($this->request->is('post')) {
>> if ($this->Account->save($this->request->data)) {
>> $this->Session->setFlash('Your account has been added.'); 
>> if($this->request->data['Account']['accounttype_id'] == 2){
>> $this->redirect(array('controller' => 'twitteraccounts', 'action' => 
>> 'connect'));
>> }
>> }
>> }
>>   $accounts = $this->Account->find('list'); 
>>   $accounttype  =  $this->Account->Accounttype->find('list', 
>> array('fields'  => array('Accounttype.id', 'Accounttype.description')));
>>   $this->set('client_id', $client_id);
>>   $this->set('accounts', $accounts);
>>   $this->set('accounttype', $accounttype);
>> }
>>
>> function edit($id = null, $client_id) {
>> $this->Account->id = $id;
>> $this->set('id', $id);
>> if ($this->request->is('get')) {
>> $this->request->data = $this->Account->read();
>> } else {
>> if ($this->Account->save($this->request->data)) {
>> $this->Session->setFlash('Your account has been updated.');
>> $this->redirect(array('action' => 'index', $client_id));
>> }
>> }
>>   $accounts = $this->Account->find('list'); 
>>   $accounttype  =  $this->Account->Accounttype->find('list', 
>> array('fields'  => array('Accounttype.id', 'Accounttype.description')));
>>   $this->set('accounts', $accounts);
>>   $this->set('accounttype', $accounttype);
>>$this->set('client_id', $client_id);
>> }
>>
>>
>>  public function delete($id, $client_id) {
>>   
>> $id = $this->request->params['pass'][0];
>>
>> //the request must be a post request
>> //that's why we use postLink method on our view for deleting user
>>if( $this->request->is('get') ){
>>
>> $this->Session->setFlash('Delete method is not allowed.');
>> $this->redirect(array('action' => 'index',$client_id));
>>
>> //since we are using php5, we can also throw an exception like:
>> //throw new MethodNotAllowedException();
>> }else{
>>
>> if( !$id ) {
>> $this->Session->setFlash('Invalid id for Account');
>> $this->redirect(array('action'=>'index',$client_id));
>>
>> }else{
>> //delete user
>> if( $this->Account->delete($id, $cascade = true) ){
>> //set to screen
>> $this->Session->setFlash('Account was deleted.');
>> //redirect to users's list
>> $this->redirect(array('action'=>'index',$client_id));
>>
>> }else{ 
>> //if unable to delete
>> $this->Session->setFlash('Unable to delete Account.');
>> $this->redirect(array('action' => 'index'));
>> }
>> }
>> 

Re: hasOne load time x4

2013-11-06 Thread Ashish Mahana

so you resolves your issue or any issues do you have ?







On Tuesday, November 5, 2013 6:20:46 PM UTC+5:30, Aurelian Apostol wrote:
>
> Indeed my friend!
> I didn't have a FK on B, after creating one I had the desired result ... 
> 1,7s average.
>
> Thank you!
>
> luni, 4 noiembrie 2013, 10:23:07 UTC+2, Ashish Mahana a scris:
>>
>>
>> HI Aurelian,
>> There is not any problem when you use containable, its good to use that 
>> feature.
>>
>> Coming to the problem part, 
>> 1. First thing what i guess is that you have not set the index properly 
>> for tables that are related so that you are also delaying the result in the 
>> second association ($hasMany) 
>> 2. Second thing is that if u have *A $hasOne B* association then cake 
>> expects one-one relationship with respect to the primaryKey and foreignKey 
>> as it find violation of 
>> referential integrity it causes slow record fetching.
>>
>> if you have any doubt you are welcome to ask.
>>
>>
>> On Friday, November 1, 2013 9:42:55 PM UTC+5:30, Aurelian Apostol wrote:
>>>
>>> I am using two tables items and products, item hasOne product.
>>> When making a containable pagination on Item it loads 1200 rows in 13s, 
>>> when moving Product in hasMany it loads in 3,2s. With no other changes on 
>>> the models or any other place as that matters.
>>>
>>> Any ideas? 
>>>
>>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.