Using phpThumb to automatically generate thumbnail images of user input?

2009-07-06 Thread eMilk

I'm using the phpThumb helper to try and automatically generate
thumbnail images of the input
http://bakery.cakephp.org/articles/view/phpthumb-helper-2

In my views/posts/add.ctp I have this line:
echo $form->input('picture');

I basically would like the system to grab the URL to the ('picture')
field in the database, and create a thumbnail of the specified size.

This is my attempt at an afterFilter() in my PostsController:
function afterFilter() {
$this->Thumbnail->render =
array(['Post']['picture'],
'path'=>'pictures',
'width'=>100,
'height'=>150,
'quality'=>80,
'extension'=>'png'
);
}

.. Which clearly isn't working right. I'm pretty sure it's because
I've made a few (many?) mistakes when writing my afterFilter().
Can anyone help me out?
--~--~-~--~~~---~--~~
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
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Automagically filling table-fields?

2009-07-04 Thread eMilk

Hi - using that line doesn't work either. So did I mess up with the
AuthComponent implementation then?
The Auth implementation is based heavily on what I could read up on
here: 
http://mrphp.com.au/code/code-category/cakephp/cakephp-1-2/simple-auth-users-habtm-groups-cakephp

When looking at the 'username' field in my 'posts' table, all the
posts I tried (including the one with the modification you suggested)
turns out as NULL.
http://imgur.com/NfwUY.png - see.

