This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

Day 3 problem changing the layout

Discussion around this tutorial for symfony 1.0.x

Day 3 problem changing the layout

by BabySnake » Sat Apr 12, 2008 6:40 pm

Hi!

So, i'm trying out day 3 now... I had some problems with the first example, changing the layout. Nothing happens when I edit the this file "/apps/frontend/templates/layout.php".

Maybe I'm missing something... are you supposed to download new code for every chapter? I noticed for instance that my file "/apps/frontend/config/config.php" is rather short compared to the one in the zip (the source code). Mine is:

Code: Select all
<?php

// include project configuration
include(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php');

// symfony bootstraping
require_once($sf_symfony_lib_dir.'/util/sfCore.class.php');
sfCore::bootstrap($sf_symfony_lib_dir, $sf_symfony_data_dir);


Are you supposed to edit the config file, or is it generated?

thanks!
/B
BabySnake
Member
 
Posts: 86
Joined: Sun Mar 30, 2008 6:50 pm
Location: Sweden

Re: Day 3 problem changing the layout

by weaverryan » Sat Apr 12, 2008 6:55 pm

Good questions.

First, your config.php file is fine. This file is generated when you initialize your application via the
Code: Select all
symfony init-app app-name

command. You can then modify it if you need some special, expert functionality. I'm looking at the askeet one right now, and it looks like they've just made some modifications in there because their project structure is a little different than normal. In other words, if you're creating a project at home and following along with the tutorial, your config.php file is just fine.

Now, the next problem is with the layout. Modifying your layout.php file in apps/##app-name##/templates should be doing the trick. First, let me mention that the layout that is used is specified in the app/##app-name##/config/view.yml file under the layout key. So, if layout is set to "my_layout", then the my_layout.php file would be used. By default, however, the value is layout, which means that modifying your layout.php file should be exactly what you need to do.

So, check out that view.yml layout value for me, make sure it lines up with the correct template file. Then, report back and we'll see if we can't keep you moving through the tutorial.

When I did the tutorial I did what you're doing, I simply created my own project at home and followed along with the tutorial (I didn't download the source). I would recommend this as the askeet tutorials and source aren't 100% updated and accurate.
Ryan Weaver - CEO of KnpLabs US
Offering Symfony2 training May 19th & 20th - Nasvhille, TN and June 6th & 7th - New York, NY

http://www.thatsquality.com
@weaverryan
User avatar
weaverryan
Faithful Member
 
Posts: 784
Joined: Sat Nov 10, 2007 1:50 am
Location: Nashville, TN

Re: Day 3 problem changing the layout

by BabySnake » Sat Apr 12, 2008 7:14 pm

Ok thanks :)~ :-)~ :smile:

By the way.. The location i'm browsing to is: http://localhost/frontend_dev.php

Here's my view.yml

Code: Select all
default:
  http_metas:
    content-type: text/html

  metas:
    title:        symfony project
    robots:       index, follow
    description:  symfony project
    keywords:     symfony, project
    language:     en

  stylesheets:    [main]

  javascripts:    []

  has_layout:     on
  layout:         layout
BabySnake
Member
 
Posts: 86
Joined: Sun Mar 30, 2008 6:50 pm
Location: Sweden

Re: Day 3 problem changing the layout

by weaverryan » Sat Apr 12, 2008 7:30 pm

yea, everything looks good there. It also helps that you're using the dev environment, that way you won't run into any caching problems while you're developing.

My thought is that you may not be modifying the correct layout.php file. The code of the askeet tutorial does something funny with their project structure, and I'm not sure why. instead of having apps/frontend, they don't have an apps directory, and instead just place the frontend folder right at the project root. I don't think they cover this anywhere in the tutorial, and if you're creating a project from home, you shouldn't end up with this structure.

My point is, if you're looking at their code, there may be some confusion as to where the correct application exists. Under a normal project, with the application called frontend, the exact file you want to modify inside your project directory is:

Code: Select all
apps/frontend/templates/layout.php


However, it looks like in the actual askeet source the file would be:

Code: Select all
frontend/templates/layout.php


