Still Stumped has anyone else ran into this issue? Thanks
On Oct 9, 3:36 pm, seacloud9 <[EMAIL PROTECTED]> wrote:
> Anyones help in this matter would be greatly appreciated truly
> stumped..
>
> On Oct 9, 12:17 pm, seacloud9 <[EMAIL PROTECTED]> wrote:
>
> > I have been working on the blog tutorial. I enabled clean urls. I
> > would now like to add comments but I have been having some issues....
> > Any and All help would be greatly appreciated. Thanks in advance for
> > your time.
>
> > /*------------------------------ Comments Model
> > -----------------------------------
>
> > <?php
> > class Comment extends AppModel {
> > var $name = 'Comment';
> > var $belongsTo = array(
> > 'Post' =>
> > array('className' => 'Post',
> > 'foreignKey' => 'post_id'
> > ),
> > );}
>
> > ?>
> > /*------------------------------ Post Model
> > -----------------------------------
>
> > <?php
> > class Post extends AppModel
> > {
> > var $name = 'Post';
>
> > var $validate = array(
> > 'title' => VALID_NOT_EMPTY,
> > 'body' => VALID_NOT_EMPTY
> > );
>
> > function beforeSave()
> > {
> > if (empty($this->id))
> > {
> > $this->data[$this->name]['url'] =
> > $this->getUniqueUrl($this->data[$this->name]['title'], 'url');
>
> > }
>
> > return true;
> > }}
>
> > ?>
>
> > /*------------------------------ Comment Controller
> > -----------------------------------
> > <?php
> > class CommentsController extends AppController {
> > var $name = 'Comments';
> > var $layout = 'comments';
> > var $uses = array('Comment');
> > function add()
> > {
> > if (empty($this->params['data']))
> > {
> > $this->Session->setFlash ("No direct access ;o)");
> > }
> > else
> > {
> > if ($this->Comment->save($this->params['data']))
> > {
> > $this->Session->setFlash ("Comment added");
> > }
> > else
> > {
> > $this->Session->setFlash ("Error adding comment");
> > }
> > }
> > $Url = $this->referer("/");
> > $this->redirect ($Url);
> > }}
>
> > ?>
>
> > /*------------------------------ Post Controller
> > -----------------------------------
>
> > <?php
>
> > class PostsController extends AppController
> > {
>
> > var $name = 'Posts';
> > var $layout = 'Blog-Posts';
>
> > function index()
> > {
> > $this->set('posts', $this->Post->findAll());
> > }
>
> > function view($url,$id)
> > {
> > $post = $this->Post->findByUrl($url);
> > $this->Post->setId($id);
> > $this->set('post', $post);
>
> > }
>
> > function admin_add()
> > {
> > if (!empty($this->data))
> > {
> > if ($this->Post->save($this->data))
> > {
> > $this->flash('Your post has been saved.','/posts');
> > }
> > }
> > }
>
> > function admin_delete($id)
> > {
> > $this->Post->del($id);
> > $this->flash('The post with id: '.$id.' has been deleted.', '/
> > posts');
> > }
>
> > function admin_edit($id = null)
> > {
> > if (empty($this->data))
> > {
> > $this->Post->id = $id;
> > $this->data = $this->Post->read();
> > }
> > else
> > {
> > if ($this->Post->save($this->data['Post']))
> > {
> > $this->flash('Your post has been updated.','/posts');
> > }
> > }
> > }
>
> > }
>
> > ?>
> > /*------------------------------ Post View
> > -----------------------------------
>
> > <h1><?php echo $post['Post']['title']?></h1>
>
> > <p><small>Created: <?php echo $post['Post']['created']?></small></p>
>
> > <p><?php echo $post['Post']['body']?></p>
> > <?php
> > if (isset($data['Comment']))
> > {
> > foreach ($data['Comment'] as $Comment)
> > {
> > echo "<div class=\"commentbody\">";
> > echo $Comment['body'];
> > echo "</div>";
> > echo "<div class=\"commenttitle\">";
> > echo "written by ".$Comment['user_id']."
> > ".$time->timeAgoInWords($Comment['created']);
> > echo "</div>";
> > }
>
> > }
>
> > else
> > {
> > echo "No comments yet.";
>
> > }
>
> > ?>
> > </div>
> > <div id="addcomment">
> > <?php
> > echo $html->formTag("/Comments/add");
> > echo
> > $html->hidden("Comment/post_id",(Array('value'=>$data['Post']
> > ['id'])));
> > echo $html->textarea("Comment/body", Array("cols"=>60,"rows"=>5));
> > echo "<br>";
> > echo $html->submit("Add Comment");
> > ?>
> > </form>
> > </div>
>
> > /*------------------------------ Comment
> > Add-----------------------------------
>
> > <h1>Add Comments</h1>
> > <form method="post" action="<?php echo action="<?php echo
> > $html->url('/comments/add/'.$post_id); ?>">
> > <p>
> > Body:
> > <?php echo
> > $html->hidden("Comment/post_id",(Array('value'=>$data['Post']
> > ['id'])));
> > $html->textarea('Comment/body', array('rows'=>'10')) ?>
> > <?php echo $html->tagErrorMsg('Comment/body', 'Comment is
> > required.') ?>
> > </p>
> > <p>
> > <?php echo $html->submit('Save') ?>
> > </p>
> > </form>
>
> > /*------------------------------ Comment
> > Table-----------------------------------
> > CREATE TABLE IF NOT EXISTS `comments` (
> > `id` int(10) unsigned NOT NULL auto_increment,
> > `user_id` int(10) default NULL,
> > `post_id` int(10) default NULL,
> > `photo_id` int(10) default NULL,
> > `url` varchar(50) NOT NULL,
> > `body` text,
> > `created` datetime default NULL,
> > `modified` datetime default NULL,
> > PRIMARY KEY (`id`)
> > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;
>
> >http://ihang10.com/posts/location
>
> > Thanks Again your advice on this matter is greatly appreciated..
> > Yours truly stumped..;(
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---