tags:

views:

352

answers:

2

I made a blog database and created some tables in it. I have wriTten the related models and controller files for CakePHP. Also, I have been successful in adding a test user to the blog database using Cake's scaffolding feature. So far so good. However, I am facing problems when getting into the Views part of Cake PHP.
I created a "default.ctp" file and placed it into apps/views/layouts folder. Following is the file:

 <html>
<head>
<title>Cake PHP Application</title>
<?=$html->css('styles');?>
</head>
<body>
<div id="container">
<div id="content">
    <?=$content_for_layout;?>
    </div>
    </div>
</body>
</html>

I have also placed the styles.css in the app/webroot/css directory. Now, when I run this in my browser, I am getting the following screen

css('styles');?>

(default) 6 queries took 14 ms
Nr  Query Error Affected Num. rows Took (ms)
1   DESCRIBE `posts`  5 5 3
2   DESCRIBE `users`  5 5 3
3   DESCRIBE `tags`  3 3 3
4   DESCRIBE `posts_tags`  3 3 3
5   SELECT COUNT(*) AS `count` FROM `posts` AS `Post` LEFT JOIN `users` AS `User` ON (`Post`.`user_id` = `User`.`id`) WHERE 1 = 1  1 1 1
6   SELECT `Post`.`id`, `Post`.`name`, `Post`.`date`, `Post`.`content`, `Post`.`user_id`, `User`.`id`, `User`.`name`, `User`.`email`, `User`.`firstname`, `User`.`lastname` FROM `posts` AS `Post` LEFT JOIN `users` AS `User` ON (`Post`.`user_id` = `User`.`id`) WHERE 1 = 1 LIMIT 20 
    2 2 1

Why is it not displaying the posts as it does using the scaffolding feature. I know it will be different than scaffolding as i am using my styles. But, why is it showing nothing?? What am I missing?

+1  A: 

<?= ?> are PHP short tags. Do you have short tags enabled? It doesn't appear so. If you view the source of the page from your browser, you will see <?=$html->css('styles');?>.

To fix this, just replace:

<?=$html->css('styles');?>

with

<?php echo $html->css('styles'); ?>

Do the same with the $content_for_layout line.

jimyi
ya...I just figured that out. However, it is still not showing up the posts and test user data.
Learner
@Adit Does that mean the above problem is fixed? Please open a new question or edit this one to specify the "not showing up" problem then.
deceze
A: 

Hi this is the code brother of default.php

My Cake Blog Application css('styles'); ?>

keep this in file. and done

Shakti anand