So, make sure you're modifying the correct layout.php file. To be sure, try renaming the file to layout2.php. If you renamed the correct file, Symfony will throw an error.
Ryan Weaver - CEO of KnpLabs US
Offering Symfony2 training May 19th & 20th - Nasvhille, TN and June 6th & 7th - New York, NY

http://www.thatsquality.com
@weaverryan
User avatar
weaverryan
Faithful Member
 
Posts: 784
Joined: Sat Nov 10, 2007 1:50 am
Location: Nashville, TN

Re: Day 3 problem changing the layout

by BabySnake » Sat Apr 12, 2008 7:41 pm

ok, when i changed the name of layout.php (apps/frontend/templates/layout.php) to "layout2.php" I got the sfRenderException..

That's interesting... that means I'm editing the right file, doesn't it?
Maybe i'm browsing to the wrong address? Is it important to have a "askeet" host rather than a "localhost"? I didn't bother to change the "hosts" file etc...
BabySnake
Member
 
Posts: 86
Joined: Sun Mar 30, 2008 6:50 pm
Location: Sweden

Re: Day 3 problem changing the layout

by weaverryan » Sat Apr 12, 2008 7:47 pm

If you rename that file and get an error, that means that symfony IS using that layout.php file for your layout. So, everything else is good - that IS the correct file. Throwing that error proves that everything is setup right, and so modifying it absolutely should modify your layout. What happens if you drastically modify that file, say, by deleting all of the contents?
Ryan Weaver - CEO of KnpLabs US
Offering Symfony2 training May 19th & 20th - Nasvhille, TN and June 6th & 7th - New York, NY

http://www.thatsquality.com
@weaverryan
User avatar
weaverryan
Faithful Member
 
Posts: 784
Joined: Sat Nov 10, 2007 1:50 am
Location: Nashville, TN

Re: Day 3 problem changing the layout

by BabySnake » Sat Apr 12, 2008 7:58 pm

If I clear the file so that it's empty, it still shows a page that look like this: <img src="http://www.symfony-project.org/images/tutorials/first_congrats.gif" border=0 alt="http://www.symfony-project.org/images/tutorials/first_congrats.gif">
BabySnake
Member
 
Posts: 86
Joined: Sun Mar 30, 2008 6:50 pm
Location: Sweden

Re: Day 3 problem changing the layout

by weaverryan » Sat Apr 12, 2008 8:21 pm

ooooooh. Well that changes everything!

That is simply the default Symfony screen that's shown when you have an application created, but no modules yet.

Here's how it works, each application consists of modules. Each module consists of actions. Each actions is roughly equal to one url in the browser. What you have right now is an application, but no modules, and therefore no actions (and so no legitimate urls). To create a module, do the following:

symfony init-module frontend main

That will give you a module inside frontend called main. Now, if you go to your apps/frontend/config.settings.yml file, you'll see the following entry:

Code: Select all
#    default_module:         default


change this to:

Code: Select all
    default_module:         main


That tells Symfony to automatically use your "main" module when you browse to the root of your application (i.e. frontend_dev.php). Having default in there routes you to a special Symfony module that displays that message.

Now, if you refresh your browser, you should still see that basic screen, but it will be slightly different.

Go to the apps/frontend/modules/main/actions/actions.class.php file.

By default, the executeIndex method is being executed when you go to frontend_dev.php. However, this method has a call in their that forwards you back to Symfony's "default" module. Go ahead and delete that line (so that the executeIndex method is empty). Refresh, you'll see a blank page, one that uses your layout.php for layout, and your indexSuccess.php file in the apps/frontend/modules/main/templates directory for its content.

Welcome to Symfony, now you're moving
Ryan Weaver - CEO of KnpLabs US
Offering Symfony2 training May 19th & 20th - Nasvhille, TN and June 6th & 7th - New York, NY

http://www.thatsquality.com
@weaverryan
User avatar
weaverryan
Faithful Member
 
Posts: 784
Joined: Sat Nov 10, 2007 1:50 am
Location: Nashville, TN

