Friday, January 31, 2014

Re: constant for base app URL?

And what I forgot to mention, from a View template, you should use $this->Html->url('/', true) to generate a full URL.  It will use Router::url() anyway, but will save you the hassle of doing an App::uses() in the .ctp.

On Saturday, 1 February 2014 16:22:54 UTC+10, Reuben wrote:
To get a full URL, you can use Router::url('/', true).  That will give you the full URL to the application.

For applications running behind a load balancer, you may wish to specify the BASE_URL, but I see you've already found that.

Regards
Reuben Helms

On Monday, 13 March 2006 13:20:32 UTC+10, Dave wrote:
Sorry, I should clarify further. By URL I mean the URL path. So, for
example, if my Cake app can be reached at
http://my.domain/subdir/cake/, then this constant would be
'/subdir/cake'.

--
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+unsubscribe@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: constant for base app URL?

To get a full URL, you can use Router::url('/', true).  That will give you the full URL to the application.

For applications running behind a load balancer, you may wish to specify the BASE_URL, but I see you've already found that.

Regards
Reuben Helms

On Monday, 13 March 2006 13:20:32 UTC+10, Dave wrote:
Sorry, I should clarify further. By URL I mean the URL path. So, for
example, if my Cake app can be reached at
http://my.domain/subdir/cake/, then this constant would be
'/subdir/cake'.

--
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+unsubscribe@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.

Adding authentication to REST API server?

I would like to add authentication to a REST API server developed with cakephp. Are there any links or tips that I can use for a start?

--
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+unsubscribe@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.

Correctly using an ajax call?

Hello-

I've done some searching, but I can't seem to find something that exactly addresses what I'm trying to do.  When viewing an invoice, I have a list of invoice_items that go along with that invoice (charges, payments, discounts, etc).  I would like to be able to add another invoice_item to an invoice without having to go to a separate page.  After adding the new invoice_item, I would like the page to display the new invoice_item the same way that it display the existing ones.  Here is the order of events that I am trying to make happen:

  1. List any invoice_items associated with an invoice.  This is done in Invoices/view.ctp.
  2. Include a button/link in Invoices/view.ctp that calls the form used to add a new invoice_item.  This is currently done using an Ajax call (see code below) to invoices/addInvoiceItem.  The data returned from the Ajax call is taken from Invoices/add_invoice_item.ctp.  
  3. Add the form data as row to my current table that displays any existing invoice_items.
  4. When the user clicks "submit", I want to add the new invoice_item to the database (assuming all the validation goes through) and then return a string of html that displays the information for the new invoice_item. (i.d. "<td>blah</td><td>more blah</td>").
  5. Ideally, I would like to do all this without calling a completely page refresh.

Here is the relevant code that I have so far:
Invoices/view.ctp

<script type="text/javascript">
$(document).ready(function(){
$("#addInvoiceItemLink").click(function(){
$.ajax({
url: '<?php echo Router::url(array('controller'=>'Invoices','action'=>'addInvoiceItem', $invoice['Invoice']['id']));?>',
type: 'POST',
dataType: 'HTML',
success: function (data) {
$("#invoiceDetails").append(data);
}
});
});
});
</script>

[...]

<table id="invoiceDetails'>
   <?php foreach ($invoice['InvoiceItem'] as $invoiceItem):?>
<tr>
    <td><?php echo $invoiceItem['amount']; ?></td>
    <td><?php echo $invoiceItem['quantity']; ?></td>
    <td><?php echo $invoiceItem['notes']; ?></td>
    <td><?php echo $invoiceItem['InvoiceItemType']['name']; ?></td>
    <td><?php echo $this->Number->precision($invoiceItem['amount'] * $invoiceItem['quantity'], 2)?></td>
        </tr>
</table>

