You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 9, 2017. It is now read-only.
Copy file name to clipboardExpand all lines: gentle-introduction/en/04-The-Basics-of-Page-Creation.markdown
+13-13
Original file line number
Diff line number
Diff line change
@@ -179,9 +179,9 @@ Note that the use of the short opening tags (`<?=`, equivalent to `<?php echo`)
179
179
Linking to Another Action
180
180
-------------------------
181
181
182
-
You already know that there is a total decoupling between an action name and the URL used to call it. So if you create a link to `update` in a template as in Listing 4-10, it will only work with the default routing. If you later decide to change the way the URLs look, then you will need to review all templates to change the hyperlinks.
182
+
You already know that there is a total decoupling between an action name and the URL used to call it. So if you create a link to `update` in a template as in Listing 4-8, it will only work with the default routing. If you later decide to change the way the URLs look, then you will need to review all templates to change the hyperlinks.
@@ -190,9 +190,9 @@ Listing 4-10 - Hyperlinks, the Classic Way
190
190
191
191
To avoid this hassle, you should always use the `link_to()` helper to create hyperlinks to your application's actions. And if you only want to generate the URL part, the `url_for()` is the helper you're looking for.
192
192
193
-
A helper is a PHP function defined by symfony that is meant to be used within templates. It outputs some HTML code and is faster to use than writing the actual HTML code by yourself. Listing 4-11 demonstrates the use of the hyperlink helpers.
193
+
A helper is a PHP function defined by symfony that is meant to be used within templates. It outputs some HTML code and is faster to use than writing the actual HTML code by yourself. Listing 4-9 demonstrates the use of the hyperlink helpers.
194
194
195
-
Listing 4-11 - The `link_to()`, and `url_for()` Helpers
195
+
Listing 4-9 - The `link_to()`, and `url_for()` Helpers
196
196
197
197
[php]
198
198
<p>Hello, world!</p>
@@ -210,9 +210,9 @@ The resulting HTML will be the same as previously, except that when you change y
210
210
211
211
Form manipulation deserves a whole chapter of its own, since symfony provides many tools to make it even easier. You will learn more about these helpers in Chapter 10.
212
212
213
-
The `link_to()` helper, like many other helpers, accepts another argument for special options and additional tag attributes. Listing 4-12 shows an example of an option argument and the resulting HTML. The option argument is either an associative array or a simple string showing `key=value` couples separated by blanks.
213
+
The `link_to()` helper, like many other helpers, accepts another argument for special options and additional tag attributes. Listing 4-10 shows an example of an option argument and the resulting HTML. The option argument is either an associative array or a simple string showing `key=value` couples separated by blanks.
214
214
215
-
Listing 4-12 - Most Helpers Accept an Option Argument
215
+
Listing 4-10 - Most Helpers Accept an Option Argument
216
216
217
217
[php]
218
218
// Option argument as an associative array
@@ -232,7 +232,7 @@ Listing 4-12 - Most Helpers Accept an Option Argument
Whenever you use a symfony helper that outputs an HTML tag, you can insert additional tag attributes (like the `class` attribute in the example in Listing 4-12) in the option argument. You can even write these attributes in the "quick-and-dirty" HTML 4.0 way (without double quotes), and symfony will output them in nicely formatted XHTML. That's another reason why helpers are faster to write than HTML.
235
+
Whenever you use a symfony helper that outputs an HTML tag, you can insert additional tag attributes (like the `class` attribute in the example in Listing 4-10) in the option argument. You can even write these attributes in the "quick-and-dirty" HTML 4.0 way (without double quotes), and symfony will output them in nicely formatted XHTML. That's another reason why helpers are faster to write than HTML.
236
236
237
237
>**NOTE**
238
238
>Because it requires an additional parsing and transformation, the string syntax is a little slower than the array syntax.
@@ -242,9 +242,9 @@ Like all symfony helpers, the link helpers are numerous and have many options. C
242
242
Getting Information from the Request
243
243
------------------------------------
244
244
245
-
Whether the user sends information via a form (usually in a POST request) or via the URL (GET request), you can retrieve the related data from the action with the `getParameter()` method of the `sfRequest` object. Listing 4-13 shows how, in `update`, you retrieve the value of the `name` parameter.
245
+
Whether the user sends information via a form (usually in a POST request) or via the URL (GET request), you can retrieve the related data from the action with the `getParameter()` method of the `sfRequest` object. Listing 4-11 shows how, in `update`, you retrieve the value of the `name` parameter.
246
246
247
-
Listing 4-13 - Getting Data from the Request Parameter in the Action
247
+
Listing 4-11 - Getting Data from the Request Parameter in the Action
248
248
249
249
[php]
250
250
<?php
@@ -263,19 +263,19 @@ As a convenience, all `executeXxx()` methods take the current `sfRequest` object
263
263
264
264
If the data manipulation is simple, you don't even need to use the action to retrieve the request parameters. The template has access to an object called `$sf_params`, which offers a `get`() method to retrieve the request parameters, just like the `getParameter()` in the action.
265
265
266
-
If `executeUpdate()` were empty, Listing 4-14 shows how the `updateSuccess.php` template would retrieve the same `name` parameter.
266
+
If `executeUpdate()` were empty, Listing 4-12 shows how the `updateSuccess.php` template would retrieve the same `name` parameter.
267
267
268
-
Listing 4-14 - Getting Data from the Request Parameter Directly in the Template
268
+
Listing 4-12 - Getting Data from the Request Parameter Directly in the Template
>Why not use the `$_POST`, `$_GET`, or `$_REQUEST` variables instead? Because then your URLs will be formatted differently (as in `http://localhost/articles/europe/france/finance.html`, without `?` nor `=`), the usual PHP variables won't work anymore, and only the routing system will be able to retrieve the request parameters. And you may want to add input filtering to prevent malicious code injection, which is only possible if you keep all request parameters in one clean parameter holder.
275
275
276
-
The `$sf_params` object is more powerful than just giving a getter equivalent to an array. For instance, if you only want to test the existence of a request parameter, you can simply use the `$sf_params->has()` method instead of testing the actual value with `get()`, as in Listing 4-15.
276
+
The `$sf_params` object is more powerful than just giving a getter equivalent to an array. For instance, if you only want to test the existence of a request parameter, you can simply use the `$sf_params->has()` method instead of testing the actual value with `get()`, as in Listing 4-13.
277
277
278
-
Listing 4-15 - Testing the Existence of a Request Parameter in the Template
278
+
Listing 4-13 - Testing the Existence of a Request Parameter in the Template
0 commit comments