Re: Day 3 problem changing the layout

by BabySnake » Sat Apr 12, 2008 8:47 pm

Hello, thanks for your tip! I didn't get it to work :x , but maybe I'm tired. I will try again tomorrow.
BabySnake
Member
 
Posts: 86
Joined: Sun Mar 30, 2008 6:50 pm
Location: Sweden

Re: Day 3 problem changing the layout

by BabySnake » Sun Apr 13, 2008 4:30 pm

Ok now it works!

Actuallt it was his file "/apps/frontend/config/routing.yml" that needed to be updated. It used to be:
Code: Select all
# default rules
homepage:
  url:   /
  param: { module: default, action: index }
.
.
.


Then I changed it to:
Code: Select all
# default rules
homepage:
  url:   /
  param: { module: question, action: list }

.
.


I compared my files with the files from this guy Balth (thanks!), then I saw this... Seems like the tutorial should point this out earlier in section 3, i.e before you start editing layout.php, or maybe I'm stupid...

Thanks!
BabySnake
Member
 
Posts: 86
Joined: Sun Mar 30, 2008 6:50 pm
Location: Sweden

Re: Day 3 problem changing the layout

by ASDS » Thu Jun 12, 2008 9:16 pm

Hi everyone,

I have same problem like BabySnake mentioned here in this page. I was getting the default congratulation page until I followed solution here and now after typing "http:/127.0.0.1/frontend_dev.php" in Firefox I don't either get the default congratulation page nor askeet congratulation page instead I get the page which has a askeet text in purple which means my css file is working, but not any congratulation message
just this

askeet
question
Id User Title Body Created at Updated at
1 Feeling how are you feeling today? 2008-06-11 14:48:53 2008-06-11 14:48:53
2 feeling 2 I saif how are yu? 2008-06-11 14:50:53 2008-06-11 14:50:53
create


any idea?

You also can see attachment.

Thanks in advance for any help and suggestions
ASDS
Attachments
Screenshot.png
Screenshot.png (59.68 KiB) Viewed 1412 times
ASDS
Junior Member
 
Posts: 29
Joined: Mon Jun 09, 2008 7:36 am
Location: San Diego, CA

Re: Day 3 problem changing the layout

by BabySnake » Tue Jun 24, 2008 8:56 pm

Hey...

That looks really strange. I've never seen it before..
The best advise I can give you is to compare your files with the "sticky" sourcefiles entitled "Day 1-16 source code" at the top of the forum/askeet view.

/B
BabySnake
Member
 
Posts: 86
Joined: Sun Mar 30, 2008 6:50 pm
Location: Sweden

Re: Day 3 problem changing the layout

by BabySnake » Tue Jun 24, 2008 8:59 pm

Or... the files by Balth located under the section "Day-by-day askeet files [unofficial]" are better...
BabySnake
Member
 
Posts: 86
Joined: Sun Mar 30, 2008 6:50 pm
Location: Sweden

Re: Day 3 problem changing the layout

by ataros » Fri Aug 15, 2008 7:43 am

I have the same problem as the poster above - the "Symfony Project Created" page displays instead of the Askeet congratulations page. Any ideas why?
ataros
Junior Member
 
Posts: 3
Joined: Wed Aug 13, 2008 8:24 am

Re: Day 3 problem changing the layout

by halfer » Wed Sep 03, 2008 10:49 am

ataros wrote: I have the same problem as the poster above - the "Symfony Project Created" page displays instead of the Askeet congratulations page. Any ideas why?

Did the explanations in this thread not help? Let us know which of them you've tried, and what happened when you tried them.
halfer
Faithful Member
 
Posts: 10148
Joined: Mon Jan 30, 2006 1:16 pm
Location: West Midlands, UK

Re: Day 3 problem changing the layout

by ASDS » Thu Sep 04, 2008 12:29 am

go to your httpd.conf file and make the path as same as your project is stored. I solved this isuue just by changing the path under httpd.conf
ASDS
Junior Member
 
Posts: 29
Joined: Mon Jun 09, 2008 7:36 am
Location: San Diego, CA