InvoicesController
public function addInvoiceItem($invoiceId){
if (!$this->Invoice->exists($invoiceId)) {
throw new NotFoundException(__('Invalid invoice'));
}
if ($this->request->is('post') && (!empty($this->request->data))){
$this->request->data['InvoiceItem']['invoice_id'] = $invoiceId;
$this->request->data['InvoiceItem']['currency_id'] = 1;
$this->Invoice->InvoiceItem->create();
if ($this->Invoice->InvoiceItem->save($this->request->data['InvoiceItem']))
$this->Session->setFlash("Invoice item saved");;
$invoiceItem = $this->Invoice->InvoiceItem->findById($invoiceId);
$html = $this->Invoice->InvoiceItem->getTableRowView();
$this->autoRender = false;
return $html;
}
$currencies = $this->Invoice->InvoiceItem->Currency->find('list');
$invoiceItemTypes = $this->Invoice->InvoiceItem->InvoiceItemType->find('list');
$this->set(compact('currencies', 'invoiceItemTypes'));
$this->set('invoiceId', $invoiceId);
}

Invoice model
public function getTableRowView(){

$html = "<td>$this->amount</td>";
$html .="<td>$this->quantity</td>";
return $html;
}

This does most of what I want, but I can't get getTableRowView() to access the data from the invoice model.  I continually get empty html like this: "<td></td><td></td>".  So, I have two questions:

1) How do I create an invoice_item object in my controller so that I can access the data in that object when calling a model function on that object?
2) I'm aware that this is my first stab at using Ajax calls in my application and it isn't perfect.  Is there any better way to do what I'm trying to do here?  

Thanks in advance for any help and let me know if there is a better way to post/phrase my questions in the future!

--
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+unsubscribe@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's naming conventions on hasMany through (The Join Model)

I've had the most success with HABTM-through by not trying to get CakePHP to do so much magic on the relationships.

So I would simply name the table "restrictions" and have it contain

id, attraction-id, attraction_accessibility_id, plus extra stuff

With Containable behavior I think you can get this wired up the way you want:

Search for attraction with 
$options = array('contains' => array('Restriction' => array('AttractionAccessibility')))

and you should get the attached accessibilities and extra data from the restriction.


On Friday, January 31, 2014 7:52:17 AM UTC-5, Sam Clauw wrote:
After struggling with this inconvenience for a couple of weeks now, I've decided to open en now topic here. A topic that can help me, but I'm sure it will help some others with this same problem too!

I wonder how I should name the tables, controllers and models of a hasMany through table (thus with additional fields) and it's coupled tables. I tried to stick on the CakePHP naming conventions as discribed in it's cookbook, but this constantly gave me some "Object not found" errors. For practical reason, I'll show you my problem with a many-words table. Perhaps that could be the reason of the problem? ;)

Situation

I have a fansite of a themepark and as you now, a themepark has many attractions. To ride an attraction, you must have a minimal height. Sometimes, small people can only ride it with an adult companion. But most of the time: you are allowed to ride the attraction because you just are tall enough ;)
Now I want to show the information of a specific attraction on my website. Name, content, photos, and so on. In addition to that information, I want to display my guests if they (or their kids) are tall enough to ride that attraction. It should appear like this way:

0m00 -> 1m00: not allowed
1m00 -> 1m30: allowed with an adult companion
1m30 -> 1m90: allowed

Database

I have two tables that are representing two objects: "attractions" & "attraction_accessibilities". In this case, I'm 100% sure the database names are correct. Secondly, I should have another table between "attractions" and "attraction_accessibilities". This table should contain:

  • an id specific for each record
  • a link to the id of the "attractions" table (attraction_id)
  • a link to the id of the "attraction_accessibilities" table (attraction_accessibility_id)
  • the additional information like "min-height" and "max-height"
I think I should name that table "attraction_accessibilities_attractions". It's a constriction of the two other tables, and I did it that way because CakePHP proposed it when you're making a HABTM association (http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#hasandbelongstomany-habtm).

But unfortunately, when I do call it that way, I've never succeeded to link those models in my application together.

Question

Is there anybody who've had the same problem but found a solution for it? If "yes": how should I name my database tables then and also important: how should I name my controller and model .php files?
Many thanks for the one who could help me and some other hopeless programmers ;)

--
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+unsubscribe@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: constant for base app URL?

Do you mean the APP_DIR constant?


These constants can be useful when working with files for example, when needing an absolute path APP is good, or even WWW_ROOT / WEBROOT_DIR when uploading images to a public directory.

Just pr() each of these constants and if you'll see the output... If you're not sure what the use is, it's likely you don't need to use it right now.

p.s. I often use these constant with Configure::write() to define new paths for use within my application.


