cricket | 1 Nov 2010 01:04
Picon

Re: New to MVC

On Sun, Oct 31, 2010 at 6:18 PM, Giorgio <anothernetfellow@...> wrote:
> Thankyou Cricket for your kind reply! I'll try to give more details about
> the part of my application i'm trying to rewrite with cakephp.
>
> 1 - In a form, an user inserts a youtube link and click on submit
> 2 - My application handles the input and
> 2.1 - Gets, from youtube api, details of that video and stores them in a db
> (get_video_details() + a connection to the DB to store data)
> 2.2 - Creates a short url and saves it into the db (shorten_url() + a
> connection to the db to store data)
> 3 - Outputs a confirmation page with the video embedded in it

So creating the Bit.ly link is just one part of the request. In that
case, go with a component. Save the the shortened URL the component
returns to the controller into the DB and include it with whatever
else you're responding back to the client.

> As you can see, this is very simple. I just need to understand where i have
> to put those "workers", those functions.

It looks like both the YT and Bit.ly stuff should be handled by a
component (but more on that below).

> Do you confirm that a component is a library in the Vendors directory?

No. A component is a class that your controller uses. They can either
be inside the app/controllers/components or the
app/plugin/your_plugin/controllers/components dirs. The latter would
be for a component that is used solely for that plugin, whereas the
former could be loaded by any of your other app's controllers. An
(Continue reading)

cricket | 1 Nov 2010 01:19
Picon

Re: need help with form

On Sun, Oct 31, 2010 at 5:48 PM, Briko03 <nathanrlarkin@...> wrote:
> Here is my view:
>
> <?php
> echo $form->create('Result', array('action' => 'findperson'));
> echo $form->input('lname');
> echo $form->input('fname');
>
> echo $form->submit();
> echo $form->end();
> ?>
>
>
> Here is the action:
>
> function findperson()
>           {
>                if (!empty($this->data)) {
>                        $this->redirect(array('action' => 'person'));
>                        }
>                }
>        //I want to append this to the redirect - $this->data['Result']
> ['lname']
>
> I am kind of stuck at the moment and not sure what I am doing
> wrong....

Don't redirect as that creates an entirely new request. You could use
setAction() instead.

(Continue reading)

Briko03 | 1 Nov 2010 01:55
Picon

Re: need help with form

Does that mean that I can have a view that does not have a
corresponding action?

How would i get the form to use person and the values from the input?

Sorry for the newb questions...

On Oct 31, 8:19 pm, cricket <zijn.digi...@...> wrote:
> On Sun, Oct 31, 2010 at 5:48 PM, Briko03 <nathanrlar...@...> wrote:
> > Here is my view:
>
> > <?php
> > echo $form->create('Result', array('action' => 'findperson'));
> > echo $form->input('lname');
> > echo $form->input('fname');
>
> > echo $form->submit();
> > echo $form->end();
> > ?>
>
> > Here is the action:
>
> > function findperson()
> >           {
> >                if (!empty($this->data)) {
> >                        $this->redirect(array('action' => 'person'));
> >                        }
> >                }
> >        //I want to append this to the redirect - $this->data['Result']
> > ['lname']
(Continue reading)

cricket | 1 Nov 2010 02:21
Picon

Re: need help with form

On Sun, Oct 31, 2010 at 8:55 PM, Briko03 <nathanrlarkin@...> wrote:
> Does that mean that I can have a view that does not have a
> corresponding action?
>
> How would i get the form to use person and the values from the input?
>
> Sorry for the newb questions...

I don't understand the question, actually. By "person" do you mean the
model? You can do:

echo $this->Form->create('Person', array(...));

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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

Briko03 | 1 Nov 2010 02:30
Picon

Re: need help with form

no the model is result....

The idea is that I have an action called person.... this action takes
url params to find results by the person. So I am trying to create a
form that will direct to that action with the params based on the
input from the form....

On Oct 31, 9:21 pm, cricket <zijn.digi...@...> wrote:
> On Sun, Oct 31, 2010 at 8:55 PM, Briko03 <nathanrlar...@...> wrote:
> > Does that mean that I can have a view that does not have a
> > corresponding action?
>
> > How would i get the form to use person and the values from the input?
>
> > Sorry for the newb questions...
>
> I don't understand the question, actually. By "person" do you mean the
> model? You can do:
>
> echo $this->Form->create('Person', array(...));

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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

