1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92 |
// database table
DROP TABLE IF EXISTS `posts`;
CREATE TABLE IF NOT EXISTS `posts` (
`id` int(11) unsigned NOT NULL auto_increment,
`title` varchar(255) default NULL,
`content` text,
`member_id` int(11) default NULL,
`created` datetime,
`modified` datetime,
PRIMARY KEY (`id`),
CONSTRAINT `FK_posts_members` FOREIGN KEY `FK_posts_members` (`member_id`)
REFERENCES `smf_members` (`id_member`)
ON DELETE NO ACTION
ON UPDATE NO ACTION
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
// models/post.php
<?php
class Post extends AppModel{
var $name = 'Post';
//var $belongsTo = array('Member');
'rule' => 'notEmpty'
),
'rule' => 'notEmpty'
)
);
}
?>
// controlle/posts_controller.php
<?php
class PostsController extends AppController{
var $name = 'Posts';
function index(){
//$posts = $this->Post->find('all');
//$this->set(compact('posts'));
}
function add(){
//$this->Post->create();
pr($this->data);
}
$smileys = $this->Smiley->set();
}
}
?>
// views/posts/add.ctp
<?php echo $menu->navigation('home'); ?>
<?php echo $smf->memberarea(); ?>
<div id="content">
<?php
echo $jquery->startWidget('addpost');
echo $form->create('Posts');
// WHY AREN'T YOU SAVE IN THE DATA ARRAY???
// creates a textarea for 'content'
echo $jquery->postbox('content', 'Message:', $smileys);
echo $jquery->clear();
echo $jquery->endWidget();
?>
</div>
// RESULT:
Array
(
[Posts] => Array
(
[title] =>
[content] => BLABLA
)
)
|
