Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 32 additions & 13 deletions docs/channels/entries.md
Original file line number Diff line number Diff line change
Expand Up @@ -1261,33 +1261,52 @@ Handy conditional for displaying markup or content based on whether or not the e

### `{if no_results}`

{if no_results} content {/if}
{if no_results} There are no entries available {/if}

You may use this conditional for displaying a message in the case when no entries are returned. The contents inside of the conditional will be displayed in cases where there are no results returned for the tag.
You will use this conditional frequently to display alternative content when no entries are returned. The content inside the conditional will be displayed when no results are returned for the tag with the given parameters.

{if no_results} <p>There are no entries available.</p> {/if}

Further, you may specify that another Template be shown in a case when there are no results. In order to do that, you must use the redirect=variable
Further, you may specify that another page should be shown when there are no results. In order to do that, you use the [redirect= variable](templates/globals/single-variables.md#redirect).

{if no_results} {redirect="channel/noresult"} {/if}

Lastly, if you want to simply display your 404 page (with 404 headers) when no entries are returned, simply use "404" as the template name.
Lastly, if you want to simply display your [custom Not Found page](general/404pages.md#404-pages) (with proper 404 headers) when no entries are returned, simply use "404" as the template name.

{if no_results} {redirect="404"} {/if}

NOTE: **Note:** If you have several nested tags, each one would need to include a `{if no_results}` pair to be parsed correctly.
NOTE: **Note:** If you have nested tag loops that each check for no results, the outer one will "claim" and process the first (and only the first) `{if no_results}` block before the inner tag loop has a chance, unless the conditional is prefixed (which not every tag provides).

For instance, if you have a Grid field with an `{if no_results}` block, the parent `{exp:channel:entries}` tag pair would need to include an `{if no_results}` block as well:
For instance, if you have a Relationship field with an `{if no_results}` block, and the parent `{exp:channel:entries}` tag pair needs to include an `{if no_results}` block as well, you should use this format:
```
{exp:channel:entries channel="blog"}
{my_relationship_field}
{if my_relationship_field:no_results} Relationship is empty {/if}
{my_relationship_field:title}
{/my_relationship_field}
{if no_results} No entries {/if}
{/exp:channel:entries}
```

NOTE: **Note:** To test whether a Grid or File Grid field is empty, use [:total_rows](fieldtypes/grid.md#total_rows-1). For a Members field, use [:total_rows](fieldtypes/member.md#total_rows). For a Fluid field, use [:total_fields](fieldtypes/fluid.md#total_fields).

```
{exp:channel:entries channel="blog"}
{if my_grid_field:total_rows == 0} Grid is empty {/if}
{my_grid_field}
{if no_results} Grid is empty {/if}
{my_grid_field:text}
{/my_grid_field}
{if my_fluid_field:total_fields == 0} Fluid field is empty {/if}
{my_fluid_field}
{my_fluid_field:text}
{content}
{/my_fluid_field:text}
{/my_fluid_field}
{if no_results} No entries {/if}
{/exp:channel:entries}
```

NOTE: **Note:** It is invalid syntax to use `{if:else}` with the `{if no_results}` conditional. Results (no pun intended) may be unpredictable.


### `{if not_category_request}`

{if not_category_request} content {/if}
Expand Down Expand Up @@ -1326,15 +1345,15 @@ You may test whether an entry is set to be "sticky". You may also test whether i

Variable pairs contain an opening and closing tag as well as content in between. Example:

{date_heading} <h1>{entry_date format="%Y %m %d"}</h1> {/date_heading}
{date_heading} <h1>{entry_date format="%Y %m %d"}</h1> {/date_heading}

The reason variable pairs have an opening and closing pair is because the information between the pairs can be shown or not shown if the criteria for each tag is met.

In the case of the "date_heading" pair, for example, it only appears at a certain interval that you set (hourly, daily, weekly, monthly, etc.). By using a pair of variables, you can put HTML formatting between them that only gets shown when the interval is met. Otherwise, the chunk is not displayed.

### `{date_footer}`

{date_footer display="daily"} <p>That's all from today!</p> {/date_footer}
{date_footer display="daily"} <p>That's all from today!</p> {/date_footer}

The date footer can be used to show a footer at certain intervals. The interval can be set to show hourly, daily, weekly, monthly, or yearly. An optional "display" parameter can be used to set the display interval:

Expand All @@ -1354,7 +1373,7 @@ NOTE: **Note:** You can use as many date_footers as you want in the same tag. Th

### `{date_heading}`

{date_heading} <h1>{entry_date format="%Y %m %d"}</h1> {/date_heading}
{date_heading} <h1>{entry_date format="%Y %m %d"}</h1> {/date_heading}

The date heading can be used to show a heading at certain intervals. The interval can be set to show hourly, daily, weekly, monthly, or yearly.

Expand Down Expand Up @@ -1493,7 +1512,7 @@ This variable will be replaced by a URL to the specified Template Group/Template

If you want the category links to point to your site index instead of a particular template group/template, you can use SITE_INDEX instead:

{categories} <a href="{path='SITE_INDEX'}">{category_name}</a> {/categories}
{categories} <a href="{path='SITE_INDEX'}">{category_name}</a> {/categories}

#### Custom Category Fields

Expand Down
87 changes: 48 additions & 39 deletions docs/cli/usage.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,35 @@
# CLI Usage

Commands can be called in the terminal of your choice in the format of:
Commands to control and report on many of the core operations of ExpressionEngine can be issued via the terminal of your choice in the format of:

`$ php system/ee/eecli.php hello`
`$ php system/ee/eecli.php version`

This will call `eecli` with a command of `hello`. This is the Hello World of ExpressionEngine commands, and will display:
Assuming you're in the directory that contains the system folder, this will have `php` use ExpressionEngine's Command Line Interface tool, `eecli`, to run the `version` command.

`Hello world`

Commands can also request confirmation:
This is the most basic of ExpressionEngine commands, and will display something similar to:

```
$ php system/ee/eecli.php hello -c

Hello world
Are you liking these questions? (yes/no) [no]
yes
That's good to hear!
ExpressionEngine Version: 7.5.25
Build: 20260623
PHP Version: 8.2.32
```
You may also be able to use the CLI with PHP implied. Command line usage is a broad topic, and the details of your system may vary.

Commands are also able to take interaction:
`$ ./system/ee/eecli.php version`

```
$ php system/ee/eecli.php hello -i
Commands can be interactive and ask you questions as they run. For example, this command will walk you through setting up the files and framework for a custom EE add-on:

Hello world
What's your name? Andy
Pleasure to meet you, Andy!
```
$ php system/ee/eecli.php make:addon

WARN: **Important:** The CLI is available to every user that has SSH or terminal access to your site's webserver. It does not handle authorization inside ExpressionEngine and is relying on your server's authorization method instead.

If you want to disable CLI globally, it can be done by setting `cli_enabled` [configuration override](general/system-configuration-overrides.md#cli_enabled) to `n`.
Let's build your add-on!
What is the name of your add-on?
etc.
```

## List All Commands

To view a list of all available commands, you may use the list command:
To view a list of all available commands, use the list command:

`php system/ee/eecli.php list`

Expand All @@ -44,41 +38,56 @@ This will return a basic list of all available system and user-generated command
```
$ php system/ee/eecli.php list

------------------------------------------------------------------
| Command | Description |
------------------------------------------------------------------
| hello | The most basic of commands |
| list | Lists all available commands |
| update | Updates ExpressionEngine |
| addons:install | Installs add-on and all its components |
| backup:database | Backup the database |
| channels:list | Lists all channels in the system |
| cache:clear | Clears all ExpressionEngine caches |
| config:config | Updates config values in config.php file |
...
```

## Command Line Security

WARN: **Important:** Unless disabled, the CLI is enabled by default and available to any person who has SSH or terminal access to your site's web server and who can run PHP scripts. The CLI does not handle authorization using ExpressionEngine's member system. It relies entirely on your server's authorization methods and simply treats a CLI user as a generic superuser.

EE is available via the CLI even when EE is set to offline mode -- this mirrors a superadmin's access permissions in the control panel and makes it possible to perform maintenance and upgrades when a site is offline.

If you want to disable CLI globally, this can be done by setting `cli_enabled` [configuration override](general/system-configuration-overrides.md#cli_enabled) to `n` or by running the following command:

`$ php eecli.php config:config -c cli_enabled -v n`

(This would be a poor choice of command to use to test the CLI.)

You can also enable and disable the CLI from [Security & Privacy Settings](control-panel/settings/security-privacy.md#enable-the-command-line-interface) in the Control Panel.

## Get Help

You can get help information on any command by using the `--help` or `-h` parameter when running the command.
You can get help information for any command by using the `--help` or `-h` parameter

```
$ php system/ee/eecli.php hello -h
$ php system/ee/eecli.php config:config -h

SUMMARY
Hello World -- This is a sample command used to test the CLI
Update Config Values -- Gives the ability to update config values

USAGE
Hello World php eecli.php hello
Update Config Values php eecli.php config:config -c is_system_on -v n

DESCRIPTION
The most basic of commands
Updates config values in config.php file

OPTIONS
--verbose
-v
Hello world, but longer

--interactive
-i
Let's interact!
--config-variable=<value>
-c <value>
The config item to modify

--confirm
-c
Test the confirmation
--value=<value>
-v <value>
The value to set the config item to
```

Additional details may also be available here in the ExpressionEngine Docs or on the add-on developer's website.
12 changes: 8 additions & 4 deletions docs/control-panel/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,16 @@ Saves the entry and returns the [Entry Manager](control-panel/entry-manager.md)

### Preview

A live preview of the entry is available if the relevant channel's [Preview URL](control-panel/channels.md#settings-tab) is set **or** the [Pages Module](add-ons/pages.md) or [Structure](add-ons/structure/overview.md) is installed and configured with a URI and template.
A dynamic, live preview of an entry can be simultaneously displayed while you edit. The preview button opens a split browser window that displays a live preview of the entry you are editing.

If neither is set, the preview button will have an exclamation mark (!) and will link to channel preferences page where Preview URL can be set.
The template used to display the preview is based on configured Pages/Structure fields if the [Pages Module](add-ons/pages.md) or [Structure](add-ons/structure/overview.md) is installed and configured with a URI and template -- or the relevant channel's [Preview URL](control-panel/channels.md#settings-tab) setting otherwise.

The preview will open a split screen that allows a live preview of edits. The template used to display the preview is based on configured Pages/Structure fields if set and the channel preview URL otherwise.
If neither of these is set, the preview button will have an exclamation mark (!) and it will link to channel preferences page where Preview URL can be set.

When the preview is triggered, it is being displayed side-by-side with edit screen. The size of preview container can be adjusted with mouse dragging its border. The preview is dynamically being updated as you change the fields.
NOTE: **Note:** Commonly, the channel preview template is set to be the same template that the live entry, but in certain cases it's useful to use a different, customized preview template. Pages/Structure do not have this flexibility.

NOTE: **Note:** Use the [`{is_live_preview_request}`](globals/single-variables.md#is_live_preview_request) conditional to only display certain content or to modify certain attributes only when previewing an entry. For example, `{if is_live_preview_request}status="open|closed" show_future_entries="yes"{/if}` will preview an entry that is closed or set to publish in the future.

Once the preview is triggered, it will continue to be displayed side-by-side with edit screen until you close it. The size of preview window can be adjusted with the mouse by dragging its border. The preview contents will dynamically update as you change the contents of any field.

Live Preview does require the [HTTP Authorization Header be enabled](troubleshooting/error-messages.md#http-authorization-header-missing).
6 changes: 4 additions & 2 deletions docs/fieldtypes/fluid.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,12 @@ A fluid field can handle the output of all of those fields, as many as they add,

## Fluid Field Notes

- The `{if no_results}` tag is not valid within the prefixed variable pairs.
- Count variables available in some variable pairs (grid and relationship) restart at 1 each loop. So the total_results for a relationship tag pair would refer to the total number of relationships for that specific instance of the relationship field.
- All native fields aside from a Fluid field can be included in a Fluid field.

- The `{if no_results}` conditional tag is not valid for use in controlling the display of fluid fields. To test if the overall field has any content, use [:total_fields](/fieldtypes/fluid.md#total_fields) outside of the fluid field loop: `{if my_fluid_field:total_fields == 0} Fluid field is empty {/if}`

- Count variables available in some variable pairs (grid and relationship) restart at 1 each loop. So the total_results for a relationship tag pair would refer to the total number of relationships for that specific instance of the relationship field.

## Field Examples

### Checkbox and Multi Select Fields
Expand Down
Loading
Loading