On 31 January 2014 06:54, Sayam Abbas <abbassayam@gmail.com> wrote:
what is the use of APP_URL costant?

--
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+unsubscribe@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.



--
Kind Regards
 Stephen Speakman

--
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+unsubscribe@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.

CakePHP's naming conventions on hasMany through (The Join Model)

After struggling with this inconvenience for a couple of weeks now, I've decided to open en now topic here. A topic that can help me, but I'm sure it will help some others with this same problem too!

I wonder how I should name the tables, controllers and models of a hasMany through table (thus with additional fields) and it's coupled tables. I tried to stick on the CakePHP naming conventions as discribed in it's cookbook, but this constantly gave me some "Object not found" errors. For practical reason, I'll show you my problem with a many-words table. Perhaps that could be the reason of the problem? ;)

Situation

I have a fansite of a themepark and as you now, a themepark has many attractions. To ride an attraction, you must have a minimal height. Sometimes, small people can only ride it with an adult companion. But most of the time: you are allowed to ride the attraction because you just are tall enough ;)
Now I want to show the information of a specific attraction on my website. Name, content, photos, and so on. In addition to that information, I want to display my guests if they (or their kids) are tall enough to ride that attraction. It should appear like this way:

0m00 -> 1m00: not allowed
1m00 -> 1m30: allowed with an adult companion
1m30 -> 1m90: allowed

Database

I have two tables that are representing two objects: "attractions" & "attraction_accessibilities". In this case, I'm 100% sure the database names are correct. Secondly, I should have another table between "attractions" and "attraction_accessibilities". This table should contain:

  • an id specific for each record
  • a link to the id of the "attractions" table (attraction_id)
  • a link to the id of the "attraction_accessibilities" table (attraction_accessibility_id)
  • the additional information like "min-height" and "max-height"
I think I should name that table "attraction_accessibilities_attractions". It's a constriction of the two other tables, and I did it that way because CakePHP proposed it when you're making a HABTM association (http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#hasandbelongstomany-habtm).

But unfortunately, when I do call it that way, I've never succeeded to link those models in my application together.

Question

Is there anybody who've had the same problem but found a solution for it? If "yes": how should I name my database tables then and also important: how should I name my controller and model .php files?
Many thanks for the one who could help me and some other hopeless programmers ;)

--
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+unsubscribe@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.

Thursday, January 30, 2014

Re: Problem with year dropdown

Allright, thank you very much, that's the dropdown I was looking for!

--
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+unsubscribe@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: constant for base app URL?

what is the use of APP_URL costant?

--
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+unsubscribe@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: What's the correct method for using Traits and Namespaces for CakePHP 2?

Right now, no.

I was just curious. Call it professional development.

I've been following the development of CakePHP 3, but have not had much time to play with it directly. So I was curious about about the namespace convention in CakePHP 3 applications, and what someone could do to ride ahead of the migration curve if they happened to be using traits, a construct where namespaces might become relevant.

On Friday, January 31, 2014, José Lorenzo <jose.zap@gmail.com> wrote:
Do you need to use namespaces? Otherwise you can just load the file with App::uses()

On Wednesday, January 29, 2014 11:50:52 AM UTC+1, Reuben wrote:
Does using namespaces change anything?

Or is the App::uses just to assist with loading the appropriate file?

Keeping in mind CakePHP 3, if namespaces can be used, what would be the namespace convention for a CakePHP 2 application?

On Wednesday, January 29, 2014, José Lorenzo <jose...@gmail.com> wrote:
Just load the trait with App::uses()