(Continue reading)

DANNY | 1 Nov 2010 04:23
Picon

the Form with method GET generate incorrent URL

Hi All:
I look the  tutorial that Pagination for custom queries
(http://bakery.cakephp.org/articles/shird10/2010/08/29/pagination-for-
custom-queries)

I can search the data by use URL (example.com/forums/viewtopic/x/y/
page:2)
But I want to use Form(method is GET) to generate the url

<!-- ------search------ -->
<?php echo $this->Form-
>create('Order',array('action'=>'index','type'=>'get'));?>
<?php echo $this->Form->input('x');  ?>
<?php echo $this->Form->input('y');  ?>
<?php echo $this->Form->end(__('submit', true));?>
<!-- ------search------ -->

I press the summit button , I get the url is :
example.com/forums/viewtopic?x=AAAAAAA&y=BBBBBB

not example.com/forums/viewtopic/x/y/page:2
How to create the above Url by Form and method is GET

thanks

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@...
To unsubscribe from this group, send email to
(Continue reading)

Pablo Terradillos | 1 Nov 2010 04:56
Picon
Gravatar

Problem with a hasMany relationship

hi guys,

i'm trying to add data to a model wich have a $hasMany relationship but with no luck...

According to the cookbook, i must have in my model something like this

class User extends AppModel {

$hasMany = 'profile';

...

then in my view i use the form helper:

$this->Form->create('user');
$this->Form-Z>input('user.id);
$this->Form->input('user.username');
$this->Form->input('user.password');
$this->Form->input('profile.0.name');
$this->Form->input('profile.0.age');
...etc...

I want to save that user and that profile (in the future i want to add more profiles to one user)

so in my controler I'm doing the following:

if(!empty($this->data) {
  $this->User->saveAll($this->data);
}

...

well, the user is saved, but nothing happens with the profile... I have the models for both defined and in my database i have a foreign key in the profile table which point to user (i'm using mysql with innodb)

I'm missing something?

Hope you can help me,

Thanks in advance!

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
cake-php+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Arak Tai'Roth | 1 Nov 2010 05:33
Picon

Adding new items to a form dynamically

So, here is my situation. I have a form that allows users (only
admins) to upload images for a specific product. What I have created
is a solution that when they load the add form initially it has one
file upload and one caption text box. However, they can click a button
lower down, that dynamically adds another file upload and another
caption box, so they can essentially upload however many images they
want to at a time.

Here is the code that I have:

images_controller.php
function add($productID = NULL)
{
	if ($this->RequestHandler->isPost())
	{
		$slug = $this->Session->read('ProductSlug');

		if ($this->Image->saveAll($this->data))
		{
			$this->Session->setFlash('Images have been added to the product.');

			$this->redirect('/product/' . $slug);
			$this->exit();
		}
	}
	else
	{
		$this->Session->write('ProductID', $productID);
		$this->Session->write('ImageCounter', 0);
	}
}

function moreImages()
{
	if ($this->RequestHandler->isAjax())
	{
		$images = $this->Session->read('ImageCounter');
		$images++;
		$this->Session->write('ImageCounter', $images);

		$this->render('/elements/imageAdd');
	}
}

and imageAdd.ctp
	$image = $this->Session->read('ImageCounter');

	echo $this->Form->input('Image.' . $image . '.product_id',
array('type' => 'hidden', 'default' => $this->Session-
>read('ProductID')));

	echo $this->Form->label('Image.' . $image . '.filename', 'Image:');
	echo $this->Form->input('Image.' . $image . '.filename',
array('label' => false, 'type' => 'file'));

	echo $this->Form->label('Image.' . $image . '.caption', 'Caption:');
	echo $this->Form->input('Image.' . $image . '.caption', array('label'
=> false));

and finally the js file that adds the stuff:
$(document).ready(function() {
	$('#forms img').click(function() {
		$.ajax({
			url: someUrl',
			dataType: 'html',
			success: function(data) {
				$('#forms div.formInputs').append(data);
			}
		});
	});
});

Now, what this does. When the user goes to the add form, it renders
the element imageAdd. Which creates 3 form elements, 1 hidden. Each
form element is rendered  with Image.0.columnName. Then if they click
the image at the bottom, it renders another element imageAdd, but this
time the elements are all named Image.1.columnName, and so on.

Now for my issue. All of this works fine if they just add one image.
However, that clearly defeats the purpose of this. When they go to add
2 or more images, it goes to a blank screen, where even the view
source is blank. So I have no idea what's going wrong. It goes there
before the timeout that's declared in php.ini, and I've made sure that
the combined filesize is also lower then what's allowed in my php.ini.

Also, if it makes a difference, I am using MeioUpload for the file
upload behaviour. Any help on this is greatly appreciated.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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

Dave Maharaj | 1 Nov 2010 05:55
Favicon

Problem with deleting cache from app_controller / model

I have a core few functions that add / edit / delete records in app_controller.

 

Now when I add / edit / delete a record it will not delete the cached file. I even tried using the afterSave() afterDelete() in the respective model for each, even hardcoded the

Cache::delete( ‘all_tests’, 'week'); but nothing seems to delete these files.

 

I am able to make a cached record from app_model but cant delete them from app_

 

Is there a reason it will not work in app_? Something I am missing?

 

Dave

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
cake-php+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Favicon
Gravatar

Re: Acl and bindNode

Because the users table has a group_id on it. Duh.

Jeremy Burns
Class Outfit

jeremyburns@...
http://www.classoutfit.com

On 31 Oct 2010, at 14:48, huoxito wrote:

> Guess I dont get your point.
> 
> Users still must de added on Aro's table, otherwise how would your
> system know that an user A belongs to group ALFA ?
> 
> On 29 out, 08:23, Jeremy Burns | Class Outfit
> <jeremybu...@...> wrote:
>> Anybody else got any more ideas on this? Anyone using it with success?
>> 
>> Jeremy Burns
>> Class Outfit
>> 
>> jeremybu...@...
>> (t) +44 (0) 208 123 3822
>> (m) +44 (0) 7973 481949
>> Skype: jeremy_burnshttp://www.classoutfit.com
>> 
>> On 27 Oct 2010, at 17:10, Jeremy Burns | Class Outfit wrote:
>> 
>> 
>> 
>>> I wish that were the case, but the guide then gives an example of the aros table, which only includes groups:http://book.cakephp.org/view/1547/Acts-As-a-Requester
>> 
>>> Jeremy Burns
>>> Class Outfit
>> 
>>> jeremybu...@...
>>> http://www.classoutfit.com
>> 
>>> On 27 Oct 2010, at 13:41, cricket wrote:
>> 
>>>> On Tue, Oct 26, 2010 at 4:40 PM, Jeremy Burns
>>>> <jeremybu...@...> wrote:
>>>>> According to the online tutorial:
>> 
>>>>> "
>>>>> In case we want simplified per-group only permissions, we need to
>>>>> implement bindNode() in User model.
>>>>> Code View
>> 
>>>>> function bindNode($user) {
>>>>>    return array('Group' => array('id' => $user['User']['group_id']));
>>>>> }
>> 
>>>>>   function bindNode($user) {
>>>>>      return array('Group' => array('id' => $user['User']
>>>>> ['group_id']));
>>>>>   }
>> 
>>>>> This method will tell ACL to skip checking User Aro's and to check
>>>>> only Group Aro's.
>>>>> "
>> 
>>>>> I've done this but I'm still getting users added to the aros table.
>>>>> What am I missing?
>> 
>>>> I believe that's normal. Users will still be present in aros but the
>>>> point is that ACL won't /check/ User, but Group.
>> 
>>>> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP
related questions.
>> 
>>>> You received this message because you are subscribed to the Google Groups "CakePHP" group.
>>>> To post to this group, send email to cake-php@...
>>>> To unsubscribe from this group, send email to
>>>> cake-php+unsubscribe@... For more options, visit this
group athttp://groups.google.com/group/cake-php?hl=en
>> 
>>> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions.
>> 
>>> You received this message because you are subscribed to the Google Groups "CakePHP" group.
>>> To post to this group, send email to cake-php@...
>>> To unsubscribe from this group, send email to
>>> cake-php+unsubscribe@... For more options, visit this
group athttp://groups.google.com/group/cake-php?hl=en
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups "CakePHP" group.
> To post to this group, send email to cake-php@...
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@... For more options, visit this group
at http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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


Gmane