On Jul 4, 9:35 pm, Hendry  wrote:
> Hi,
>
> That's weird, could you test using this line, just to make sure you
> implement the AuthComponent correctly:
>
> $this->data['Post']['username'] = 'Hendry';
>
> Regards,
> Hendry
>
> On Sun, Jul 5, 2009 at 3:28 AM, eMilk wrote:
> > Hi Hendry,
>
> > Thanks - didn't fix it though - still no data being added to the
> > 'username' field automatically yet. :(
--~--~-~--~~~---~--~~
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
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Automagically filling table-fields?

2009-07-04 Thread eMilk

Hi Hendry,

Thanks - didn't fix it though - still no data being added to the
'username' field automatically yet. :(

On Jul 4, 9:21 pm, Hendry  wrote:
> Hi,
>
> should be Post not Posts:
>
> $this->data['Post']['username'] = $this->Auth->user('username');
>
> Regards,
> Hendry
>
> On Sun, Jul 5, 2009 at 2:58 AM, eMilk wrote:
> > This is my PostsController::add():
> >        function add() {
> >                        if (!empty($this->data)) {
> >                                $this->data['Posts']['username'] = 
> > $this->Auth->user
> > ('username');
> >                        if  ($this->Post->save($this->data)) {
> >                                $this->Session->setFlash('Your robot has 
> > been saved.');
> >                                $this->redirect(array('action' => 'index'));
> >                        }
> >                }
> >        }
--~--~-~--~~~---~--~~
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
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Automagically filling table-fields?

2009-07-04 Thread eMilk

Alright, after some messing around, I cant seem to work this thing
out. I've attached some dumps:

My 'posts' table, after running the
  ALTER TABLE ORDERS
  ADD FOREIGN KEY (`username`) REFERENCES users(`username`);
command:

-
CREATE TABLE `posts` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `created` datetime default NULL,
  `username` varchar(50) default NULL,
  `name` varchar(15) NOT NULL,
  `year` date NOT NULL,
  `country` varchar(12) NOT NULL,
  `origin` varchar(40) NOT NULL,
  `video` varchar(60) NOT NULL,
  `picture` varchar(100) NOT NULL,
  `text` text NOT NULL,
  `rating` varchar(3) NOT NULL,
  `keywords` varchar(100) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `username` (`username`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=36 ;


-- Dumping data for table `posts`

INSERT INTO `posts` VALUES(1, '1984-10-26 00:00:00', 'Me', 'R2-D2',
'1977-05-25', 'USA', 'Star Wars', 'http://www.youtube.com/watch?
v=gQCWV4vuz', 'http://localhost/images/r2d2.jpg', 'R2-D2 (phonetically
spelled Artoo-Detoo)', '02', 'cyborg, assassin, military, war');

The 'posts' data is just some dummy data I typed in manually..

This is my PostsController::add():
function add() {
if (!empty($this->data)) {
$this->data['Posts']['username'] = 
$this->Auth->user
('username');
if  ($this->Post->save($this->data)) {
$this->Session->setFlash('Your robot has been 
saved.');
$this->redirect(array('action' => 'index'));
}
}
}


And just in case, here's my users table:
CREATE TABLE `users` (
  `id` int(11) NOT NULL auto_increment,
  `username` char(50) NOT NULL,
  `password` char(50) NOT NULL,
  `active` tinyint(4) NOT NULL default '0',
  `email` varchar(255) NOT NULL,
  `created` datetime default NULL,
  `modified` datetime default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;

Thanks again - I really hope you can tell me where I've made a
mistake.


On Jul 4, 8:00 pm, eMilk  wrote:
> Hi Brian,
>
> Thanks - will try that out right away! :)
>
> On Jul 4, 7:12 pm, brian  wrote:
>
> > Add a user_id column to the posts table. You should use that as your
> > foreign key.
>
> > As for filling it in automatically, you can do that right before
> > save() in PostsController::add()
>
> > $this->data['Posts']['user_id'] = $this->Auth->user('id');
>
> > On Sat, Jul 4, 2009 at 12:55 PM, eMilk wrote:
>
> > > Hi all you experienced bakers.
>
> > > I'm new to the world of CakePHP, so forgive me if this is a very basic
> > > question.
> > > I followed a few tutorials, and have a question about getting
> > > information filled automagically into the different fields of the
> > > table.
>
> > > First off, I extended the blog tutorial with a simple implementation
> > > of Auth, based heavily on what I could find here:
> > >http://mrphp.com.au/code/code-category/cakephp/cakephp-1-2/simple-aut...
>
> > > Then, I've extended on the blog tutorial, and have been adding new
> > > fields to the "posts" table from the example. One of the new fields, I
> > > created is 'username'.
>
> > > Here's the deal: I'd really like to have the 'username' field being
> > > filled automagically based on what user is logged in, just like it
> > > does to both the 'modified' and 'created' fields by default in the
> > > blog-tutorial.
>
> > > From the blog-tutorial, bottom: [10.1.2 Creating the Blog Database]
> > > "Check out "CakePHP Conventions" for more information, but suffice it
> > > to say that naming our table 'posts' automatically hooks it to our
> > > Post model, and having fields called 'modified' and 'created' will be
> > > automagically managed by Cake."
>
> > > Thanks in advance!
> > > Best regards,
> > > Emil K
--~--~-~--~~~---~--~~
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
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Automagically filling table-fields?

2009-07-04 Thread eMilk

Hi Brian,

Thanks - will try that out right away! :)

On Jul 4, 7:12 pm, brian  wrote:
> Add a user_id column to the posts table. You should use that as your
> foreign key.
>
> As for filling it in automatically, you can do that right before
> save() in PostsController::add()
>
> $this->data['Posts']['user_id'] = $this->Auth->user('id');
>
> On Sat, Jul 4, 2009 at 12:55 PM, eMilk wrote:
>
> > Hi all you experienced bakers.
>
> > I'm new to the world of CakePHP, so forgive me if this is a very basic
> > question.
> > I followed a few tutorials, and have a question about getting
> > information filled automagically into the different fields of the
> > table.
>
> > First off, I extended the blog tutorial with a simple implementation
> > of Auth, based heavily on what I could find here:
> >http://mrphp.com.au/code/code-category/cakephp/cakephp-1-2/simple-aut...
>
> > Then, I've extended on the blog tutorial, and have been adding new
> > fields to the "posts" table from the example. One of the new fields, I
> > created is 'username'.
>
> > Here's the deal: I'd really like to have the 'username' field being
> > filled automagically based on what user is logged in, just like it
> > does to both the 'modified' and 'created' fields by default in the
> > blog-tutorial.
>
> > From the blog-tutorial, bottom: [10.1.2 Creating the Blog Database]
> > "Check out "CakePHP Conventions" for more information, but suffice it
> > to say that naming our table 'posts' automatically hooks it to our
> > Post model, and having fields called 'modified' and 'created' will be
> > automagically managed by Cake."
>
> > Thanks in advance!
> > Best regards,
> > Emil K
--~--~-~--~~~---~--~~
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
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Automagically filling table-fields?

2009-07-04 Thread eMilk

Hi all you experienced bakers.

I'm new to the world of CakePHP, so forgive me if this is a very basic
question.
I followed a few tutorials, and have a question about getting
information filled automagically into the different fields of the
table.

First off, I extended the blog tutorial with a simple implementation
of Auth, based heavily on what I could find here:
http://mrphp.com.au/code/code-category/cakephp/cakephp-1-2/simple-auth-users-habtm-groups-cakephp

Then, I've extended on the blog tutorial, and have been adding new
fields to the "posts" table from the example. One of the new fields, I
created is 'username'.

Here's the deal: I'd really like to have the 'username' field being
filled automagically based on what user is logged in, just like it
does to both the 'modified' and 'created' fields by default in the
blog-tutorial.

>From the blog-tutorial, bottom: [10.1.2 Creating the Blog Database]
"Check out "CakePHP Conventions" for more information, but suffice it
to say that naming our table 'posts' automatically hooks it to our
Post model, and having fields called 'modified' and 'created' will be
automagically managed by Cake."

Thanks in advance!
Best regards,
Emil K

--~--~-~--~~~---~--~~
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
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---