On Tuesday, January 28, 2014 1:52:07 AM UTC+1, Reuben wrote:
My original question on Stack Overflow [http://stackoverflow.com/questions/21394852/whats-the-correct-method-for-using-traits-and-namespaces-for-cakephp-2], and content copied here, should that disappear.

I'm using CakePHP 2.4.5 and PHP 5.5, and would like to use a trait.

I have a trait in Utility/VariablesTrait.php called VariablesTrait.

To take advantage of namespaces, I've given it a namespace of App\Utility\VariablesTrait, since Utility\VariablesTrait seems a bit too global, and the former would work better with CakePHP 3.

In my class that I want to use it in, I have the use App\Utility\VariablesTrait; statement in the class. For backup, I also have a App::uses('VariablesTrait', 'Utility'); statement at the top of the file. I'm not sure if the SPL autoloader is used when looking for traits, which is why I was going for namespaces in the first place.

The small issue is that the app directory is app, and since directory structures should match namespaces (I think), I renamed it to App. However, CakeRequest::_base() hardcodes app, so determining the controller doesn't work so well.

So, I'm trying to determine if that's a CakePHP bug, or if there is a more appropriate way of using traits in CakePHP 2.


--
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/gqWZW191sHU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cake-php+unsubscribe@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+unsubscribe@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: What's the correct method for using Traits and Namespaces for CakePHP 2?

Do you need to use namespaces? Otherwise you can just load the file with App::uses()

On Wednesday, January 29, 2014 11:50:52 AM UTC+1, Reuben wrote:
Does using namespaces change anything?

Or is the App::uses just to assist with loading the appropriate file?

Keeping in mind CakePHP 3, if namespaces can be used, what would be the namespace convention for a CakePHP 2 application?

On Wednesday, January 29, 2014, José Lorenzo <jose...@gmail.com> wrote:
Just load the trait with App::uses()

On Tuesday, January 28, 2014 1:52:07 AM UTC+1, Reuben wrote:
My original question on Stack Overflow [http://stackoverflow.com/questions/21394852/whats-the-correct-method-for-using-traits-and-namespaces-for-cakephp-2], and content copied here, should that disappear.

I'm using CakePHP 2.4.5 and PHP 5.5, and would like to use a trait.

I have a trait in Utility/VariablesTrait.php called VariablesTrait.

To take advantage of namespaces, I've given it a namespace of App\Utility\VariablesTrait, since Utility\VariablesTrait seems a bit too global, and the former would work better with CakePHP 3.

In my class that I want to use it in, I have the use App\Utility\VariablesTrait; statement in the class. For backup, I also have a App::uses('VariablesTrait', 'Utility'); statement at the top of the file. I'm not sure if the SPL autoloader is used when looking for traits, which is why I was going for namespaces in the first place.

The small issue is that the app directory is app, and since directory structures should match namespaces (I think), I renamed it to App. However, CakeRequest::_base() hardcodes app, so determining the controller doesn't work so well.

So, I'm trying to determine if that's a CakePHP bug, or if there is a more appropriate way of using traits in CakePHP 2.


Regards

Reuben Helms

--
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/gqWZW191sHU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cake-php+unsubscribe@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+unsubscribe@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.

3.0 FormHelper branch?

There isn't a specific branch right now. So far I've been focusing on splitting out each input type into separate objecta. This will allow formhelper to be more extensible and allow developers to add/change behavior without subclassing.

I'm now working on another internal piece of formhelper that will allow formhelper to be used with alternative orms as this has been a pain point for many people in the past.

Once the above work is done, there will be an actual formhelper branch as the prerequisite work will be complete.

-Mark

--
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+unsubscribe@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.

Wednesday, January 29, 2014

Re: 3.0 FormHelper branch?

Be patient ;) Its not even alpha or beta yet.


Am Mittwoch, 29. Januar 2014 21:22:20 UTC+1 schrieb RobertM:
No ETA then I guess :(
Would be great to start new personal projects in 3.0 (no FormHelper seems like an obstacle) and finish them as framework matures.

W dniu wtorek, 28 stycznia 2014 14:03:10 UTC+1 użytkownik José Lorenzo napisał:
Most of the progress of the FormHelper has already been merged directly to 3.0. The thing is, FormHelper has not been touched yet! We are currently rewriting each input type as a separate, configurable class, which is mostly done so far.

On Monday, January 27, 2014 9:29:19 PM UTC+1, RobertM wrote:
Is there any public branch where can we see how new FormHelper will be implemented?
Would love to play with 3.0's little more ...

R

--
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+unsubscribe@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: 3.0 FormHelper branch?

No ETA then I guess :(
Would be great to start new personal projects in 3.0 (no FormHelper seems like an obstacle) and finish them as framework matures.

W dniu wtorek, 28 stycznia 2014 14:03:10 UTC+1 użytkownik José Lorenzo napisał:
Most of the progress of the FormHelper has already been merged directly to 3.0. The thing is, FormHelper has not been touched yet! We are currently rewriting each input type as a separate, configurable class, which is mostly done so far.

On Monday, January 27, 2014 9:29:19 PM UTC+1, RobertM wrote:
Is there any public branch where can we see how new FormHelper will be implemented?
Would love to play with 3.0's little more ...

R

--
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+unsubscribe@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.

Schema duality in _create()

I'm having a hard time understanding the difference between the instance of the schema initialized SchemaShell::startup() and the instance passed in to SchemaShell::_create(). _create() implements both, and it's causing issues for me (one uses one connection, and one uses the other).



Dustin

--
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+unsubscribe@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.

Containable + pagination

In cakePHP 2.4.5 I have the following model:

Article belongsTo UserUpload
Article belongsTo UserTranslated
Article belongsTo Author
Article hasAndBelongsToMany Category

I want to view a category and paginate articles with authors and user_uploads:


$paginateSettings = array(
      'ArticlesCategory' => array(
        'limit' => 4,
        'recursive' => -1,
        'conditions' => array('Category.slug' => $slug, 'Article.isTranslated' => 1),
        'order' => 'Article.created desc',
        'contain' => array(
          'Category',
          'Article.Author')
    ));

    $this->Paginator->settings = $paginateSettings;
    $articles = $this->Paginator->paginate('ArticlesCategory');

Author is never loaded. The sql executed is:

SELECT `Article`.`id`, `Category`.`slug`, `Category`.`description`, `Article`.`isTranslated`, `Article`.`title_translated`, `Article`.`title`, `Article`.`abstract_translated`, `Article`.`abstract`, `Article`.`slug`, `Article`.`created`, `Article`.`alternate_translated_by`, `Article`.`url`, `Article`.`url_description`, `Article`.`year`, `Article`.`total_views`, `Category`.`id` FROM `articles_categories` AS `ArticlesCategory` LEFT JOIN `articles` AS `Article` ON (`ArticlesCategory`.`article_id` = `Article`.`id`) LEFT JOIN `categories` AS `Category` ON (`ArticlesCategory`.`category_id` = `Category`.`id`) WHERE `Category`.`slug` = 'gender' AND `Article`.`isTranslated` = '1' ORDER BY `Article`.`created` desc LIMIT 4

Why isn't there a left join with Author?

Am I missing something?

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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@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: What's the correct method for using Traits and Namespaces for CakePHP 2?

Does using namespaces change anything?

Or is the App::uses just to assist with loading the appropriate file?

Keeping in mind CakePHP 3, if namespaces can be used, what would be the namespace convention for a CakePHP 2 application?

On Wednesday, January 29, 2014, José Lorenzo <jose.zap@gmail.com> wrote:
Just load the trait with App::uses()

On Tuesday, January 28, 2014 1:52:07 AM UTC+1, Reuben wrote:
My original question on Stack Overflow [http://stackoverflow.com/questions/21394852/whats-the-correct-method-for-using-traits-and-namespaces-for-cakephp-2], and content copied here, should that disappear.

I'm using CakePHP 2.4.5 and PHP 5.5, and would like to use a trait.

I have a trait in Utility/VariablesTrait.php called VariablesTrait.

To take advantage of namespaces, I've given it a namespace of App\Utility\VariablesTrait, since Utility\VariablesTrait seems a bit too global, and the former would work better with CakePHP 3.

In my class that I want to use it in, I have the use App\Utility\VariablesTrait; statement in the class. For backup, I also have a App::uses('VariablesTrait', 'Utility'); statement at the top of the file. I'm not sure if the SPL autoloader is used when looking for traits, which is why I was going for namespaces in the first place.

The small issue is that the app directory is app, and since directory structures should match namespaces (I think), I renamed it to App. However, CakeRequest::_base() hardcodes app, so determining the controller doesn't work so well.

So, I'm trying to determine if that's a CakePHP bug, or if there is a more appropriate way of using traits in CakePHP 2.


Regards

Reuben Helms

--
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/gqWZW191sHU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cake-php+unsubscribe@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+unsubscribe@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: What's the correct method for using Traits and Namespaces for CakePHP 2?

Just load the trait with App::uses()

On Tuesday, January 28, 2014 1:52:07 AM UTC+1, Reuben wrote:
My original question on Stack Overflow [http://stackoverflow.com/questions/21394852/whats-the-correct-method-for-using-traits-and-namespaces-for-cakephp-2], and content copied here, should that disappear.

I'm using CakePHP 2.4.5 and PHP 5.5, and would like to use a trait.

I have a trait in Utility/VariablesTrait.php called VariablesTrait.

To take advantage of namespaces, I've given it a namespace of App\Utility\VariablesTrait, since Utility\VariablesTrait seems a bit too global, and the former would work better with CakePHP 3.

In my class that I want to use it in, I have the use App\Utility\VariablesTrait; statement in the class. For backup, I also have a App::uses('VariablesTrait', 'Utility'); statement at the top of the file. I'm not sure if the SPL autoloader is used when looking for traits, which is why I was going for namespaces in the first place.

The small issue is that the app directory is app, and since directory structures should match namespaces (I think), I renamed it to App. However, CakeRequest::_base() hardcodes app, so determining the controller doesn't work so well.

So, I'm trying to determine if that's a CakePHP bug, or if there is a more appropriate way of using traits in CakePHP 2.


Regards

Reuben Helms

--
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+unsubscribe@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.

Tuesday, January 28, 2014

Re: Problem with year dropdown



On Tuesday, 28 January 2014 14:43:50 UTC+1, Sam Clauw wrote:
Is there nobody who can help me with this? Could it be possibile dat the datebase field type "year" isn't supported in CakePHP? If yes, what should I use instead? Varchar or...?

 'type' => 'year',

A year input is intended to be used as part of a date - it doesn't work on it's own. If you check the html source your data will be ala:

<select name="data[Foo][opened][year]">

and not

<select name="data[Foo][opened]">

Instead of using `year` - I suggest to use a select (which is all the year input is) like so:

    $years = range(1954, date('Y') + 1);
    $years = array_combine($years, $years);

    'opened' => array(
        'label' => 'Year opening',
        'options' => $years,
        'empty' => 'Kies...'
    ),

AD

--
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+unsubscribe@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: Problem with year dropdown

Is there nobody who can help me with this? Could it be possibile dat the datebase field type "year" isn't supported in CakePHP? If yes, what should I use instead? Varchar or...?

--
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+unsubscribe@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: Rendering PDF from POST basead searches

Thank you.

Nilson


Prof. Dr. Nilson Pena
Av. ACM, 585, sl. 1205
Salvador - Bahia
71 - 3012-3031


On Tue, Jan 28, 2014 at 9:37 AM, euromark <dereuromark@gmail.com> wrote:
I gave you an answer as comment.


Am Montag, 27. Januar 2014 16:04:40 UTC+1 schrieb Nilson Pena:
Hi folks,
I use mPDF and the solution proposed in this excellent post [1]. Everything works well if the action uses GET. Example: /controller/action/2.pdf wil use the view.ctp inside the pdf folder and render the 2.pdf file.

But there are cases that I have to use a form to POST some parameters to do a especific search and return this data to the view. In this case, the /controller/action/2.pdf won't work, once the action only allows POST.

How can I workaround this "issue" and keep using this approach on serving PDF?

Thank You!

Nilson

[1] http://www.dereuromark.de/2011/11/21/serving-views-as-files-in-cake2/

--
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+unsubscribe@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: 3.0 FormHelper branch?

Most of the progress of the FormHelper has already been merged directly to 3.0. The thing is, FormHelper has not been touched yet! We are currently rewriting each input type as a separate, configurable class, which is mostly done so far.

On Monday, January 27, 2014 9:29:19 PM UTC+1, RobertM wrote:
Is there any public branch where can we see how new FormHelper will be implemented?
Would love to play with 3.0's little more ...

R

--
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+unsubscribe@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: Rendering PDF from POST basead searches

I gave you an answer as comment.


Am Montag, 27. Januar 2014 16:04:40 UTC+1 schrieb Nilson Pena:
Hi folks,
I use mPDF and the solution proposed in this excellent post [1]. Everything works well if the action uses GET. Example: /controller/action/2.pdf wil use the view.ctp inside the pdf folder and render the 2.pdf file.

But there are cases that I have to use a form to POST some parameters to do a especific search and return this data to the view. In this case, the /controller/action/2.pdf won't work, once the action only allows POST.

How can I workaround this "issue" and keep using this approach on serving PDF?

Thank You!

Nilson

[1] http://www.dereuromark.de/2011/11/21/serving-views-as-files-in-cake2/

--
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+unsubscribe@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.

Monday, January 27, 2014

Re: What's the correct method for using Traits and Namespaces for CakePHP 2?

For the moment, even though PHP 5.5 has namespaces, it just seems to work if you don't use them (namespaces, that is).

You will need to have an App::uses() statement to use load the trait, and you'll also need the 'use' statement in the class.

And given that namespaces are not in use, also keep 'app' as 'app' and not 'App'.  Although replacing 'app' with APP_DIR would be better for CakePHP 2.4.5 projects that have selected a different name for their project, and don't have the HTTP root pointing to webroot (in the case of integration with legacy apps).

Regards
Reuben Helms

On Tuesday, 28 January 2014 10:52:07 UTC+10, Reuben wrote:
My original question on Stack Overflow [http://stackoverflow.com/questions/21394852/whats-the-correct-method-for-using-traits-and-namespaces-for-cakephp-2], and content copied here, should that disappear.

I'm using CakePHP 2.4.5 and PHP 5.5, and would like to use a trait.

I have a trait in Utility/VariablesTrait.php called VariablesTrait.

To take advantage of namespaces, I've given it a namespace of App\Utility\VariablesTrait, since Utility\VariablesTrait seems a bit too global, and the former would work better with CakePHP 3.

In my class that I want to use it in, I have the use App\Utility\VariablesTrait; statement in the class. For backup, I also have a App::uses('VariablesTrait', 'Utility'); statement at the top of the file. I'm not sure if the SPL autoloader is used when looking for traits, which is why I was going for namespaces in the first place.

The small issue is that the app directory is app, and since directory structures should match namespaces (I think), I renamed it to App. However, CakeRequest::_base() hardcodes app, so determining the controller doesn't work so well.

So, I'm trying to determine if that's a CakePHP bug, or if there is a more appropriate way of using traits in CakePHP 2.


Regards

Reuben Helms

--
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+unsubscribe@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.

What's the correct method for using Traits and Namespaces for CakePHP 2?

My original question on Stack Overflow [http://stackoverflow.com/questions/21394852/whats-the-correct-method-for-using-traits-and-namespaces-for-cakephp-2], and content copied here, should that disappear.

I'm using CakePHP 2.4.5 and PHP 5.5, and would like to use a trait.

I have a trait in Utility/VariablesTrait.php called VariablesTrait.

To take advantage of namespaces, I've given it a namespace of App\Utility\VariablesTrait, since Utility\VariablesTrait seems a bit too global, and the former would work better with CakePHP 3.

In my class that I want to use it in, I have the use App\Utility\VariablesTrait; statement in the class. For backup, I also have a App::uses('VariablesTrait', 'Utility'); statement at the top of the file. I'm not sure if the SPL autoloader is used when looking for traits, which is why I was going for namespaces in the first place.

The small issue is that the app directory is app, and since directory structures should match namespaces (I think), I renamed it to App. However, CakeRequest::_base() hardcodes app, so determining the controller doesn't work so well.

So, I'm trying to determine if that's a CakePHP bug, or if there is a more appropriate way of using traits in CakePHP 2.


Regards

Reuben Helms

--
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+unsubscribe@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.

3.0 FormHelper branch?

Is there any public branch where can we see how new FormHelper will be implemented?
Would love to play with 3.0's little more ...

R

--
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+unsubscribe@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: Cake console shell error - not able to see App

OK... it was me. All me. I was missing a semi-colon ;p

I do however have a new issue. I manage to call in my Component, but that component calls one of my controllers and this is now throwing an error when running in the console. I need all the functionality to be accessible to both the web based app and to the console as there is a manual call to this component and there is a cron job which will run the shell script every hour or so, which in turn is calling my component.

Is there a better way to do this, baring in mind that the app is pretty much complete and I'd be in a big pickle if I had to drastically change the structure of any of it. The cron job is an add on.

Thanks in advance,
Nikki

--
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+unsubscribe@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.