diff --git a/docs/designers/language-basic-syntax/language-escaping.md b/docs/designers/language-basic-syntax/language-escaping.md index cb0b2a7c..58e75d58 100644 --- a/docs/designers/language-basic-syntax/language-escaping.md +++ b/docs/designers/language-basic-syntax/language-escaping.md @@ -1,4 +1,4 @@ -# Escaping Smarty Parsing +# Escaping Smarty parsing It is sometimes desirable or even necessary to have Smarty ignore sections it would otherwise parse. A classic example is embedding diff --git a/docs/designers/language-basic-syntax/language-syntax-functions.md b/docs/designers/language-basic-syntax/language-syntax-functions.md index 4628b984..93d94f6b 100644 --- a/docs/designers/language-basic-syntax/language-syntax-functions.md +++ b/docs/designers/language-basic-syntax/language-syntax-functions.md @@ -22,7 +22,7 @@ within delimiters like so: `{funcname attr1="val1" attr2="val2"}`. ``` - Both [built-in functions](../language-builtin-functions/index.md) and [custom - functions](../language-custom-functions.md) have the same syntax within + functions](../language-custom-functions/index.md) have the same syntax within templates. - Built-in functions are the **inner** workings of Smarty, such as diff --git a/docs/designers/language-builtin-functions/index.md b/docs/designers/language-builtin-functions/index.md index ccc4bf46..10dc3a6f 100644 --- a/docs/designers/language-builtin-functions/index.md +++ b/docs/designers/language-builtin-functions/index.md @@ -4,7 +4,7 @@ Smarty comes with several built-in functions. These built-in functions are the integral part of the smarty template engine. They are compiled into corresponding inline PHP code for maximum performance. -You cannot create your own [custom functions](../language-custom-functions.md) with the same name; and you +You cannot create your own [custom functions](../language-custom-functions/index.md) with the same name; and you should not need to modify the built-in functions. A few of these functions have an `assign` attribute which collects the @@ -12,7 +12,7 @@ result the function to a named template variable instead of being output; much like the [`{assign}`](language-function-assign.md) function. - [{append}](language-function-append.md) -- [{assign}](language-function-assign.md) or [{$var=...}](language-function-shortform-assign.md) +- [{assign} or {$var=...}](language-function-assign.md) - [{block}](language-function-block.md) - [{call}](language-function-call.md) - [{capture}](language-function-capture.md) diff --git a/docs/designers/language-builtin-functions/language-function-capture.md b/docs/designers/language-builtin-functions/language-function-capture.md index 3e3a8302..4f7a6021 100644 --- a/docs/designers/language-builtin-functions/language-function-capture.md +++ b/docs/designers/language-builtin-functions/language-function-capture.md @@ -68,6 +68,6 @@ I say just hello world See also [`$smarty.capture`](../language-variables/language-variables-smarty.md#smartycapture-languagevariablessmartycapture), -[`{eval}`](./language-function-eval.md), -[`{fetch}`](./language-function-fetch.md), [`fetch()`](../../programmers/api-functions/api-fetch.md) and +[`{eval}`](../language-custom-functions/language-function-eval.md), +[`{fetch}`](../language-custom-functions/language-function-fetch.md), [`fetch()`](../../programmers/api-functions/api-fetch.md) and [`{assign}`](./language-function-assign.md). diff --git a/docs/designers/language-custom-functions.md b/docs/designers/language-custom-functions.md deleted file mode 100644 index fd413c61..00000000 --- a/docs/designers/language-custom-functions.md +++ /dev/null @@ -1,19 +0,0 @@ -# Custom Functions - -Smarty comes with several custom plugin functions that you can use in -the templates. - -- [{counter}](./language-custom-functions/language-function-counter.md) -- [{cycle}](./language-custom-functions/language-function-cycle.md) -- [{eval}](./language-custom-functions/language-function-eval.md) -- [{fetch}](./language-custom-functions/language-function-fetch.md) -- [{html_checkboxes}](./language-custom-functions/language-function-html-checkboxes.md) -- [{html_image}](./language-custom-functions/language-function-html-image.md) -- [{html_options}](./language-custom-functions/language-function-html-options.md) -- [{html_radios}](./language-custom-functions/language-function-html-radios.md) -- [{html_select_date}](./language-custom-functions/language-function-html-select-date.md) -- [{html_select_time}](./language-custom-functions/language-function-html-select-time.md) -- [{html_table}](./language-custom-functions/language-function-html-table.md) -- [{mailto}](./language-custom-functions/language-function-mailto.md) -- [{math}](./language-custom-functions/language-function-math.md) -- [{textformat}](./language-custom-functions/language-function-textformat.md) diff --git a/docs/designers/language-custom-functions/index.md b/docs/designers/language-custom-functions/index.md new file mode 100644 index 00000000..81979654 --- /dev/null +++ b/docs/designers/language-custom-functions/index.md @@ -0,0 +1,19 @@ +# Custom Functions + +Smarty comes with several custom plugin functions that you can use in +the templates. + +- [{counter}](language-function-counter.md) +- [{cycle}](language-function-cycle.md) +- [{eval}](language-function-eval.md) +- [{fetch}](language-function-fetch.md) +- [{html_checkboxes}](language-function-html-checkboxes.md) +- [{html_image}](language-function-html-image.md) +- [{html_options}](language-function-html-options.md) +- [{html_radios}](language-function-html-radios.md) +- [{html_select_date}](language-function-html-select-date.md) +- [{html_select_time}](language-function-html-select-time.md) +- [{html_table}](language-function-html-table.md) +- [{mailto}](language-function-mailto.md) +- [{math}](language-function-math.md) +- [{textformat}](language-function-textformat.md) diff --git a/docs/designers/language-custom-functions/language-function-counter.md b/docs/designers/language-custom-functions/language-function-counter.md index cc1ac08f..de04c2fe 100644 --- a/docs/designers/language-custom-functions/language-function-counter.md +++ b/docs/designers/language-custom-functions/language-function-counter.md @@ -1,41 +1,45 @@ -{counter} {#language.function.counter} -========= +# {counter} `{counter}` is used to print out a count. `{counter}` will remember the count on each iteration. You can adjust the number, the interval and the -direction of the count, as well as determine whether or not to print the +direction of the count, as well as determine whether to print the value. You can run multiple counters concurrently by supplying a unique name for each one. If you do not supply a name, the name "default" will be used. +## Attributes + +| Attribute Name | Required | Description | +|----------------|----------|-----------------------------------------------------------| +| name | No | The name of the counter | +| start | No | The initial number to start counting from (defaults to 1) | +| skip | No | The interval to count by (defaults to 1) | +| direction | No | The direction to count (up/down) (defaults to 'up') | +| print | No | Whether or not to print the value (defaults to true) | +| assign | No | the template variable the output will be assigned to | + If you supply the `assign` attribute, the output of the `{counter}` function will be assigned to this template variable instead of being output to the template. - Attribute Name Type Required Default Description - ---------------- --------- ---------- ----------- ------------------------------------------------------ - name string No *default* The name of the counter - start number No *1* The initial number to start counting from - skip number No *1* The interval to count by - direction string No *up* The direction to count (up/down) - print boolean No *TRUE* Whether or not to print the value - assign string No *n/a* the template variable the output will be assigned to +## Examples +```smarty - {* initialize the count *} - {counter start=0 skip=2}
- {counter}
- {counter}
- {counter}
+{* initialize the count *} +{counter start=0 skip=2}
+{counter}
+{counter}
+{counter}
- +``` this will output: - - 0
- 2
- 4
- 6
- +```html +0
+2
+4
+6
+``` diff --git a/docs/designers/language-custom-functions/language-function-cycle.md b/docs/designers/language-custom-functions/language-function-cycle.md index 5986e632..661e490d 100644 --- a/docs/designers/language-custom-functions/language-function-cycle.md +++ b/docs/designers/language-custom-functions/language-function-cycle.md @@ -1,22 +1,23 @@ -{cycle} {#language.function.cycle} -======= +# {cycle} `{cycle}` is used to alternate a set of values. This makes it easy to for example, alternate between two or more colors in a table, or cycle through an array of values. - Attribute Name Type Required Default Description - ---------------- --------- ---------- ----------- ------------------------------------------------------------------------------------------------------------- - name string No *default* The name of the cycle - values mixed Yes *N/A* The values to cycle through, either a comma delimited list (see delimiter attribute), or an array of values - print boolean No *TRUE* Whether to print the value or not - advance boolean No *TRUE* Whether or not to advance to the next value - delimiter string No *,* The delimiter to use in the values attribute - assign string No *n/a* The template variable the output will be assigned to - reset boolean No *FALSE* The cycle will be set to the first value and not advanced +## Attributes + +| Attribute Name | Required | Description | +|----------------|----------|-------------------------------------------------------------------------------------------------------------| +| name | No | The name of the cycle | +| values | Yes | The values to cycle through, either a comma delimited list (see delimiter attribute), or an array of values | +| print | No | Whether to print the value or not (defaults to true) | +| advance | No | Whether or not to advance to the next value (defaults to true) | +| delimiter | No | The delimiter to use in the values attribute (defaults to ',') | +| assign | No | The template variable the output will be assigned to | +| reset | No | The cycle will be set to the first value and not advanced (defaults to false) | - You can `{cycle}` through more than one set of values in a template - by supplying a `name` attribute. Give each `{cycle}` an unique + by supplying a `name` attribute. Give each `{cycle}` a unique `name`. - You can force the current value not to print with the `print` @@ -30,20 +31,18 @@ through an array of values. function will be assigned to a template variable instead of being output to the template. - - - - {section name=rows loop=$data} +## Examples +```smarty +{section name=rows loop=$data} {$data[rows]} - {/section} - - +{/section} +``` The above template would output: - +```html 1 @@ -53,5 +52,4 @@ The above template would output: 3 - - +``` diff --git a/docs/designers/language-custom-functions/language-function-debug.md b/docs/designers/language-custom-functions/language-function-debug.md index 79b3477c..78861453 100644 --- a/docs/designers/language-custom-functions/language-function-debug.md +++ b/docs/designers/language-custom-functions/language-function-debug.md @@ -1,15 +1,14 @@ -{debug} {#language.function.debug} -======= +# {debug} `{debug}` dumps the debug console to the page. This works regardless of -the [debug](#chapter.debugging.console) settings in the php script. +the [debug](../chapter-debugging-console.md) settings in the php script. Since this gets executed at runtime, this is only able to show the -[assigned](#api.assign) variables; not the templates that are in use. +[assigned](../../programmers/api-functions/api-assign.md) variables; not the templates that are in use. However, you can see all the currently available variables within the scope of a template. - Attribute Name Type Required Default Description - ---------------- -------- ---------- -------------- --------------------------------- - output string No *javascript* output type, html or javascript +| Attribute Name | Required | Description | +|----------------|----------|------------------------------------------------------------| +| output | No | output type, html or javascript (defaults to 'javascript') | -See also the [debugging console page](#chapter.debugging.console). +See also the [debugging console page](../chapter-debugging-console.md). diff --git a/docs/designers/language-custom-functions/language-function-eval.md b/docs/designers/language-custom-functions/language-function-eval.md index e11f57e3..70c7a3d1 100644 --- a/docs/designers/language-custom-functions/language-function-eval.md +++ b/docs/designers/language-custom-functions/language-function-eval.md @@ -1,19 +1,20 @@ -{eval} {#language.function.eval} -====== +# {eval} `{eval}` is used to evaluate a variable as a template. This can be used for things like embedding template tags/variables into variables or tags/variables into config file variables. +## Attributes + +| Attribute Name | Required | Description | +|----------------|----------|------------------------------------------------------| +| var | Yes | Variable (or string) to evaluate | +| assign | No | The template variable the output will be assigned to | + If you supply the `assign` attribute, the output of the `{eval}` function will be assigned to this template variable instead of being output to the template. - Attribute Name Type Required Default Description - ---------------- -------- ---------- --------- ------------------------------------------------------ - var mixed Yes *n/a* Variable (or string) to evaluate - assign string No *n/a* The template variable the output will be assigned to - > **Note** > > - Evaluated variables are treated the same as templates. They follow @@ -21,64 +22,60 @@ output to the template. > templates. > > - Evaluated variables are compiled on every invocation, the compiled -> versions are not saved! However if you have [caching](#caching) +> versions are not saved! However, if you have [caching](../../programmers/caching.md) > enabled, the output will be cached with the rest of the template. > -> - If the content to evaluate doesn\'t change often, or is used +> - If the content to evaluate doesn't change often, or is used > repeatedly, consider using > `{include file="string:{$template_code}"}` instead. This may cache -> the compiled state and thus doesn\'t have to run the (comparably +> the compiled state and thus doesn't have to run the (comparably > slow) compiler on every invocation. -> + +## Examples + The contents of the config file, `setup.conf`. - - emphstart = - emphend = - title = Welcome to {$company}'s home page! - ErrorCity = You must supply a {#emphstart#}city{#emphend#}. - ErrorState = You must supply a {#emphstart#}state{#emphend#}. - - +```ini +emphstart = +emphend = +title = Welcome to {$company}'s home page! +ErrorCity = You must supply a {#emphstart#}city{#emphend#}. +ErrorState = You must supply a {#emphstart#}state{#emphend#}. +``` Where the template is: +```smarty +{config_load file='setup.conf'} - {config_load file='setup.conf'} - - {eval var=$foo} - {eval var=#title#} - {eval var=#ErrorCity#} - {eval var=#ErrorState# assign='state_error'} - {$state_error} - +{eval var=$foo} +{eval var=#title#} +{eval var=#ErrorCity#} +{eval var=#ErrorState# assign='state_error'} +{$state_error} +``` - The above template will output: - - This is the contents of foo. - Welcome to Foobar Pub & Grill's home page! - You must supply a city. - You must supply a state. - - +```html +This is the contents of foo. +Welcome to Foobar Pub & Grill's home page! +You must supply a city. +You must supply a state. +``` This outputs the server name (in uppercase) and IP. The assigned variable `$str` could be from a database query. - - assign('foo',$str); - ?> - - +``` Where the template is: - - {eval var=$foo} - - +```smarty +{eval var=$foo} +``` diff --git a/docs/designers/language-custom-functions/language-function-fetch.md b/docs/designers/language-custom-functions/language-function-fetch.md index 3dbc5610..2ff494fd 100644 --- a/docs/designers/language-custom-functions/language-function-fetch.md +++ b/docs/designers/language-custom-functions/language-function-fetch.md @@ -1,10 +1,15 @@ -{fetch} {#language.function.fetch} -======= +# {fetch} `{fetch}` is used to retrieve files from the local file system, http, or ftp and display the contents. -- If the file name begins with `http://`, the web site page will be +## Attributes +| Attribute | Required | Description | +|-----------|----------|------------------------------------------------------| +| file | Yes | The file, http or ftp site to fetch | +| assign | No | The template variable the output will be assigned to | + +- If the file name begins with `http://`, the website page will be fetched and displayed. > **Note** @@ -20,40 +25,37 @@ ftp and display the contents. > **Note** > - > If security is enabled and you are fetching a file from the local + > If security is enabled, and you are fetching a file from the local > file system, `{fetch}` will only allow files from within the > `$secure_dir` path of the security policy. See the - > [Security](#advanced.features.security) section for details. + > [Security](../../programmers/advanced-features/advanced-features-security.md) section for details. - If the `assign` attribute is set, the output of the `{fetch}` function will be assigned to this template variable instead of being output to the template. - Attribute Name Type Required Default Description - ---------------- -------- ---------- --------- ------------------------------------------------------ - file string Yes *n/a* The file, http or ftp site to fetch - assign string No *n/a* The template variable the output will be assigned to +## Examples +```smarty +{* include some javascript in your template *} +{fetch file='/export/httpd/www.example.com/docs/navbar.js'} - {* include some javascript in your template *} - {fetch file='/export/httpd/www.example.com/docs/navbar.js'} +{* embed some weather text in your template from another web site *} +{fetch file='http://www.myweather.com/68502/'} - {* embed some weather text in your template from another web site *} - {fetch file='http://www.myweather.com/68502/'} - - {* fetch a news headline file via ftp *} - {fetch file='ftp://user:password@ftp.example.com/path/to/currentheadlines.txt'} - {* as above but with variables *} - {fetch file="ftp://`$user`:`$password`@`$server`/`$path`"} - - {* assign the fetched contents to a template variable *} - {fetch file='http://www.myweather.com/68502/' assign='weather'} - {if $weather ne ''} -
{$weather}
- {/if} +{* fetch a news headline file via ftp *} +{fetch file='ftp://user:password@ftp.example.com/path/to/currentheadlines.txt'} +{* as above but with variables *} +{fetch file="ftp://`$user`:`$password`@`$server`/`$path`"} +{* assign the fetched contents to a template variable *} +{fetch file='http://www.myweather.com/68502/' assign='weather'} +{if $weather ne ''} +
{$weather}
+{/if} +``` -See also [`{capture}`](#language.function.capture), -[`{eval}`](#language.function.eval), -[`{assign}`](#language.function.assign) and [`fetch()`](#api.fetch). +See also [`{capture}`](../language-builtin-functions/language-function-capture.md), +[`{eval}`](language-function-eval.md), +[`{assign}`](../language-builtin-functions/language-function-assign.md) and [`fetch()`](../../programmers/api-functions/api-fetch.md). diff --git a/docs/designers/language-custom-functions/language-function-html-checkboxes.md b/docs/designers/language-custom-functions/language-function-html-checkboxes.md index 23af713b..3ab36096 100644 --- a/docs/designers/language-custom-functions/language-function-html-checkboxes.md +++ b/docs/designers/language-custom-functions/language-function-html-checkboxes.md @@ -1,113 +1,102 @@ -{html\_checkboxes} {#language.function.html.checkboxes} -================== +# {html_checkboxes} -`{html_checkboxes}` is a [custom function](#language.custom.functions) +`{html_checkboxes}` is a [custom function](index.md) that creates an html checkbox group with provided data. It takes care of which item(s) are selected by default as well. - Attribute Name Type Required Default Description - ---------------- ------------------- ------------------------------------- ------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - name string No *checkbox* Name of checkbox list - values array Yes, unless using options attribute *n/a* An array of values for checkbox buttons - output array Yes, unless using options attribute *n/a* An array of output for checkbox buttons - selected string/array No *empty* The selected checkbox element(s) - options associative array Yes, unless using values and output *n/a* An associative array of values and output - separator string No *empty* String of text to separate each checkbox item - assign string No *empty* Assign checkbox tags to an array instead of output - labels boolean No *TRUE* Add \-tags to the output - label\_ids boolean No *FALSE* Add id-attributes to \ and \ to the output - escape boolean No *TRUE* Escape the output / content (values are always escaped) - strict boolean No *FALSE* Will make the \"extra\" attributes *disabled* and *readonly* only be set, if they were supplied with either boolean *TRUE* or string *\"disabled\"* and *\"readonly\"* respectively +## Attributes -- Required attributes are `values` and `output`, unless you use - `options` instead. +| Attribute Name | Required | Description | +|----------------|-------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| name | No | Name of checkbox list (defaults to 'checkbox') | +| values | Yes, unless using options attribute | An array of values for checkbox buttons | +| output | Yes, unless using options attribute | An array of output for checkbox buttons | +| selected | No | The selected checkbox element(s) as a string or array | +| options | Yes, unless using values and output | An associative array of values and output | +| separator | No | String of text to separate each checkbox item | +| assign | No | Assign checkbox tags to an array instead of output | +| labels | No | Add -tags to the output (defaults to true) | +| label\_ids | No | Add id-attributes to and to the output (defaults to false) | +| escape | No | Escape the output / content (values are always escaped) (defaults to true) | +| strict | No | Will make the "extra" attributes *disabled* and *readonly* only be set, if they were supplied with either boolean *TRUE* or string *"disabled"* and *"readonly"* respectively (defaults to false) | + +- Required attributes are `values` and `output`, unless you use `options` instead. - All output is XHTML compliant. - All parameters that are not in the list above are printed as - name/value-pairs inside each of the created \-tags. + name/value-pairs inside each of the created -tags. - +## Examples +```php +assign('cust_ids', array(1000,1001,1002,1003)); - $smarty->assign('cust_names', array( - 'Joe Schmoe', - 'Jack Smith', - 'Jane Johnson', - 'Charlie Brown') - ); - $smarty->assign('customer_id', 1001); - - ?> - - +$smarty->assign('cust_ids', array(1000,1001,1002,1003)); +$smarty->assign('cust_names', array( + 'Joe Schmoe', + 'Jack Smith', + 'Jane Johnson', + 'Charlie Brown') + ); +$smarty->assign('customer_id', 1001); +``` where template is - - {html_checkboxes name='id' values=$cust_ids output=$cust_names - selected=$customer_id separator='
'} - - +```smarty +{html_checkboxes name='id' values=$cust_ids output=$cust_names selected=$customer_id separator='
'} +``` or where PHP code is: +```php +assign('cust_checkboxes', array( - 1000 => 'Joe Schmoe', - 1001 => 'Jack Smith', - 1002 => 'Jane Johnson', - 1003 => 'Charlie Brown') - ); - $smarty->assign('customer_id', 1001); - - ?> - - +$smarty->assign( + 'cust_checkboxes', + [ + 1000 => 'Joe Schmoe', + 1001 => 'Jack Smith', + 1002 => 'Jane Johnson', + 1003 => 'Charlie Brown', + ] +); +$smarty->assign('customer_id', 1001); +``` and the template is - - {html_checkboxes name='id' options=$cust_checkboxes - selected=$customer_id separator='
'} - - +```smarty +{html_checkboxes name='id' options=$cust_checkboxes selected=$customer_id separator='
'} +``` both examples will output: - -
- -
-
-
- +```html +
+ +
+
+
+``` +```php +assign('contact_types',$db->getAssoc($sql)); - $sql = 'select type_id, types from contact_types order by type'; - $smarty->assign('contact_types',$db->getAssoc($sql)); - - $sql = 'select contact_id, contact_type_id, contact ' - .'from contacts where contact_id=12'; - $smarty->assign('contact',$db->getRow($sql)); - - ?> - - +$sql = 'select contact_id, contact_type_id, contact ' + .'from contacts where contact_id=12'; +$smarty->assign('contact',$db->getRow($sql)); +``` The results of the database queries above would be output with. +```smarty +{html_checkboxes name='contact_type_id' options=$contact_types selected=$contact.contact_type_id separator='
'} +``` - {html_checkboxes name='contact_type_id' options=$contact_types - selected=$contact.contact_type_id separator='
'} - -See also [`{html_radios}`](#language.function.html.radios) and -[`{html_options}`](#language.function.html.options) +See also [`{html_radios}`](./language-function-html-radios.md) and +[`{html_options}`](./language-function-html-options.md) diff --git a/docs/designers/language-custom-functions/language-function-html-image.md b/docs/designers/language-custom-functions/language-function-html-image.md index e21f2a12..7ecde265 100644 --- a/docs/designers/language-custom-functions/language-function-html-image.md +++ b/docs/designers/language-custom-functions/language-function-html-image.md @@ -1,25 +1,26 @@ -{html\_image} {#language.function.html.image} -============= +# {html_image} -`{html_image}` is a [custom function](#language.custom.functions) that +`{html_image}` is a [custom function](index.md) that generates an HTML `` tag. The `height` and `width` are automatically calculated from the image file if they are not supplied. - Attribute Name Type Required Default Description - ---------------- -------- ---------- ----------------------- --------------------------------------- - file string Yes *n/a* name/path to image - height string No *actual image height* Height to display image - width string No *actual image width* Width to display image - basedir string no *web server doc root* Directory to base relative paths from - alt string no *""* Alternative description of the image - href string no *n/a* href value to link the image to - path\_prefix string no *n/a* Prefix for output path +## Attributes + +| Attribute Name | Required | Description | +|----------------|----------|-------------------------------------------------------------------------| +| file | Yes | name/path to image | +| height | No | Height to display image (defaults to actual image height) | +| width | No | Width to display image (defaults to actual image width) | +| basedir | no | Directory to base relative paths from (defaults to web server doc root) | +| alt | no | Alternative description of the image | +| href | no | href value to link the image to | +| path\_prefix | no | Prefix for output path | - `basedir` is the base directory that relative image paths are based - from. If not given, the web server\'s document root + from. If not given, the web server's document root `$_ENV['DOCUMENT_ROOT']` is used as the base. If security is enabled, then the image must be located in the `$secure_dir` path of - the security policy. See the [Security](#advanced.features.security) + the security policy. See the [Security](../../programmers/advanced-features/advanced-features-security.md) section for details. - `href` is the href value to link the image to. If link is supplied, @@ -35,22 +36,23 @@ automatically calculated from the image file if they are not supplied. > **Note** > > `{html_image}` requires a hit to the disk to read the image and -> calculate the height and width. If you don\'t use template -> [caching](#caching), it is generally better to avoid `{html_image}` +> calculate the height and width. If you don't use template +> [caching](../../programmers/caching.md), it is generally better to avoid `{html_image}` > and leave image tags static for optimal performance. +## Examples - {html_image file='pumpkin.jpg'} - {html_image file='/path/from/docroot/pumpkin.jpg'} - {html_image file='../path/relative/to/currdir/pumpkin.jpg'} - - +```smarty +{html_image file='pumpkin.jpg'} +{html_image file='/path/from/docroot/pumpkin.jpg'} +{html_image file='../path/relative/to/currdir/pumpkin.jpg'} +``` Example output of the above template would be: - - - - - +```html + + + +``` diff --git a/docs/designers/language-custom-functions/language-function-html-options.md b/docs/designers/language-custom-functions/language-function-html-options.md index 9c9a00a1..a63ccc56 100644 --- a/docs/designers/language-custom-functions/language-function-html-options.md +++ b/docs/designers/language-custom-functions/language-function-html-options.md @@ -1,18 +1,19 @@ -{html\_options} {#language.function.html.options} -=============== +# {html_options} -`{html_options}` is a [custom function](#language.custom.functions) that +`{html_options}` is a [custom function](index.md) that creates the html `` tags. - - {html_options name=foo options=$myOptions selected=$mySelect} - - +```smarty +{html_options name=foo options=$myOptions selected=$mySelect} +``` Output of the above example would be: - - - + +``` - - assign('cust_ids', array(56,92,13)); - $smarty->assign('cust_names', array( - 'Joe Schmoe', - 'Jane Johnson', - 'Charlie Brown')); - $smarty->assign('customer_id', 92); - ?> - - +```php +assign('cust_ids', [56,92,13]); +$smarty->assign('cust_names', [ + 'Joe Schmoe', + 'Jane Johnson', + 'Charlie Brown']); +$smarty->assign('customer_id', 92); +``` The above arrays would be output with the following template (note the use of the php [`count()`](https://www.php.net/function.count) function as a modifier to set the select size). - - - - +```smarty + +``` The above example would output: +```html + +``` - +```php +assign('contact_types',$db->getAssoc($sql)); - +$sql = 'select contact_id, name, email, contact_type_id + from contacts where contact_id='.$contact_id; +$smarty->assign('contact',$db->getRow($sql)); - - assign('contact_types',$db->getAssoc($sql)); - - $sql = 'select contact_id, name, email, contact_type_id - from contacts where contact_id='.$contact_id; - $smarty->assign('contact',$db->getRow($sql)); - - ?> +``` Where a template could be as follows. Note the use of the -[`truncate`](#language.modifier.truncate) modifier. +[`truncate`](../language-modifiers/language-modifier-truncate.md) modifier. +```smarty + +``` - - - - - - 'Golf', 9 => 'Cricket',7 => 'Swim'); - $arr['Rest'] = array(3 => 'Sauna',1 => 'Massage'); - $smarty->assign('lookups', $arr); - $smarty->assign('fav', 7); - ?> - - +```php + 'Golf', 9 => 'Cricket',7 => 'Swim'); +$arr['Rest'] = array(3 => 'Sauna',1 => 'Massage'); +$smarty->assign('lookups', $arr); +$smarty->assign('fav', 7); +``` The script above and the following template - - {html_options name=foo options=$lookups selected=$fav} - - +```smarty +{html_options name=foo options=$lookups selected=$fav} +``` would output: - - - - - + + + - - + + - + +``` -See also [`{html_checkboxes}`](#language.function.html.checkboxes) and -[`{html_radios}`](#language.function.html.radios) +See also [`{html_checkboxes}`](./language-function-html-checkboxes.md) and +[`{html_radios}`](./language-function-html-radios.md) diff --git a/docs/designers/language-custom-functions/language-function-html-radios.md b/docs/designers/language-custom-functions/language-function-html-radios.md index 992adaea..af8ecda6 100644 --- a/docs/designers/language-custom-functions/language-function-html-radios.md +++ b/docs/designers/language-custom-functions/language-function-html-radios.md @@ -1,23 +1,24 @@ -{html\_radios} {#language.function.html.radios} -============== +# {html_radios} -`{html_radios}` is a [custom function](#language.custom.functions) that -creates a HTML radio button group. It also takes care of which item is +`{html_radios}` is a [custom function](index.md) that +creates an HTML radio button group. It also takes care of which item is selected by default as well. - Attribute Name Type Required Default Description - ---------------- ------------------- ------------------------------------- --------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - name string No *radio* Name of radio list - values array Yes, unless using options attribute *n/a* An array of values for radio buttons - output array Yes, unless using options attribute *n/a* An array of output for radio buttons - selected string No *empty* The selected radio element - options associative array Yes, unless using values and output *n/a* An associative array of values and output - separator string No *empty* String of text to separate each radio item - assign string No *empty* Assign radio tags to an array instead of output - labels boolean No *TRUE* Add \-tags to the output - label\_ids boolean No *FALSE* Add id-attributes to \ and \ to the output - escape boolean No *TRUE* Escape the output / content (values are always escaped) - strict boolean No *FALSE* Will make the \"extra\" attributes *disabled* and *readonly* only be set, if they were supplied with either boolean *TRUE* or string *\"disabled\"* and *\"readonly\"* respectively +## Attributes + +| Attribute Name | Required | Description | +|----------------|-------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| name | No | Name of radio list | +| values | Yes, unless using options attribute | An array of values for radio buttons | +| output | Yes, unless using options attribute | An array of output for radio buttons | +| selected | No | The selected radio element | +| options | Yes, unless using values and output | An associative array of values and output | +| separator | No | String of text to separate each radio item | +| assign | No | Assign radio tags to an array instead of output | +| labels | No | Add