|
|||
|
Hi, Im stugling with a strange behavier her.
When I go to http://localhost:8080/no/part2/html/index.php I get the index.phtml rendered as i should. If I go to another adress (http://localhost:8080/no/part2/appli...Controller.php) during a post from a form, I only get a emty page, not Transfere.phtml rendered. Any Ide about this error? Driving me crazy here ... My .htaccess fil: Code:
RewriteEngine on RewriteBase / RewriteRule !\.(js|ico|txt|gif| From IE source: Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<meta http-equiv="Content-Type" type="text/html; charset=UTF-8">
<script type="text/javascript">
function button_pressed(){
alert("knapp trykket");
test = getElementById("tekstboks");
alert(test);
}
</script>
<title>Test av rammeverk nummer 2</title>
</head>
<body>
<h1 style="background: blue; color: white;">Her skal du leke litt med de ulike kontrollene og se om responstiden er bra nok. Husk at layout ikke har noe med denne testen 㟧j�.
</h1>
<p>
</p>
<div id = "done" name = "done"></div>
<p>
</p>
<p>
</p>
</br>
</body>
</html></br></br><form id="stdkontroller1" enctype="application/x-www-form-urlencoded" action="http://localhost:8080/no/part2/application/default/controllers/TransfereController.php" method="post"><dl class="zend_form">
<dt><label for="tekstboks" class="optional">Skriv inn en tekst i tekstboksen:</label></dt>
<dd>
<input type="text" name="tekstboks" id="tekstboks" value=""></dd>
<dt></dt><dd>
<input type="submit" name="Sendtillistboks" id="Sendtillistboks" value="Send til listboks"></dd>
<dt></dt>
<dd>
<select name="listboks" id="listboks" label="Listeboks: " size="5">
<option value="0" label="Valg 1">Valg 1</option>
<option value="1" label="Valg 2">Valg 2</option>
</select></dd></dl></form><form id="stdkontroller2" enctype="application/x-www-form-urlencoded" action="http://localhost:8080/no/part2/application/default/controllers/TransfereController.php" method="post"><dl class="zend_form">
<dt></dt>
<dd>
<label style="white-space: nowrap;"><input type="checkbox" name="groups[]" value="1">Valg 1</label><br /><label style="white-space: nowrap;"><input type="checkbox" name="groups[]" value="2">Valg 2</label><br /><label style="white-space: nowrap;"><input type="checkbox" name="groups[]" value="3">Valg 3</label></dd></dl></form><form id="stdkontroller3" enctype="application/x-www-form-urlencoded" action="http://localhost:8080/no/part2/application/default/controllers/TransfereController.php" method="post"><dl class="zend_form">
<dt></dt>
<dd>
<label style="white-space: nowrap;"><input type="radio" name="valg" value="0">Valg1</label><br /><label style="white-space: nowrap;"><input type="radio" name="valg" value="1">Valg 1</label></dd></dl></form>
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<meta http-equiv="Content-Type" type="text/html; charset=UTF-8">
<script type="text/javascript">
function button_pressed(){
alert("knapp trykket");
test = getElementById("tekstboks");
alert(test);
}
</script>
<title>Test av rammeverk nummer 2</title>
</head>
<body>
<h1 style="background: blue; color: white;">Her skal du leke litt med de ulike kontrollene og se om responstiden er bra nok. Husk at layout ikke har noe med denne testen å gjøre ..
</h1>
<p>
<?php $this->form1; ?>
</p>
<div id = "done" name = "done"></div>
<p>
<?php $this->form2; ?>
</p>
<p>
<?php $this->form3; ?>
</p>
</br>
<?php $this->viewText; ?>
</body>
</html>
Last edited by Aurheim : 05-19-2008 at 03:10 AM. Reason: added source from IE |
|
|||
|
omg Aurheim please read anything about Zend Framewrok on maunual or any other tuturial. You are asking about such trivial question that it drives me crazy.
My propostition is very simple - read something about client side of application (html, javascript), basics of php and design patters (including MVC), mod_rewrite, and only then ZF. You are definetely trying to do things that are too hard for you. However, I am helpful person so I'l try to answer your questions. 1. First of all, looking at the links you're accessing - configure your web server root to html directory, or make the structure as follows (it is not required but maybe it will help you): Code:
+application
bootstrap.php
+modules
+default
+controllers
IndexController.php
TransfereController.php
...
+models
+views
+index // IndexController
index.phtml // IndexController:indexAction()
test.phtml // IndexController:testAction()
+transfere
index.phtml // TransfereController:indexAction()
other.phtml // TransfereController:otherAction()
+someothermodule
+configs
...
+library
+Zend
...
+public
+css
+js
+images
index.php // require_once '../application/bootstrap.php';
.htaccess // RewriteEngine On
!\.(js|ico|gif|jpg|png|css)$ index.php
now if you go to http://localhost/app/, IndexController and indexAction() from default module is accessed. application/modules/default/index/index.phtml Code:
http://localhost/app/index => IndexController:indexAction() application/modules/default/index/index.phtml http://localhost/app/index/index => IndexController:indexAction() application/modules/default/index/index.phtml http://localhost/app/index/test => IndexController:testAction() application/modules/default/index/test.phtml http://localhost/app/transfere => TransfereController:indexAction() application/modules/default/transfere/index.phtml http://localhost/app/transfere/other => TransfereController:otherAction() application/modules/default/transfere/other.phtml http://localhost/app/someothermodule/index/index => Someothermodule_IndexController:indexAction() application/modules/someothermodule/index/index.phtml In controller you propably write: PHP Code:
However, You should type in PHP Code:
Last edited by kuba : 05-19-2008 at 07:05 PM. |
|
|||
|
Thanks for the reply.
I do have read a lot about it, and have seen several hours of video about it. The problem is that there always are some small bits missing or just not explained good enough in the tutorials and manuals. This is probably the best explination that I have seen so far for the folder/namingconvention. The problem with the view was that I missunderstood the namingconvention about the .pthm files. +transfere index.phtml // TransfereController:indexAction() other.phtml // TransfereController therAction()became +transfere transfere.phtml // TransfereController:indexAction() other.phtml // TransfereController therAction()and would of cource not render. To bad nobody illustrated the folder/file tree as you did here before. Would have saved me some hours spent researching. Since I did not have any proof of the environment working as it should, it was easy to suspect some configuration error when the resulting html did not follow the standard outline. |
|
|||
|
I would also like to know if it is normal that any code from Zend comes AFTHER the </html> tag in the source, even if it was intended in the <body> tag when echoed out in the .phtml file.
Definitely no. When you use the forms: <?php $this->form1; ?> <?php $this->form2; ?> <?php $this->form3; ?> It appears that you are trying to use View Helper classes that echo output within the helper class. It would be better to return the helper text to the view script and echo it there: <?php echo $this->form1; ?> Or insert the form data into the View, like Kuba mentioned: $this->view->form1 = $form1; +transfere index.phtml // TransfereController:indexAction() other.phtml // TransfereController therAction()index.phtml is the default view when no action is specified for the controller. I believe that is the case for all controllers unless you specifically change the controllers behavior. |
|
|||
|
you can read more about Choosing Your Application's Directory Layout at Choosing Your Application's Directory Layout - Zend Framework Wiki and Zend Framework Default Project Structure - Wil Sinclair - Zend Framework Wiki
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|