Part of the EllisLab Network
   
 
Blog in 20 minutes video tutorial? Maybe 240 or 380 minutes
Posted: 28 November 2009 10:01 AM   [ Ignore ]  
Summer Student
Total Posts:  4
Joined  11-28-2009

Hi all, I’m newbie into Codeigniter and I find is an excellent piece of software, I was pretty excited about using it, but now I am a little bit dissapointed.

This is my first php framework, trying to accomplish the video tutorial “blog in 20 minutes” and I am stuck… again, first I noticed that the video tutorial doesn’t speak about creating a model for the controller is necessary, so when talks about putting…

$data[‘query’] = $this->db->get(‘entries’);

into the blog controller it didn’t worked for me… after hours of searching I realize that I had to create a blog_model and create an

  function get_entries()
  {
      $query = $this->db->get(‘entries’);
      return $query->result();
  }

and replacing

$data[‘query’] = $this->db->get(‘entries’);
for
$data[‘query’] = $this->blog_model->get_entries();

Well… It took more or less four hours of headache

But now I am stuck in the function comments(), I get a 404 page, the url helper gives me the right link

http://localhost/codeigniter_test/index.php/blog/comments/1

I have tried to change the

$config[‘uri_protocol’]  = “AUTO”;

to every parameter and doesn’t work, I have tried to change

$config[‘base_url’]  = “http://localhost/codeigniter_test”;

with slash at the end and without… nothing

I have tried to create a comment model and nothing.

this is my comments function in the blog controller

  function comments()
  {
      $data[‘titlepag’] = ‘My Comment Title’;
      $data[‘headingpag’] = ‘My Comment Heading’;
     
      //echo $this->comment_model->test();
      $this->load->view(‘comment_view’, $data); 
  }

It wouldn’t be better to have an html updated tutorial than a video outdated tutorial? If somebody can help me I would really appreciate it. I am using XAMPP and Aptana IDE in an Apple environment. Thanks

Profile
 
 
Posted: 28 November 2009 10:32 AM   [ Ignore ]   [ # 1 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  3175
Joined  06-11-2007

DB interaction works perfectly fine in the controller but SHOULD be done in the model. It didnt mention it because its not a requirement.

It is perfectly possible to do the 20 minute tutorial in 20 minutes.

 Signature 

————————
Blog | Twitter | GitHub | BitBucket
————————-
PyroCMS - open source modular CMS built with CodeIgniter
PancakeApp - Simple, hosted invoicing/w project management

Profile
 
 
Posted: 28 November 2009 10:58 AM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  4
Joined  11-28-2009

Sorry but in my case it didn’t work the db interaction… following the tutorial I always get an error using it

A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: views/blog_view.php

Line Number: 9

Thats why I am using the model

Profile
 
 
Posted: 28 November 2009 11:01 AM   [ Ignore ]   [ # 3 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  3175
Joined  06-11-2007

Using a model you are just changing the location of the same code, something else is going wrong here.

 Signature 

————————
Blog | Twitter | GitHub | BitBucket
————————-
PyroCMS - open source modular CMS built with CodeIgniter
PancakeApp - Simple, hosted invoicing/w project management

Profile
 
 
Posted: 28 November 2009 11:03 AM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  4
Joined  11-28-2009

any clue?

Profile
 
 
Posted: 28 November 2009 11:28 AM   [ Ignore ]   [ # 5 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2126
Joined  06-04-2008
soyraro - 28 November 2009 04:03 PM

any clue?

Any code?

You’ve said an error occurred at line 9 of a file .. that you haven’t shown us.

Are you loading the database class?

Profile
 
 
Posted: 28 November 2009 01:00 PM   [ Ignore ]   [ # 6 ]  
Summer Student
Total Posts:  4
Joined  11-28-2009

Yes, I am loading the database class in autoload.php

$autoload[‘libraries’] = array(‘database’);

Ok I explain what I did… I followed the video tutorial and I founded an error where the tutorial says…

$data[‘query’] = $this->db->get(‘entries’);

in function index of the controller… when trying to load the blog_view that said

<html>
<head>
<title><?=$titlepag?></title>
</head>
<body>
<h1><?=$headingpag?></h1>

<?php foreach($query as $row): ?>

<?= $row->title ?>

<?= $row->body ?>

<?= anchor(‘blog/comments/’ . $row->id ,‘Comments’) ?>
<hr></hr>
<?php endforeach; ?>

</body>
</html>

It said

A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: views/blog_view.php

Line Number: 9

In every blog entry so I created the blog_model and It worked so I followed the tutorial again till I have found another error about listing the comments (if you read first post)... do you want me to post my files?

Thanks

Profile
 
 
Posted: 28 November 2009 01:29 PM   [ Ignore ]   [ # 7 ]  
Research Assistant
RankRankRank
Total Posts:  390
Joined  04-21-2009

Welcome to this forum soyrar!

Edit your posts like this.
1. Scroll to your last post.
2. Click [edit]
3. Highlight the code in your post
4. Click
5. Click [update post]

 Signature 

I love the smell of code in the morning.

Profile
 
 
Posted: 28 November 2009 01:54 PM   [ Ignore ]   [ # 8 ]  
Grad Student
Avatar
Rank
Total Posts:  75
Joined  01-28-2009

Try this

<?php foreach($query as $row): ?>
// change to
foreach($query->result() as $row
 Signature 

flaming-crud: Model generator for codeigniter
clip-gallery: Image Gallery helper library for codeigniter

Profile
 
 
Posted: 27 April 2012 02:57 PM   [ Ignore ]   [ # 9 ]  
Summer Student
Total Posts:  2
Joined  04-25-2012

is there any posibilty to get the source code?

Profile