├── .gitignore ├── .vuepress ├── config-en.js ├── config-ja.js ├── config.js └── public │ └── icon.svg ├── README.md ├── assets-fields.md ├── assets.md ├── categories-fields.md ├── categories.md ├── changes-in-craft-3.md ├── checkboxes-fields.md ├── coc.md ├── color-fields.md ├── config ├── README.md ├── app.md ├── config-settings.md ├── db-settings.md ├── environments.md └── php-constants.md ├── crowdin.yml ├── date-time-fields.md ├── dev ├── README.md ├── eager-loading-elements.md ├── element-queries │ ├── README.md │ ├── asset-queries.md │ ├── category-queries.md │ ├── entry-queries.md │ ├── global-set-queries.md │ ├── matrix-block-queries.md │ ├── tag-queries.md │ └── user-queries.md ├── elements.md ├── elements │ ├── asset.md │ ├── category.md │ ├── entry.md │ ├── global-set.md │ ├── matrix-block.md │ ├── tag.md │ └── user.md ├── examples │ ├── README.md │ ├── atom-feed.md │ ├── entry-form.md │ ├── forgot-password-form.md │ ├── integrating-disqus.md │ ├── login-form.md │ ├── rss-feed.md │ ├── search-form.md │ ├── set-password-form.md │ ├── user-profile-form.md │ └── user-registration-form.md ├── filters.md ├── functions.md ├── global-variables.md ├── headless.md ├── tags.md ├── tests.md └── twig-primer.md ├── directory-structure.md ├── dropdown-fields.md ├── email-fields.md ├── entries-fields.md ├── extend ├── README.md ├── asset-bundles.md ├── changelogs-and-updates.md ├── coding-guidelines.md ├── commands.md ├── controllers.md ├── cp-section.md ├── cp-templates.md ├── element-action-types.md ├── element-exporter-types.md ├── element-types.md ├── environmental-settings.md ├── extending-system-components.md ├── extending-twig.md ├── field-types.md ├── migrations.md ├── module-guide.md ├── plugin-editions.md ├── plugin-guide.md ├── plugin-settings.md ├── plugin-store.md ├── project-config.md ├── services.md ├── soft-deletes.md ├── template-hooks.md ├── template-roots.md ├── translation-categories.md ├── updating-plugins.md ├── user-permissions.md ├── utility-types.md ├── volume-types.md └── widget-types.md ├── fields.md ├── fr ├── README.md ├── assets-fields.md ├── assets.md ├── categories-fields.md ├── categories.md ├── changes-in-craft-3.md ├── checkboxes-fields.md ├── coc.md ├── color-fields.md ├── config │ ├── README.md │ ├── app.md │ ├── config-settings.md │ ├── db-settings.md │ ├── environments.md │ └── php-constants.md ├── date-time-fields.md ├── dev │ ├── README.md │ ├── eager-loading-elements.md │ ├── element-queries │ │ ├── README.md │ │ ├── asset-queries.md │ │ ├── category-queries.md │ │ ├── entry-queries.md │ │ ├── global-set-queries.md │ │ ├── matrix-block-queries.md │ │ ├── tag-queries.md │ │ └── user-queries.md │ ├── elements.md │ ├── elements │ │ ├── asset.md │ │ ├── category.md │ │ ├── entry.md │ │ ├── global-set.md │ │ ├── matrix-block.md │ │ ├── tag.md │ │ └── user.md │ ├── examples │ │ ├── README.md │ │ ├── atom-feed.md │ │ ├── entry-form.md │ │ ├── forgot-password-form.md │ │ ├── integrating-disqus.md │ │ ├── login-form.md │ │ ├── rss-feed.md │ │ ├── search-form.md │ │ ├── set-password-form.md │ │ ├── user-profile-form.md │ │ └── user-registration-form.md │ ├── filters.md │ ├── functions.md │ ├── global-variables.md │ ├── headless.md │ ├── tags.md │ ├── tags │ │ ├── cache.md │ │ ├── css.md │ │ ├── dd.md │ │ ├── exit.md │ │ ├── header.md │ │ ├── hook.md │ │ ├── js.md │ │ ├── nav.md │ │ ├── paginate.md │ │ ├── redirect.md │ │ ├── requirelogin.md │ │ ├── requirepermission.md │ │ └── switch.md │ ├── tests.md │ └── twig-primer.md ├── directory-structure.md ├── dropdown-fields.md ├── email-fields.md ├── entries-fields.md ├── extend │ ├── README.md │ ├── asset-bundles.md │ ├── changelogs-and-updates.md │ ├── coding-guidelines.md │ ├── cp-section.md │ ├── cp-templates.md │ ├── element-action-types.md │ ├── element-types.md │ ├── environmental-settings.md │ ├── extending-twig.md │ ├── field-types.md │ ├── migrations.md │ ├── module-guide.md │ ├── plugin-editions.md │ ├── plugin-guide.md │ ├── plugin-settings.md │ ├── plugin-store.md │ ├── project-config.md │ ├── services.md │ ├── soft-deletes.md │ ├── template-hooks.md │ ├── template-roots.md │ ├── translation-categories.md │ ├── updating-plugins.md │ ├── user-permissions.md │ ├── utility-types.md │ ├── volume-types.md │ └── widget-types.md ├── fields.md ├── gc.md ├── globals.md ├── graphql.md ├── image-transforms.md ├── images │ ├── categories-category-index.png │ ├── categories-edit-popup.png │ ├── cli-update-info.png │ ├── cli-update-plugin.png │ ├── fields-field-settings.png │ ├── globals-multisite-nav.png │ ├── graphiql.png │ ├── installation-command-line.png │ ├── installation-step-0.png │ ├── installation-step-1.png │ ├── installation-step-2.png │ ├── installation-step-3.png │ ├── installation-step-4.png │ ├── installation-step-5.png │ ├── plugin-index.png │ ├── plugin-store-plugin.png │ ├── plugin-store.png │ ├── plugin-update.png │ ├── preview-targets.png │ ├── routing-creating-new-route.png │ ├── save-component--class.png │ ├── save-component--interface.png │ ├── searching-search-bar.png │ ├── sections-and-entries-entry-types.png │ ├── share-with-targets.png │ ├── users-client-user.png │ └── volume-base-url-setting.jpg ├── installation.md ├── lightswitch-fields.md ├── localization.md ├── matrix-fields.md ├── multi-select-fields.md ├── number-fields.md ├── plain-text-fields.md ├── planning-your-craft-site.md ├── plugins.md ├── project-config.md ├── radio-buttons-fields.md ├── reference-tags.md ├── relations.md ├── requirements.md ├── routing.md ├── searching.md ├── sections-and-entries.md ├── sites.md ├── static-translations.md ├── table-fields.md ├── tags-fields.md ├── tags.md ├── testing │ ├── README.md │ ├── ci.md │ ├── codeception.md │ ├── framework │ │ ├── assertion-helpers.md │ │ ├── config-options.md │ │ ├── full-mock.md │ │ ├── mocking.md │ │ └── support-classes.md │ ├── testing-craft │ │ ├── console.md │ │ ├── events.md │ │ ├── fixtures.md │ │ ├── getting-started.md │ │ ├── plugins-and-modules.md │ │ ├── queue.md │ │ └── testing-tips.md │ └── testing.md ├── updating.md ├── upgrade.md ├── url-fields.md ├── users-fields.md └── users.md ├── gc.md ├── globals.md ├── graphql.md ├── image-transforms.md ├── images ├── categories-category-index.png ├── categories-edit-popup.png ├── cli-update-info.png ├── cli-update-plugin.png ├── exporters-custom.png ├── exporters-default.png ├── fields-field-settings.png ├── globals-multisite-nav.png ├── graphiql.png ├── installation-command-line.png ├── installation-step-0.png ├── installation-step-1.png ├── installation-step-2.png ├── installation-step-3.png ├── installation-step-4.png ├── installation-step-5.png ├── plugin-index.png ├── plugin-store-plugin.png ├── plugin-store.png ├── plugin-update.png ├── preview-targets.png ├── routing-creating-new-route.png ├── save-component--class.png ├── save-component--interface.png ├── searching-search-bar.png ├── sections-and-entries-entry-types.png ├── share-with-targets.png ├── users-client-user.png └── volume-base-url-setting.jpg ├── installation.md ├── ja ├── README.md ├── assets-fields.md ├── assets.md ├── categories-fields.md ├── categories.md ├── changes-in-craft-3.md ├── checkboxes-fields.md ├── coc.md ├── color-fields.md ├── config │ ├── README.md │ ├── app.md │ ├── config-settings.md │ ├── db-settings.md │ ├── environments.md │ └── php-constants.md ├── date-time-fields.md ├── dev │ ├── README.md │ ├── eager-loading-elements.md │ ├── element-queries │ │ ├── README.md │ │ ├── asset-queries.md │ │ ├── category-queries.md │ │ ├── entry-queries.md │ │ ├── global-set-queries.md │ │ ├── matrix-block-queries.md │ │ ├── tag-queries.md │ │ └── user-queries.md │ ├── elements.md │ ├── elements │ │ ├── asset.md │ │ ├── category.md │ │ ├── entry.md │ │ ├── global-set.md │ │ ├── matrix-block.md │ │ ├── tag.md │ │ └── user.md │ ├── examples │ │ ├── README.md │ │ ├── atom-feed.md │ │ ├── entry-form.md │ │ ├── forgot-password-form.md │ │ ├── integrating-disqus.md │ │ ├── login-form.md │ │ ├── rss-feed.md │ │ ├── search-form.md │ │ ├── set-password-form.md │ │ ├── user-profile-form.md │ │ └── user-registration-form.md │ ├── filters.md │ ├── functions.md │ ├── global-variables.md │ ├── headless.md │ ├── tags.md │ ├── tags │ │ ├── cache.md │ │ ├── css.md │ │ ├── dd.md │ │ ├── exit.md │ │ ├── header.md │ │ ├── hook.md │ │ ├── js.md │ │ ├── nav.md │ │ ├── paginate.md │ │ ├── redirect.md │ │ ├── requirelogin.md │ │ ├── requirepermission.md │ │ └── switch.md │ ├── tests.md │ └── twig-primer.md ├── directory-structure.md ├── dropdown-fields.md ├── email-fields.md ├── entries-fields.md ├── extend │ ├── README.md │ ├── asset-bundles.md │ ├── changelogs-and-updates.md │ ├── coding-guidelines.md │ ├── cp-section.md │ ├── cp-templates.md │ ├── element-action-types.md │ ├── element-types.md │ ├── environmental-settings.md │ ├── extending-twig.md │ ├── field-types.md │ ├── migrations.md │ ├── module-guide.md │ ├── plugin-editions.md │ ├── plugin-guide.md │ ├── plugin-settings.md │ ├── plugin-store.md │ ├── project-config.md │ ├── services.md │ ├── soft-deletes.md │ ├── template-hooks.md │ ├── template-roots.md │ ├── translation-categories.md │ ├── updating-plugins.md │ ├── user-permissions.md │ ├── utility-types.md │ ├── volume-types.md │ └── widget-types.md ├── fields.md ├── gc.md ├── globals.md ├── graphql.md ├── image-transforms.md ├── images │ ├── categories-category-index.png │ ├── categories-edit-popup.png │ ├── cli-update-info.png │ ├── cli-update-plugin.png │ ├── fields-field-settings.png │ ├── globals-multisite-nav.png │ ├── graphiql.png │ ├── installation-command-line.png │ ├── installation-step-0.png │ ├── installation-step-1.png │ ├── installation-step-2.png │ ├── installation-step-3.png │ ├── installation-step-4.png │ ├── installation-step-5.png │ ├── plugin-index.png │ ├── plugin-store-plugin.png │ ├── plugin-store.png │ ├── plugin-update.png │ ├── preview-targets.png │ ├── routing-creating-new-route.png │ ├── save-component--class.png │ ├── save-component--interface.png │ ├── searching-search-bar.png │ ├── sections-and-entries-entry-types.png │ ├── share-with-targets.png │ ├── users-client-user.png │ └── volume-base-url-setting.jpg ├── installation.md ├── lightswitch-fields.md ├── localization.md ├── matrix-fields.md ├── multi-select-fields.md ├── number-fields.md ├── plain-text-fields.md ├── planning-your-craft-site.md ├── plugins.md ├── project-config.md ├── radio-buttons-fields.md ├── reference-tags.md ├── relations.md ├── requirements.md ├── routing.md ├── searching.md ├── sections-and-entries.md ├── sites.md ├── static-translations.md ├── table-fields.md ├── tags-fields.md ├── tags.md ├── testing │ ├── README.md │ ├── ci.md │ ├── codeception.md │ ├── framework │ │ ├── assertion-helpers.md │ │ ├── config-options.md │ │ ├── full-mock.md │ │ ├── mocking.md │ │ └── support-classes.md │ ├── testing-craft │ │ ├── console.md │ │ ├── events.md │ │ ├── fixtures.md │ │ ├── getting-started.md │ │ ├── plugins-and-modules.md │ │ ├── queue.md │ │ └── testing-tips.md │ └── testing.md ├── updating.md ├── upgrade.md ├── url-fields.md ├── users-fields.md └── users.md ├── lightswitch-fields.md ├── localization.md ├── matrix-fields.md ├── multi-select-fields.md ├── number-fields.md ├── package.json ├── plain-text-fields.md ├── planning-your-craft-site.md ├── plugins.md ├── project-config.md ├── radio-buttons-fields.md ├── reference-tags.md ├── relations.md ├── requirements.md ├── routing.md ├── searching.md ├── sections-and-entries.md ├── sites.md ├── static-translations.md ├── table-fields.md ├── tags-fields.md ├── tags.md ├── testing ├── README.md ├── ci.md ├── codeception.md ├── framework │ ├── assertion-helpers.md │ ├── config-options.md │ ├── full-mock.md │ ├── mocking.md │ └── support-classes.md ├── testing-craft │ ├── console.md │ ├── events.md │ ├── fixtures.md │ ├── getting-started.md │ ├── plugins-and-modules.md │ ├── queue.md │ └── testing-tips.md └── testing.md ├── updating.md ├── upgrade.md ├── url-fields.md ├── users-fields.md ├── users.md └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | package-lock.json 2 | /.idea 3 | /node_modules 4 | *.log 5 | .DS_Store 6 | /docs-build 7 | -------------------------------------------------------------------------------- /.vuepress/public/icon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /color-fields.md: -------------------------------------------------------------------------------- 1 | # Color Fields 2 | 3 | Color fields give you a hexadecimal color input with a preview of the current color, and on browsers that support ``, clicking on the preview will open the browser’s color picker. 4 | 5 | ## Templating 6 | 7 | Calling a Color field in your templates will return a object, or `null` if no color was selected. 8 | 9 | ```twig 10 | {% if entry.linkColor %} 11 | 16 | {% endif %} 17 | ``` 18 | -------------------------------------------------------------------------------- /crowdin.yml: -------------------------------------------------------------------------------- 1 | files: 2 | - source: /**/*.md 3 | ignore: 4 | - /fr/ 5 | - /ar/ 6 | - /de/ 7 | - /es/ 8 | - /it/ 9 | - /nl/ 10 | - /pt/ 11 | - /ru/ 12 | - /zh/ 13 | - /ja/ 14 | translation: /%two_letters_code%/%original_path%/%file_name%.md 15 | content_segmentation: 0 -------------------------------------------------------------------------------- /dev/elements.md: -------------------------------------------------------------------------------- 1 | # Elements 2 | 3 | - [Asset](api:craft\elements\Asset) 4 | - [Category](api:craft\elements\Category) 5 | - [Entry](api:craft\elements\Entry) 6 | - [GlobalSet](api:craft\elements\GlobalSet) 7 | - [MatrixBlock](api:craft\elements\MatrixBlock) 8 | - [Tag](api:craft\elements\Tag) 9 | - [User](api:craft\elements\User) 10 | -------------------------------------------------------------------------------- /dev/elements/asset.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/craftcms/legacy-docs/ce80a70c3d1b4592638ea3c28cf2d3fec801cad1/dev/elements/asset.md -------------------------------------------------------------------------------- /dev/elements/category.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/craftcms/legacy-docs/ce80a70c3d1b4592638ea3c28cf2d3fec801cad1/dev/elements/category.md -------------------------------------------------------------------------------- /dev/elements/entry.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/craftcms/legacy-docs/ce80a70c3d1b4592638ea3c28cf2d3fec801cad1/dev/elements/entry.md -------------------------------------------------------------------------------- /dev/elements/global-set.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/craftcms/legacy-docs/ce80a70c3d1b4592638ea3c28cf2d3fec801cad1/dev/elements/global-set.md -------------------------------------------------------------------------------- /dev/elements/matrix-block.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/craftcms/legacy-docs/ce80a70c3d1b4592638ea3c28cf2d3fec801cad1/dev/elements/matrix-block.md -------------------------------------------------------------------------------- /dev/elements/tag.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/craftcms/legacy-docs/ce80a70c3d1b4592638ea3c28cf2d3fec801cad1/dev/elements/tag.md -------------------------------------------------------------------------------- /dev/elements/user.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/craftcms/legacy-docs/ce80a70c3d1b4592638ea3c28cf2d3fec801cad1/dev/elements/user.md -------------------------------------------------------------------------------- /dev/examples/README.md: -------------------------------------------------------------------------------- 1 | # Template Examples 2 | 3 | Some common usage examples in Craft: 4 | 5 | - [Integrating Disqus](integrating-disqus.md) 6 | - [RSS Feed](rss-feed.md) 7 | - [Atom Feed](atom-feed.md) 8 | - [Entry Form](entry-form.md) 9 | - [Search Form](search-form.md) 10 | - [Login Form](login-form.md) 11 | - [User Profile Form](user-profile-form.md) 12 | - [User Registration Form](user-registration-form.md) 13 | - [Forgot Password Form](forgot-password-form.md) 14 | - [Set Password Form](set-password-form.md) 15 | -------------------------------------------------------------------------------- /dev/examples/atom-feed.md: -------------------------------------------------------------------------------- 1 | # Atom Feed 2 | 3 | The following template can be used to provide an Atom 1.0 feed on your site. It assumes that you have a [global set](../../globals.md) with the handle `globals`, with two fields: `feedAuthorName` and `feedAuthorEmail`. 4 | 5 | ::: tip 6 | If you save this in a template that ends with an `.atom` file extension, Craft will even serve it with an `application/atom+xml` MIME type. 7 | ::: 8 | 9 | ```twig 10 | 11 | 12 | 13 | {{ siteName }} 14 | 15 | 16 | {{ now|atom }} 17 | {{ craft.app.request.absoluteUrl }} 18 | 19 | {{ globals.feedAuthorName }} 20 | {{ globals.feedAuthorEmail }} 21 | 22 | 23 | {% for entry in craft.entries.all() %} 24 | 25 | {{ entry.url }} 26 | 27 | {{ entry.title }} 28 | {{ entry.postDate|atom }} 29 | {{ entry.dateUpdated|atom }} 30 | 31 | {{ entry.author.fullName }} 32 | {{ siteUrl }} 33 | 34 | 37 | 38 | {% endfor %} 39 | 40 | ``` 41 | 42 | -------------------------------------------------------------------------------- /dev/examples/entry-form.md: -------------------------------------------------------------------------------- 1 | # Entry Form 2 | 3 | You can create a form for submitting new entries using the following code as a starting point: 4 | 5 | ```twig 6 | {% macro errorList(errors) %} 7 | {% if errors %} 8 | 13 | {% endif %} 14 | {% endmacro %} 15 | 16 | {# If there were any validation errors, an `entry` variable will be passed to the 17 | template, which contains the posted values and validation errors. If that’s not 18 | set, we’ll default to a new entry. #} 19 | {% set entry = entry ?? create('craft\\elements\\Entry') %} 20 | 21 |
22 | {{ csrfInput() }} 23 | {{ actionInput('entries/save-entry') }} 24 | {{ redirectInput('viewentry/{slug}') }} 25 | {{ hiddenInput('sectionId', '2') }} 26 | {{ hiddenInput('enabled', '1') }} 27 | 28 | 29 | {{ input('text', 'title', entry.title, { 30 | id: 'title', 31 | class: entry.hasErrors('title') ? 'error', 32 | }) }} 33 | {{ _self.errorList(entry.getErrors('title')) }} 34 | 35 | 36 | {{ tag('textarea', entry.body, { 37 | id: 'body', 38 | name: 'body', 39 | class: entry.hasErrors('body') ? 'error', 40 | }) }} 41 | {{ _self.errorList(entry.getErrors('body')) }} 42 | 43 | 44 |
45 | ``` 46 | 47 | Be sure to change the `sectionId` value to the actual ID of the section want to save the entry to. 48 | 49 | The user submitting the entry will also need to have the permission necessary to create entries for the section they are posting to. 50 | 51 | ::: tip 52 | You can accept anonymous entry submissions using the [Guest Entries](https://plugins.craftcms.com/guest-entries) plugin. 53 | ::: 54 | 55 | ### Editing Existing Entries 56 | 57 | You can modify the form to save existing entries by adding an `entryId` hidden input to the form: 58 | 59 | ```twig 60 | {{ hiddenInput('entryId', entry.id) }} 61 | ``` 62 | -------------------------------------------------------------------------------- /dev/examples/forgot-password-form.md: -------------------------------------------------------------------------------- 1 | # Forgot Password Form 2 | 3 | You can create a Forgot Password form using the following code: 4 | 5 | ```twig 6 |
7 | {{ csrfInput() }} 8 | {{ actionInput('users/send-password-reset-email') }} 9 | {{ redirectInput('') }} 10 | 11 |

12 | 14 | 15 | {% if errors is defined %} 16 | 21 | {% endif %} 22 | 23 | 24 |
25 | ``` 26 | 27 | ::: tip 28 | Craft doesn’t ever automatically create links to your Forgot Password page – only your own templates will link to it – so you don’t need to set any config settings with the path to this page, unlike other pages in the password-reset flow (e.g. and ). 29 | ::: 30 | -------------------------------------------------------------------------------- /dev/examples/integrating-disqus.md: -------------------------------------------------------------------------------- 1 | # Integrating Disqus 2 | 3 | You can easily add comments to your Craft entry pages by utilizing a third-party comment service such as [Disqus](https://disqus.com/). 4 | 5 | To do this, you will need to have an output for displaying a single entry you want to allow comments on. In this example, we'll use a template located at `templates/_entry.twig`. 6 | 7 | You'll want to sign up with Disqus and get your Universal Code on Disqus’ site in Admin → Settings → Install. Disqus has certain configuration variables that you can use to ensure comments end up on the right post. Look for: 8 | 9 | ```javascript 10 | /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */ 11 | ``` 12 | 13 | and add this line: 14 | 15 | ```javascript 16 | var disqus_identifier = 'blog-{{ entry.id }}'; 17 | ``` 18 | 19 | A final entry template including comments might look like so: 20 | 21 | ```twig 22 | {% block blog %} 23 |

{{ entry.title }}

24 | 25 | {{ entry.body|raw }} 26 | 27 |
28 | 41 | 42 | 43 | comments powered by Disqus 44 | {% endblock %} 45 | ``` 46 | 47 | -------------------------------------------------------------------------------- /dev/examples/login-form.md: -------------------------------------------------------------------------------- 1 | # Login Form 2 | 3 | If you need to login a user from the front-end of your site, you can do so with the following code: 4 | 5 | ```twig 6 |
7 | {{ csrfInput() }} 8 | {{ actionInput('users/login') }} 9 | 10 |

11 | 13 | 14 |

15 | 16 | 17 | 21 | 22 | 23 | 24 | {% if errorMessage is defined %} 25 |

{{ errorMessage }}

26 | {% endif %} 27 |
28 | 29 |

Forget your password?

30 | ``` 31 | 32 | `craft.app.user.returnUrl` is set to the original URL that included the `{% requireLogin %}` tag that initiated the redirect to this login form. 33 | 34 | By default, users will be redirected based on your `postLoginRedirect` config setting value after logging in. You can override that within your login form using a `redirect` param: 35 | 36 | ```twig 37 | {{ redirectInput('some/custom/path') }} 38 | ``` 39 | 40 | -------------------------------------------------------------------------------- /dev/examples/rss-feed.md: -------------------------------------------------------------------------------- 1 | # RSS Feed 2 | 3 | The following template can be used to provide a RSS 2.0 feed on your site. It assumes that you have a [global set](../../globals.md) with the handle `globals`, with a field called `siteDescription`. 4 | 5 | ::: tip 6 | If you save this in a template that ends with a `.rss` file extension, Craft will even serve it with an `application/rss+xml` MIME type. 7 | ::: 8 | 9 | ```twig 10 | 11 | 12 | 13 | {{ siteName }} 14 | {{ siteUrl }} 15 | 16 | {{ globals.siteDescription }} 17 | en-us 18 | {{ now|rss }} 19 | {{ now|rss }} 20 | 21 | {% for entry in craft.entries.all() %} 22 | 23 | {{ entry.title }} 24 | {{ entry.url }} 25 | {{ entry.postDate|rss }} 26 | {{ entry.author }} 27 | {{ entry.url }} 28 | 31 | 32 | {% endfor %} 33 | 34 | 35 | ``` 36 | 37 | -------------------------------------------------------------------------------- /dev/examples/search-form.md: -------------------------------------------------------------------------------- 1 | # Search Form 2 | 3 | To create a search form, first create a normal HTML form with a `search` input: 4 | 5 | ```twig 6 |
7 | 8 | 9 |
10 | ``` 11 | 12 | Then, on whatever template your form submits to (e.g. `search/results.twig`), just pull the search query from the `GET`/`POST` data, and pass it to the `search` [entry query param](../element-queries/entry-queries.md#search): 13 | 14 | ```twig 15 |

Search Results

16 | 17 | {% set searchQuery = craft.app.request.getParam('q') %} 18 | {% set entries = craft.entries() 19 | .search(searchQuery) 20 | .orderBy('score') 21 | .all() %} 22 | 23 | {% if entries|length %} 24 |

{{ entries|length }} results:

25 | 26 | 31 | {% else %} 32 |

Your search for “{{ searchQuery }}” didn’t return any results.

33 | {% endif %} 34 | ``` 35 | -------------------------------------------------------------------------------- /dev/examples/set-password-form.md: -------------------------------------------------------------------------------- 1 | # Set Password Form 2 | 3 | When a user forgets their password, Craft will send them an email with a URL to set a new password. That URL is defined by your config setting, which is “setpassword” by default. 4 | 5 | If you want the front-end of your site to support password resetting, you need to create a template at the path specified by the ”setPasswordPath” config setting. 6 | 7 | Within that template, place the following code: 8 | 9 | ```twig 10 |
11 | {{ csrfInput() }} 12 | {{ actionInput('users/set-password') }} 13 | {{ hiddenInput('code', code) }} 14 | {{ hiddenInput('id', id) }} 15 | 16 |

17 | 18 | {% if errors is defined %} 19 |
    20 | {% for error in errors %} 21 |
  • {{ error }}
  • 22 | {% endfor %} 23 |
24 | {% endif %} 25 | 26 | 27 |
28 | ``` 29 | 30 | After the user successfully logs in, they will be redirected to the path defined by the config setting. 31 | -------------------------------------------------------------------------------- /dev/examples/user-registration-form.md: -------------------------------------------------------------------------------- 1 | # User Registration Form 2 | 3 | If you have Craft Pro and want people to be able to register user accounts on your site, first go to Settings → Users → Settings and make sure that the “Allow Public Registration?” setting is checked. 4 | 5 | Then you can create a registration form on the front end, like this: 6 | 7 | ```twig 8 |
9 | {{ csrfInput() }} 10 | {{ actionInput('users/save-user') }} 11 | {{ redirectInput('') }} 12 | 13 | {% macro errorList(errors) %} 14 | {% if errors %} 15 |
    16 | {% for error in errors %} 17 |
  • {{ error }}
  • 18 | {% endfor %} 19 |
20 | {% endif %} 21 | {% endmacro %} 22 | 23 |

24 | 26 | 27 | {% if user is defined %} 28 | {{ _self.errorList(user.getErrors('username')) }} 29 | {% endif %} 30 | 31 |

32 | 34 | 35 | {% if user is defined %} 36 | {{ _self.errorList(user.getErrors('email')) }} 37 | {% endif %} 38 | 39 |

40 | 41 | 42 | {% if user is defined %} 43 | {{ _self.errorList(user.getErrors('password')) }} 44 | {% endif %} 45 | 46 | 47 |
48 | ``` 49 | 50 | -------------------------------------------------------------------------------- /dev/headless.md: -------------------------------------------------------------------------------- 1 | # Going Headless 2 | 3 | Craft’s templating system isn’t the only way to get your content out of Craft. 4 | 5 | If you want to use Craft as a “headless” CMS, meaning it acts as a content API instead of (or in addition to) a regular website, there are a few ways you can go about it. 6 | 7 | To see exactly what enabling Headless Mode does, see the [`headlessMode` config setting](../config/config-settings.md#headlessmode). 8 | 9 | ::: tip 10 | Check out CraftQuest’s [Headless Craft CMS](https://craftquest.io/courses/headless-craft) course to learn more about using Craft as a headless CMS. 11 | ::: 12 | 13 | ## GraphQL API 14 | 15 | Craft comes with a built-in, self-generating [GraphQL API](../graphql.md). 16 | 17 | ## JSON API 18 | 19 | The first-party [Element API](https://github.com/craftcms/element-api) offers a simple way to create a read-only [JSON API](http://jsonapi.org/) for your content. 20 | 21 | ## REST API 22 | 23 | Watch Nate Iler’s [How to Create a Full REST API](http://dotall.com/sessions/how-to-create-a-full-rest-api-with-craft-3) presentation from Dot All 2017 for an in-depth look at how to create a REST API with Craft. 24 | 25 | ## Something Custom 26 | 27 | Modules and plugins can define custom front-end [controllers](https://www.yiiframework.com/doc/guide/2.0/en/structure-controllers) that provide new HTTP endpoints. See [Extending Craft](../extend/README.md) to get started. 28 | -------------------------------------------------------------------------------- /dev/tests.md: -------------------------------------------------------------------------------- 1 | # Tests 2 | 3 | The following [tests](https://twig.symfony.com/doc/2.x/templates.html#test-operator) are available to Twig templates in Craft: 4 | 5 | Test | Description 6 | ---- | ----------- 7 | [constant](https://twig.symfony.com/doc/2.x/tests/constant.html) | Whether a variable is the same as a PHP constant value. 8 | [defined](https://twig.symfony.com/doc/2.x/tests/defined.html) | Whether a variable is defined. 9 | [divisible by](https://twig.symfony.com/doc/2.x/tests/divisibleby.html) | Whether a number is divisible by another number. 10 | [empty](https://twig.symfony.com/doc/2.x/tests/empty.html) | Whether a variable is empty. 11 | [even](https://twig.symfony.com/doc/2.x/tests/even.html) | Whether a number is even. 12 | [instance of](#instance-of) | Whether an object is an instance of a namespace or parent class. 13 | [iterable](https://twig.symfony.com/doc/2.x/tests/iterable.html) | Whether a variable is an array or a traversable object. 14 | [missing](#missing) | Whether an object is missing its expected class. 15 | [null](https://twig.symfony.com/doc/2.x/tests/null.html) | Whether a variable is `null`. 16 | [odd](https://twig.symfony.com/doc/2.x/tests/odd.html) | Whether a number is odd. 17 | [same as](https://twig.symfony.com/doc/2.x/tests/sameas.html) | Whether a variable is the same as another. 18 | 19 | ## `instance of` 20 | 21 | Returns whether an object is an instance of another object or class. 22 | 23 | ```twig 24 | {% if element is instance of('craft\\elements\\Entry') %} 25 |

{{ entry.title }}

26 | {% endif %} 27 | ``` 28 | 29 | ## `missing` 30 | 31 | Returns whether a given object is an instance of , an interface used to represent components whose types are missing. 32 | 33 | ```twig 34 | {% if field is missing %} 35 |

😱

36 | {% endif %} 37 | ``` 38 | -------------------------------------------------------------------------------- /email-fields.md: -------------------------------------------------------------------------------- 1 | # Email Fields 2 | -------------------------------------------------------------------------------- /extend/README.md: -------------------------------------------------------------------------------- 1 | # Extending Craft 2 | 3 | Craft provides a complete toolkit for customizing its features and functionality – almost every aspect of Craft can be extended, hooked into, or completely replaced. If you know PHP, you can build anything you want with it. 4 | 5 | ## Modules vs. Plugins 6 | 7 | Most customizations come in the form of a **module** or a **plugin**. 8 | 9 | As Yii’s documentation [puts it](https://www.yiiframework.com/doc/guide/2.0/en/structure-modules), **modules** are _“self-contained software units that consist of models, views, controllers, and other supporting components”_. In other words, modules extend the system in various ways, without needing to change any of the core system code. 10 | 11 | Modules can be simple, serving a single purpose like providing a new [Dashboard widget type](widget-types.md), or they can be complex, introducing entirely new concepts to the system, like an e-commerce application. 12 | 13 | **Plugins** are a Craft-specific concept, so you won’t find any mention of it in the Yii docs. They can do everything modules can do (plugins actually _are_ modules, technically), and some other things that make them better for being publicly distributed: 14 | 15 | - They can be installed/trialed/purchased from the Craft Plugin Store. 16 | - They can make database changes when installed, updated, or uninstalled. 17 | - They get their own settings page within the Settings section of the control panel. 18 | - They can be enabled/disabled by an admin, without running any Composer commands. 19 | 20 | If the thing you want to build would benefit from those features, make it a plugin. Otherwise, a module might be better. 21 | -------------------------------------------------------------------------------- /extend/cp-templates.md: -------------------------------------------------------------------------------- 1 | # Control Panel Templates 2 | 3 | The control panel is built using Twig templates, so extending it with new pages should feel familiar if you’ve worked with Twig on the front-end. 4 | 5 | Plugins can define templates within the `templates/` folder within their base source folder. Templates within there can be referenced using the plugin’s handle as the template path prefix. 6 | 7 | For example if a plugin’s handle is `foo` and it has a `templates/bar.twig` template, that template could be accessed by going to `/admin/foo/bar`, or from Twig by including/extending `foo/bar` (or `foo/bar.twig`). 8 | 9 | Modules can have templates too, but they will need to manually define a [template root](template-roots.md) before they are accessible. 10 | 11 | ## Page Templates 12 | 13 | At a minimum, page templates should extend Craft’s [_layouts/cp](https://github.com/craftcms/cms/blob/develop/src/templates/_layouts/cp.html) layout template, set a `title` variable, and define a `content` block. 14 | 15 | ```twig 16 | {% extends "_layouts/cp" %} 17 | {% set title = "Page Title"|t('plugin-handle') %} 18 | 19 | {% block content %} 20 |

Page content goes here

21 | {% endblock %} 22 | ``` 23 | 24 | The following blocks can also be defined, to customize other aspects of the page: 25 | 26 | - `header` – Used to output the page header, including the page title and other header elements. 27 | - `pageTitle` – Used to output the page title. 28 | - `contextMenu` – Used to output context menus beside the page title. (For example, the entry revision menu on Edit Entry pages.) 29 | - `actionButton` – Used to output the primary page action button. (For example, the Save button on Edit Entry pages.) 30 | - `sidebar` – Used to output the page sidebar contents. 31 | - `details` – Used to output the detail pane contents. 32 | -------------------------------------------------------------------------------- /extend/element-action-types.md: -------------------------------------------------------------------------------- 1 | # Element Action Types 2 | 3 | Plugins can provide custom action types for element index pages by creating a class that implements . The class will serve both as a way to communicate various things about your action type (with static methods), and as a model that actions of its type will be instantiated with. 4 | 5 | As a convenience, you can extend , which provides a base action type implementation. 6 | 7 | You can refer to Craft’s own element action classes for examples. They are located in `vendor/craftcms/cms/src/elements/actions/`. 8 | 9 | ## Registering Custom Element Action Types 10 | 11 | To get an element action to show up on an element index page, it has to be registered with the element type. 12 | 13 | If it’s for a custom element type that is defined by the same plugin, simply include your element action in the element class’s [defineActions()](element-types.md#index-page-actions) method. 14 | 15 | If it’s for an element type that is out of the plugin’s control, you can register it using the `registerActions` event: 16 | 17 | ```php 18 | actions[] = MyAction::class; 32 | }); 33 | 34 | // ... 35 | } 36 | 37 | // ... 38 | } 39 | ``` 40 | -------------------------------------------------------------------------------- /extend/field-types.md: -------------------------------------------------------------------------------- 1 | # Field Types 2 | 3 | Plugins can provide custom field types by creating a class that implements and . The class will serve both as a way to communicate various things about your field type (with static methods), and as a model that fields of its type will be instantiated with. 4 | 5 | As a convenience, you can extend , which provides a base field type implementation. 6 | 7 | You can refer to Craft’s own field classes for examples. They are located in `vendor/craftcms/cms/src/fields/`. 8 | 9 | ## Registering Custom Field Types 10 | 11 | Once you have created your field class, you will need to register it with the Fields service, so Craft will know about it when populating the list of available field types: 12 | 13 | ```php 14 | types[] = MyField::class; 30 | } 31 | ); 32 | 33 | // ... 34 | } 35 | 36 | // ... 37 | } 38 | ``` 39 | 40 | ## Supporting Delta Saves 41 | 42 | If your field type does any processing from [afterElementSave()]() or [afterElementPropagate()](), you can improve performance by skipping processing when the field’s value is unchanged. 43 | 44 | You can tell whether field content has changed by calling [isFieldDirty()]() on the element. 45 | 46 | ```php 47 | public function afterElementSave(ElementInterface $element, bool $isNew) 48 | { 49 | if ($element->isFieldDirty()) { 50 | // logic for handling saved element 51 | } 52 | 53 | parent::afterElementSave($element, $isNew); 54 | } 55 | ``` 56 | -------------------------------------------------------------------------------- /extend/template-hooks.md: -------------------------------------------------------------------------------- 1 | # Template Hooks 2 | 3 | Craft templates can give modules and plugins an opportunity to hook into them using [hook](../dev/tags/hook.md) tags. 4 | 5 | ```twig 6 | {# Give plugins a chance to make changes here #} 7 | {% hook 'my-custom-hook-name' %} 8 | ``` 9 | 10 | Plugins and modules can register methods to be called by template hooks using . 11 | 12 | ```php 13 | Craft::$app->view->hook('my-custom-hook-name', function(array &$context) { 14 | $context['foo'] = 'bar'; 15 | return '

Hey!

'; 16 | }); 17 | ``` 18 | 19 | The callback method will pass a `$context` argument, which represents the current template context (all of the currently defined template variables). Any changes to this array will result in changes to the template’s variables for any tags that follow the `{% hook %}` tag. 20 | 21 | The method can optionally return a string, which will be output where the `{% hook %}` tag is in the template. 22 | -------------------------------------------------------------------------------- /extend/template-roots.md: -------------------------------------------------------------------------------- 1 | # Template Roots 2 | 3 | Modules and plugins can register custom “template roots” for either control panel or front-end templates. 4 | 5 | A template root is a directory that contains templates, which are accessible to other templates from a predefined template path prefix. 6 | 7 | For example, you could create a plugin that provides common Twig utility macros, which could be accessible from `_utils/macros.twig`. 8 | 9 | To do that, use the [EVENT_REGISTER_SITE_TEMPLATE_ROOTS](api:craft\web\View::EVENT_REGISTER_SITE_TEMPLATE_ROOTS) event: 10 | 11 | ```php 12 | use craft\events\RegisterTemplateRootsEvent; 13 | use craft\web\View; 14 | use yii\base\Event; 15 | 16 | public function init() 17 | { 18 | parent::init(); 19 | 20 | Event::on( 21 | View::class, 22 | View::EVENT_REGISTER_SITE_TEMPLATE_ROOTS, 23 | function(RegisterTemplateRootsEvent $event) { 24 | $event->roots['_utils'] = __DIR__ . '/template-utils'; 25 | } 26 | ); 27 | } 28 | ``` 29 | 30 | If you want to register new control panel template roots, use the [EVENT_REGISTER_CP_TEMPLATE_ROOTS](api:craft\web\View::EVENT_REGISTER_CP_TEMPLATE_ROOTS) event instead. 31 | 32 | ## Plugin Control Panel Templates 33 | 34 | Plugins get a control panel template root added automatically, named after the plugin handle, which points to the `templates/` folder within the plugin’s base source folder. 35 | -------------------------------------------------------------------------------- /extend/translation-categories.md: -------------------------------------------------------------------------------- 1 | # Translation Categories 2 | 3 | Modules and plugins can provide custom translation categories, for use by Yii’s [Message Translations](https://www.yiiframework.com/doc/guide/2.0/en/tutorial-i18n#message-translation) feature. 4 | 5 | ::: tip 6 | See [Static Message Translations](../static-translations.md) for more details on how message translations work. 7 | ::: 8 | 9 | Translation categories can be added programmatically by adding a new translation source onto the array. 10 | 11 | ```php 12 | use craft\i18n\PhpMessageSource; 13 | 14 | public function init() 15 | { 16 | parent::init(); 17 | 18 | Craft::$app->i18n->translations['my-category'] = [ 19 | 'class' => PhpMessageSource::class, 20 | 'sourceLanguage' => 'en', 21 | 'basePath' => __DIR__ . '/translations', 22 | 'allowOverrides' => true, 23 | ]; 24 | } 25 | ``` 26 | 27 | If you have control over the [application config](../config/app.md), you could also add the translation category from there: 28 | 29 | ```php 30 | // -- config/app.php -- 31 | return [ 32 | 'components' => [ 33 | 'i18n' => [ 34 | 'translations' => [ 35 | 'my-category' => [ 36 | 'class' => craft\i18n\PhpMessageSource::class, 37 | 'sourceLanguage' => 'en', 38 | 'basePath' => dirname(__DIR__) . '/translations', 39 | 'allowOverrides' => true, 40 | ], 41 | ], 42 | ], 43 | ], 44 | ]; 45 | ``` 46 | 47 | ## Plugin Translations 48 | 49 | Plugins get a custom translation category registered automatically, named after the plugin handle. Plugins can provide translation files within a `translations/` folder in their base source folder. 50 | 51 | ```treeview 52 | src/ 53 | ├── Plugin.php 54 | ├── ... 55 | └── translations/ 56 | └── de/ 57 | └── plugin-handle.php 58 | ``` 59 | -------------------------------------------------------------------------------- /extend/utility-types.md: -------------------------------------------------------------------------------- 1 | # Utility Types 2 | 3 | Plugins can provide custom utility types for the Utilities section by creating a class that implements . 4 | 5 | As a convenience, you can extend , which provides a base utility type implementation. 6 | 7 | You can refer to Craft’s own utility classes for examples. They are located in `vendor/craftcms/cms/src/utilities/`. 8 | 9 | ## Registering Custom Utility Types 10 | 11 | Once you have created your utility class, you will need to register it with the Utilities service, so Craft will know about it when populating the list of available utility types: 12 | 13 | ```php 14 | types[] = MyUtility::class; 27 | }); 28 | 29 | // ... 30 | } 31 | 32 | // ... 33 | } 34 | ``` 35 | -------------------------------------------------------------------------------- /extend/volume-types.md: -------------------------------------------------------------------------------- 1 | # Volume Types 2 | 3 | Plugins can provide custom asset volume types by creating a class that implements and . The class will serve both as a way to communicate various things about your volume type (with static methods), and as a model that volumes of its type will be instantiated with. 4 | 5 | As a convenience, you can extend , which provides a base volume type implementation, optimized for [Flysystem](https://flysystem.thephpleague.com/) adapters. 6 | 7 | You can refer to Craft’s own volume classes for examples. They are located in `vendor/craftcms/cms/src/volumes/`. 8 | 9 | ## Registering Custom Volume Types 10 | 11 | Once you have created your volume class, you will need to register it with the Volumes service, so Craft will know about it when populating the list of available volume types: 12 | 13 | ```php 14 | types[] = MyVolume::class; 27 | }); 28 | 29 | // ... 30 | } 31 | 32 | // ... 33 | } 34 | ``` 35 | -------------------------------------------------------------------------------- /extend/widget-types.md: -------------------------------------------------------------------------------- 1 | # Widget Types 2 | 3 | Plugins can provide custom widget types for the Dashboard by creating a class that implements and . The class will serve both as a way to communicate various things about your widget type (with static methods), and as a model that widgets of its type will be instantiated with. 4 | 5 | As a convenience, you can extend , which provides a base widget type implementation. 6 | 7 | You can refer to Craft’s own widget classes for examples. They are located in `vendor/craftcms/cms/src/widgets/`. 8 | 9 | ## Registering Custom Widget Types 10 | 11 | Once you have created your widget class, you will need to register it with the Dashboard service, so Craft will know about it when populating the list of available widget types: 12 | 13 | ```php 14 | types[] = MyWidget::class; 27 | }); 28 | 29 | // ... 30 | } 31 | 32 | // ... 33 | } 34 | ``` 35 | -------------------------------------------------------------------------------- /fr/README.md: -------------------------------------------------------------------------------- 1 | # About Craft CMS 2 | 3 | Craft is a flexible, user-friendly CMS for creating custom digital experiences on the web and beyond. 4 | 5 | It features: 6 | 7 | - An intuitive, user-friendly Control Panel for content creation and administrative tasks. 8 | - A clean-slate approach to content modeling and [front-end development](dev/README.md) that doesn’t make any assumptions about your content or how it should be consumed. 9 | - A built-in Plugin Store with hundreds of free and commercial [plugins](https://plugins.craftcms.com/), all just a click away. 10 | - A robust framework for [module and plugin development](extend/README.md). 11 | - An active, vibrant [community](https://craftcms.com/community). 12 | 13 | You can learn all about it at [craftcms.com](https://craftcms.com). 14 | 15 | ## Tech Specs 16 | 17 | Craft is a self-hosted PHP 7 application, built on [Yii 2](https://www.yiiframework.com/). It can connect to MySQL and PostgreSQL for content storage. Templating is powered by [Twig](https://twig.symfony.com). 18 | 19 | ## Popular Resources 20 | 21 | - **[Documentation](http://docs.craftcms.com/v3/)** – Read the official docs. 22 | - **[Guides](https://craftcms.com/guides)** – Follow along with the official guides. 23 | - **[#craftcms](https://twitter.com/hashtag/craftcms)** – See the latest tweets about Craft. 24 | - **[Discord](https://craftcms.com/discord)** – Meet the community. 25 | - **[Stack Exchange](http://craftcms.stackexchange.com/)** – Get help and help others. 26 | - **[CraftQuest](https://craftquest.io/)** – Watch unlimited video lessons and courses. 27 | - **[Craft Link List](http://craftlinklist.com/)** – Stay in-the-know. 28 | - **[nystudio107 Blog](https://nystudio107.com/blog)** – Learn Craft and modern web development. 29 | 30 | ## Diving In 31 | 32 | To start getting acquainted with how content modeling works in Craft, read [Sections and Entries](sections-and-entries.md) and [Fields](fields.md). 33 | 34 | When you’re ready to install Craft, read [Server Requirements](requirements.md) and [Installation Instructions](installation.md). 35 | 36 | Finally, read the [Front-End Development](dev/README.md) section when you’re ready to start building out the front-end of your site or application. 37 | -------------------------------------------------------------------------------- /fr/color-fields.md: -------------------------------------------------------------------------------- 1 | # Color Fields 2 | 3 | Color fields give you a hexadecimal color input with a preview of the current color, and on browsers that support ``, clicking on the preview will open the browser’s color picker. 4 | 5 | ## Templating 6 | 7 | Calling a Color field in your templates will return a object, or `null` if no color was selected. 8 | 9 | ```twig 10 | {% if entry.linkColor %} 11 | 16 | {% endif %} 17 | ``` 18 | -------------------------------------------------------------------------------- /fr/dev/elements.md: -------------------------------------------------------------------------------- 1 | # Elements 2 | 3 | - [Asset](api:craft\elements\Asset) 4 | - [Category](api:craft\elements\Category) 5 | - [Entry](api:craft\elements\Entry) 6 | - [GlobalSet](api:craft\elements\GlobalSet) 7 | - [MatrixBlock](api:craft\elements\MatrixBlock) 8 | - [Tag](api:craft\elements\Tag) 9 | - [User](api:craft\elements\User) 10 | -------------------------------------------------------------------------------- /fr/dev/elements/asset.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/craftcms/legacy-docs/ce80a70c3d1b4592638ea3c28cf2d3fec801cad1/fr/dev/elements/asset.md -------------------------------------------------------------------------------- /fr/dev/elements/category.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/craftcms/legacy-docs/ce80a70c3d1b4592638ea3c28cf2d3fec801cad1/fr/dev/elements/category.md -------------------------------------------------------------------------------- /fr/dev/elements/entry.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/craftcms/legacy-docs/ce80a70c3d1b4592638ea3c28cf2d3fec801cad1/fr/dev/elements/entry.md -------------------------------------------------------------------------------- /fr/dev/elements/global-set.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/craftcms/legacy-docs/ce80a70c3d1b4592638ea3c28cf2d3fec801cad1/fr/dev/elements/global-set.md -------------------------------------------------------------------------------- /fr/dev/elements/matrix-block.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/craftcms/legacy-docs/ce80a70c3d1b4592638ea3c28cf2d3fec801cad1/fr/dev/elements/matrix-block.md -------------------------------------------------------------------------------- /fr/dev/elements/tag.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/craftcms/legacy-docs/ce80a70c3d1b4592638ea3c28cf2d3fec801cad1/fr/dev/elements/tag.md -------------------------------------------------------------------------------- /fr/dev/elements/user.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/craftcms/legacy-docs/ce80a70c3d1b4592638ea3c28cf2d3fec801cad1/fr/dev/elements/user.md -------------------------------------------------------------------------------- /fr/dev/examples/README.md: -------------------------------------------------------------------------------- 1 | # Template Examples 2 | 3 | Some common usage examples in Craft: 4 | 5 | - [Integrating Disqus](integrating-disqus.md) 6 | - [RSS Feed](rss-feed.md) 7 | - [Atom Feed](atom-feed.md) 8 | - [Entry Form](entry-form.md) 9 | - [Search Form](search-form.md) 10 | - [Login Form](login-form.md) 11 | - [User Profile Form](user-profile-form.md) 12 | - [User Registration Form](user-registration-form.md) 13 | - [Forgot Password Form](forgot-password-form.md) 14 | - [Set Password Form](set-password-form.md) 15 | -------------------------------------------------------------------------------- /fr/dev/examples/atom-feed.md: -------------------------------------------------------------------------------- 1 | # Atom Feed 2 | 3 | The following template can be used to provide an Atom 1.0 feed on your site. It assumes that you have a [global set](../../globals.md) with the handle `globals`, with two fields: `feedAuthorName` and `feedAuthorEmail`. 4 | 5 | ::: tip 6 | If you save this in a template that ends with an `.atom` file extension, Craft will even serve it with an `application/atom+xml` MIME type. 7 | ::: 8 | 9 | ```twig 10 | 11 | 12 | 13 | {{ siteName }} 14 | 15 | 16 | {{ now|atom }} 17 | {{ craft.app.request.absoluteUrl }} 18 | 19 | {{ globals.feedAuthorName }} 20 | {{ globals.feedAuthorEmail }} 21 | 22 | 23 | {% for entry in craft.entries.all() %} 24 | 25 | {{ entry.url }} 26 | 27 | {{ entry.title }} 28 | {{ entry.postDate|atom }} 29 | {{ entry.dateUpdated|atom }} 30 | 31 | {{ entry.author.fullName }} 32 | {{ siteUrl }} 33 | 34 | 37 | 38 | {% endfor %} 39 | 40 | ``` 41 | 42 | -------------------------------------------------------------------------------- /fr/dev/examples/entry-form.md: -------------------------------------------------------------------------------- 1 | # Entry Form 2 | 3 | You can create a new entry form for the front-end of your site using the following code: 4 | 5 | ```twig 6 | {% macro errorList(errors) %} 7 | {% if errors %} 8 |
    9 | {% for error in errors %} 10 |
  • {{ error }}
  • 11 | {% endfor %} 12 |
13 | {% endif %} 14 | {% endmacro %} 15 | 16 |
17 | {{ csrfInput() }} 18 | {{ actionInput('entries/save-entry') }} 19 | {{ redirectInput('viewentry/{slug}') }} 20 | {{ hiddenInput('sectionId', '2') }} 21 | {{ hiddenInput('enabled', '1') }} 22 | 23 | 24 | 26 | 27 | {% if entry is defined %} 28 | {{ _self.errorList(entry.getErrors('title')) }} 29 | {% endif %} 30 | 31 | 32 | 35 | 36 | {% if entry is defined %} 37 | {{ _self.errorList(entry.getErrors('body')) }} 38 | {% endif %} 39 | 40 | 41 |
42 | 43 | ``` 44 | 45 | Be sure and adjust the “sectionId” to the actual ID of the section want to save the entry to. 46 | 47 | The user submitting the entry will also need to have the permission necessary to create entries for the section they are posting to. 48 | 49 | ### Editing Entry Form 50 | 51 | You can modify the form to save existing entries by adding an “entryId” hidden input to the form: 52 | 53 | ```twig 54 | {{ hiddenInput('entryId', entry.id) }} 55 | ``` 56 | -------------------------------------------------------------------------------- /fr/dev/examples/forgot-password-form.md: -------------------------------------------------------------------------------- 1 | # Forgot Password Form 2 | 3 | You can create a Forgot Password form using the following code: 4 | 5 | ```twig 6 |
7 | {{ csrfInput() }} 8 | {{ actionInput('users/send-password-reset-email') }} 9 | {{ redirectInput('') }} 10 | 11 |

12 | 14 | 15 | {% if errors is defined %} 16 |
    17 | {% for error in errors %} 18 |
  • {{ error }}
  • 19 | {% endfor %} 20 |
21 | {% endif %} 22 | 23 | 24 |
25 | ``` 26 | 27 | ::: tip 28 | Craft doesn’t ever automatically create links to your Forgot Password page – only your own templates will link to it – so you don’t need to set any config settings with the path to this page, unlike other pages in the password-reset flow (e.g. and ). 29 | ::: 30 | -------------------------------------------------------------------------------- /fr/dev/examples/integrating-disqus.md: -------------------------------------------------------------------------------- 1 | # Integrating Disqus 2 | 3 | You can easily add comments to your Craft entry pages by utilizing a third-party comment service such as [Disqus](https://disqus.com/). 4 | 5 | To do this, you will need to have an output for displaying a single entry you want to allow comments on. In this example, we'll use a template located at `templates/_entry.twig`. 6 | 7 | You'll want to sign up with Disqus and get your Universal Code on Disqus’ site in Admin → Settings → Install. Disqus has certain configuration variables that you can use to ensure comments end up on the right post. Look for: 8 | 9 | ```javascript 10 | /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */ 11 | ``` 12 | 13 | and add this line: 14 | 15 | ```javascript 16 | var disqus_identifier = 'blog-{{ entry.id }}'; 17 | ``` 18 | 19 | A final entry template including comments might look like so: 20 | 21 | ```twig 22 | {% block blog %} 23 |

{{ entry.title }}

24 | 25 | {{ entry.body|raw }} 26 | 27 |
28 | 41 | 42 | 43 | comments powered by Disqus 44 | {% endblock %} 45 | ``` 46 | 47 | -------------------------------------------------------------------------------- /fr/dev/examples/login-form.md: -------------------------------------------------------------------------------- 1 | # Login Form 2 | 3 | If you need to login a user from the front-end of your site, you can do so with the following code: 4 | 5 | ```twig 6 |
7 | {{ csrfInput() }} 8 | {{ actionInput('users/login') }} 9 | 10 |

11 | 13 | 14 |

15 | 16 | 17 | 21 | 22 | 23 | 24 | {% if errorMessage is defined %} 25 |

{{ errorMessage }}

26 | {% endif %} 27 |
28 | 29 |

Forget your password?

30 | ``` 31 | 32 | `craft.app.user.returnUrl` is set to the original URL that included the `{% requireLogin %}` tag that initiated the redirect to this login form. 33 | 34 | By default, users will be redirected based on your `postLoginRedirect` config setting value after logging in. You can override that within your login form using a `redirect` param: 35 | 36 | ```twig 37 | {{ redirectInput('some/custom/path') }} 38 | ``` 39 | 40 | -------------------------------------------------------------------------------- /fr/dev/examples/rss-feed.md: -------------------------------------------------------------------------------- 1 | # RSS Feed 2 | 3 | The following template can be used to provide a RSS 2.0 feed on your site. It assumes that you have a [global set](../../globals.md) with the handle `globals`, with a field called `siteDescription`. 4 | 5 | ::: tip 6 | If you save this in a template that ends with a `.rss` file extension, Craft will even serve it with an `application/rss+xml` MIME type. 7 | ::: 8 | 9 | ```twig 10 | 11 | 12 | 13 | {{ siteName }} 14 | {{ siteUrl }} 15 | 16 | {{ globals.siteDescription }} 17 | en-us 18 | {{ now|rss }} 19 | {{ now|rss }} 20 | 21 | {% for entry in craft.entries.all() %} 22 | 23 | {{ entry.title }} 24 | {{ entry.url }} 25 | {{ entry.postDate|rss }} 26 | {{ entry.author }} 27 | {{ entry.url }} 28 | 31 | 32 | {% endfor %} 33 | 34 | 35 | ``` 36 | 37 | -------------------------------------------------------------------------------- /fr/dev/examples/search-form.md: -------------------------------------------------------------------------------- 1 | # Search Form 2 | 3 | To create a search form, first create a normal HTML form with a `search` input: 4 | 5 | ```twig 6 |
7 | 8 | 9 |
10 | ``` 11 | 12 | Then, on whatever template your form submits to (e.g. `search/results.twig`), just pull the search query from the `GET`/`POST` data, and pass it to the `search` [entry query param](../element-queries/entry-queries.md#search): 13 | 14 | ```twig 15 |

Search Results

16 | 17 | {% set searchQuery = craft.app.request.getParam('q') %} 18 | {% set entries = craft.entries() 19 | .search(searchQuery) 20 | .orderBy('score') 21 | .all() %} 22 | 23 | {% if entries|length %} 24 |

{{ entries|length }} results:

25 | 26 | 31 | {% else %} 32 |

Your search for “{{ searchQuery }}” didn’t return any results.

33 | {% endif %} 34 | ``` 35 | -------------------------------------------------------------------------------- /fr/dev/examples/set-password-form.md: -------------------------------------------------------------------------------- 1 | # Set Password Form 2 | 3 | When a user forgets their password, Craft will send them an email with a URL to set a new password. That URL is defined by your config setting, which is “setpassword” by default. 4 | 5 | If you want the front-end of your site to support password resetting, you need to create a template at the path specified by the ”setPasswordPath” config setting. 6 | 7 | Within that template, place the following code: 8 | 9 | ```twig 10 |
11 | {{ csrfInput() }} 12 | {{ actionInput('users/set-password') }} 13 | {{ hiddenInput('code', code) }} 14 | {{ hiddenInput('id', id) }} 15 | 16 |

17 | 18 | {% if errors is defined %} 19 |
    20 | {% for error in errors %} 21 |
  • {{ error }}
  • 22 | {% endfor %} 23 |
24 | {% endif %} 25 | 26 | 27 |
28 | ``` 29 | 30 | After the user successfully logs in, they will be redirected to the path defined by the config setting. 31 | -------------------------------------------------------------------------------- /fr/dev/examples/user-registration-form.md: -------------------------------------------------------------------------------- 1 | # User Registration Form 2 | 3 | If you have Craft Pro and want people to be able to register user accounts on your site, first go to Settings → Users → Settings and make sure that the “Allow Public Registration?” setting is checked. 4 | 5 | Then you can create a registration form on the front end, like this: 6 | 7 | ```twig 8 |
9 | {{ csrfInput() }} 10 | {{ actionInput('users/save-user') }} 11 | {{ redirectInput('') }} 12 | 13 | {% macro errorList(errors) %} 14 | {% if errors %} 15 |
    16 | {% for error in errors %} 17 |
  • {{ error }}
  • 18 | {% endfor %} 19 |
20 | {% endif %} 21 | {% endmacro %} 22 | 23 |

24 | 26 | 27 | {% if user is defined %} 28 | {{ _self.errorList(user.getErrors('username')) }} 29 | {% endif %} 30 | 31 |

32 | 34 | 35 | {% if user is defined %} 36 | {{ _self.errorList(user.getErrors('email')) }} 37 | {% endif %} 38 | 39 |

40 | 41 | 42 | {% if user is defined %} 43 | {{ _self.errorList(user.getErrors('password')) }} 44 | {% endif %} 45 | 46 | 47 |
48 | ``` 49 | 50 | -------------------------------------------------------------------------------- /fr/dev/headless.md: -------------------------------------------------------------------------------- 1 | # Going Headless 2 | 3 | Craft’s templating system isn’t the only way to get your content out of Craft. 4 | 5 | If you want to use Craft as a “headless” CMS, meaning it acts as a content API instead of (or in addition to) a regular website, there are a few ways you can go about it. 6 | 7 | ::: tip 8 | Check out CraftQuest’s [Headless Craft CMS](https://craftquest.io/courses/headless-craft) course to learn more about using Craft as a headless CMS. 9 | ::: 10 | 11 | ## GraphQL API 12 | 13 | Craft comes with a built-in, self-generating [GraphQL API](../graphql.md). 14 | 15 | ## JSON API 16 | 17 | The first-party [Element API](https://github.com/craftcms/element-api) offers a simple way to create a read-only [JSON API](http://jsonapi.org/) for your content. 18 | 19 | ## REST API 20 | 21 | Watch Nate Iler’s [How to Create a Full REST API](http://dotall.com/sessions/how-to-create-a-full-rest-api-with-craft-3) presentation from Dot All 2017 for an in-depth look at how to create a REST API with Craft. 22 | 23 | ## Something Custom 24 | 25 | Modules and plugins can define custom front-end [controllers](https://www.yiiframework.com/doc/guide/2.0/en/structure-controllers) that provide new HTTP endpoints. See [Extending Craft](../extend/README.md) to get started. 26 | -------------------------------------------------------------------------------- /fr/dev/tags.md: -------------------------------------------------------------------------------- 1 | # Tags 2 | 3 | In addition to the template tags that [Twig comes with](https://twig.symfony.com/doc/tags/index.html), Craft provides a few of its own. 4 | 5 | - [cache](tags/cache.md) 6 | - [css](tags/css.md) 7 | - [exit](tags/exit.md) 8 | - [header](tags/header.md) 9 | - [hook](tags/hook.md) 10 | - [js](tags/js.md) 11 | - [nav](tags/nav.md) 12 | - [paginate](tags/paginate.md) 13 | - [redirect](tags/redirect.md) 14 | - [requireLogin](tags/requirelogin.md) 15 | - [requirePermission](tags/requirepermission.md) 16 | - [switch](tags/switch.md) 17 | -------------------------------------------------------------------------------- /fr/dev/tags/css.md: -------------------------------------------------------------------------------- 1 | # `{% css %}` Tags 2 | 3 | The `{% css %}` tag can be used to register a ` 16 | {% endif %} 17 | ``` 18 | -------------------------------------------------------------------------------- /ja/dev/elements.md: -------------------------------------------------------------------------------- 1 | # エレメント 2 | 3 | - [アセット](api:craft\elements\Asset) 4 | - [カテゴリ](api:craft\elements\Category) 5 | - [エントリ](api:craft\elements\Entry) 6 | - [グローバル設定](api:craft\elements\GlobalSet) 7 | - [行列ブロック](api:craft\elements\MatrixBlock) 8 | - [タグ](api:craft\elements\Tag) 9 | - [ユーザー](api:craft\elements\User) 10 | -------------------------------------------------------------------------------- /ja/dev/elements/asset.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/craftcms/legacy-docs/ce80a70c3d1b4592638ea3c28cf2d3fec801cad1/ja/dev/elements/asset.md -------------------------------------------------------------------------------- /ja/dev/elements/category.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/craftcms/legacy-docs/ce80a70c3d1b4592638ea3c28cf2d3fec801cad1/ja/dev/elements/category.md -------------------------------------------------------------------------------- /ja/dev/elements/entry.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/craftcms/legacy-docs/ce80a70c3d1b4592638ea3c28cf2d3fec801cad1/ja/dev/elements/entry.md -------------------------------------------------------------------------------- /ja/dev/elements/global-set.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/craftcms/legacy-docs/ce80a70c3d1b4592638ea3c28cf2d3fec801cad1/ja/dev/elements/global-set.md -------------------------------------------------------------------------------- /ja/dev/elements/matrix-block.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/craftcms/legacy-docs/ce80a70c3d1b4592638ea3c28cf2d3fec801cad1/ja/dev/elements/matrix-block.md -------------------------------------------------------------------------------- /ja/dev/elements/tag.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/craftcms/legacy-docs/ce80a70c3d1b4592638ea3c28cf2d3fec801cad1/ja/dev/elements/tag.md -------------------------------------------------------------------------------- /ja/dev/elements/user.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/craftcms/legacy-docs/ce80a70c3d1b4592638ea3c28cf2d3fec801cad1/ja/dev/elements/user.md -------------------------------------------------------------------------------- /ja/dev/examples/README.md: -------------------------------------------------------------------------------- 1 | # テンプレートの実例 2 | 3 | Craft の一般的な使用例です。 4 | 5 | - [Disqus の統合](integrating-disqus.md) 6 | - [RSS フィード](rss-feed.md) 7 | - [Atom フィード](atom-feed.md) 8 | - [エントリの投稿フォーム](entry-form.md) 9 | - [検索フォーム](search-form.md) 10 | - [ログインフォーム](login-form.md) 11 | - [ユーザープロフィールの編集フォーム](user-profile-form.md) 12 | - [ユーザー登録フォーム](user-registration-form.md) 13 | - [パスワードを忘れた際のフォーム](forgot-password-form.md) 14 | - [パスワードの設定フォーム](set-password-form.md) 15 | -------------------------------------------------------------------------------- /ja/dev/examples/atom-feed.md: -------------------------------------------------------------------------------- 1 | # Atom フィード 2 | 3 | 次のテンプレートは、あなたのサイトで Atom 1.0 フィードを提供するために使用できます。`feedAuthorName` と `feedAuthorEmail` 2つのフィールドを持つ、`globals` というハンドルの[グローバルのセット](../../globals.md)があることを前提としています。 4 | 5 | ::: tip 6 | ファイル拡張子 `.atom` で終わるテンプレートとして保存すると、Craft はそれを MIME タイプ `application/atom+xml` で配信します。 7 | ::: 8 | 9 | ```twig 10 | 11 | 12 | 13 | {{ siteName }} 14 | 15 | 16 | {{ now|atom }} 17 | {{ craft.app.request.absoluteUrl }} 18 | 19 | {{ globals.feedAuthorName }} 20 | {{ globals.feedAuthorEmail }} 21 | 22 | 23 | {% for entry in craft.entries.all() %} 24 | 25 | {{ entry.url }} 26 | 27 | {{ entry.title }} 28 | {{ entry.postDate|atom }} 29 | {{ entry.dateUpdated|atom }} 30 | 31 | {{ entry.author.fullName }} 32 | {{ siteUrl }} 33 | 34 | 37 | 38 | {% endfor %} 39 | 40 | ``` 41 | 42 | -------------------------------------------------------------------------------- /ja/dev/examples/entry-form.md: -------------------------------------------------------------------------------- 1 | # エントリの投稿フォーム 2 | 3 | 次のコードを利用して、サイトのフロントエンド向けに新しいエントリの投稿フォームを作成できます。 4 | 5 | ```twig 6 | {% macro errorList(errors) %} 7 | {% if errors %} 8 |
    9 | {% for error in errors %} 10 |
  • {{ error }}
  • 11 | {% endfor %} 12 |
13 | {% endif %} 14 | {% endmacro %} 15 | 16 |
17 | {{ csrfInput() }} 18 | {{ actionInput('entries/save-entry') }} 19 | {{ redirectInput('viewentry/{slug}') }} 20 | {{ hiddenInput('sectionId', '2') }} 21 | {{ hiddenInput('enabled', '1') }} 22 | 23 | 24 | 26 | 27 | {% if entry is defined %} 28 | {{ _self.errorList(entry.getErrors('title')) }} 29 | {% endif %} 30 | 31 | 32 | 35 | 36 | {% if entry is defined %} 37 | {{ _self.errorList(entry.getErrors('body')) }} 38 | {% endif %} 39 | 40 | 41 |
42 | 43 | ``` 44 | 45 | 「sectionId」は必ずエントリを保存したいセクションの実際の ID に調整してください。 46 | 47 | エントリを送信するユーザーは、そのセクションのエントリを作成するための権限を持っている必要があります。 48 | 49 | ### エントリの編集フォーム 50 | 51 | 不可視項目の「entryId」を追加すると、既存のエントリを保存するためのフォームに変更できます。 52 | 53 | ```twig 54 | {{ hiddenInput('entryId', entry.id) }} 55 | ``` 56 | -------------------------------------------------------------------------------- /ja/dev/examples/forgot-password-form.md: -------------------------------------------------------------------------------- 1 | # パスワードを忘れた際のフォーム 2 | 3 | 次のコードを利用して、パスワードを忘れた際のフォームを作成できます。 4 | 5 | ```twig 6 |
7 | {{ csrfInput() }} 8 | {{ actionInput('users/send-password-reset-email') }} 9 | {{ redirectInput('') }} 10 | 11 |

12 | 14 | 15 | {% if errors is defined %} 16 |
    17 | {% for error in errors %} 18 |
  • {{ error }}
  • 19 | {% endfor %} 20 |
21 | {% endif %} 22 | 23 | 24 |
25 | ``` 26 | 27 | ::: tip 28 | Craft がパスワードを忘れた際のページを自動的に作成することはありません。あなた自身がテンプレートにリンクを設定するだけです。そのため、パスワードリセットフローの他のページとは異なり、このページのパスにコンフィグ設定をセットする必要はありません(例: および )。 29 | ::: 30 | -------------------------------------------------------------------------------- /ja/dev/examples/integrating-disqus.md: -------------------------------------------------------------------------------- 1 | # Disqus の統合 2 | 3 | [Disqus](https://disqus.com/) のようなサードパーティのコメントサービスを利用して、Craft のエントリページに簡単にコメント機能を追加することができます。 4 | 5 | これを行うためには、コメントを許可する単一のエントリを表示するための出力設定が必要です。この例では、`templates/_entry.twig` にあるテンプレートを使用します。 6 | 7 | あなたは Disqus にサインアップし、Disqus のサイトの「Admin → Settings → Install」からユニバーサルコードを入手できるでしょう。Disqus には意図したポストへのコメントを保証するために使うことができる、規定のコンフィグ変数があります。次のコメントを探してください。 8 | 9 | ```javascript 10 | /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */ 11 | ``` 12 | 13 | 次の行を追加します。 14 | 15 | ```javascript 16 | var disqus_identifier = 'blog-{{ entry.id }}'; 17 | ``` 18 | 19 | コメント機能を含む最終的なエントリのテンプレートは次のようになります。 20 | 21 | ```twig 22 | {% block blog %} 23 |

{{ entry.title }}

24 | 25 | {{ entry.body|raw }} 26 | 27 |
28 | 41 | 42 | 43 | comments powered by Disqus 44 | {% endblock %} 45 | ``` 46 | 47 | -------------------------------------------------------------------------------- /ja/dev/examples/login-form.md: -------------------------------------------------------------------------------- 1 | # ログインフォーム 2 | 3 | サイトのフロントエンドからユーザーのログインが必要な場合、次のコードで実現できます。 4 | 5 | ```twig 6 |
7 | {{ csrfInput() }} 8 | {{ actionInput('users/login') }} 9 | 10 |

11 | 13 | 14 |

15 | 16 | 17 | 21 | 22 | 23 | 24 | {% if errorMessage is defined %} 25 |

{{ errorMessage }}

26 | {% endif %} 27 |
28 | 29 |

Forget your password?

30 | ``` 31 | 32 | `craft.session.returnUrl` には、このログインフォームへリダイレクトした `{% requireLogin %}` タグを含む元の URL がセットされます。 33 | 34 | デフォルトでは、ユーザーがログイン後にコンフィグ設定 `postLoginRedirect` の値に基づきリダイレクトされます。`redirect` パラメータを利用して、ログインフォーム内で設定を上書きすることもできます。 35 | 36 | ```twig 37 | {{ redirectInput('some/custom/path') }} 38 | ``` 39 | 40 | -------------------------------------------------------------------------------- /ja/dev/examples/rss-feed.md: -------------------------------------------------------------------------------- 1 | # RSS フィード 2 | 3 | 次のテンプレートは、あなたのサイトで RSS 2.0 フィードを提供するために使用できます。`siteDescription` と呼ばれるフィールドを持つ、`globals` というハンドルの[グローバルのセット](../../globals.md)があることを前提としています。 4 | 5 | ::: tip 6 | ファイル拡張子 `.rss` で終わるテンプレートとして保存すると、Craft はそれを MIME タイプ `application/rss+xml` で配信します。 7 | ::: 8 | 9 | ```twig 10 | 11 | 12 | 13 | {{ siteName }} 14 | {{ siteUrl }} 15 | 16 | {{ globals.siteDescription }} 17 | en-us 18 | {{ now|rss }} 19 | {{ now|rss }} 20 | 21 | {% for entry in craft.entries.all() %} 22 | 23 | {{ entry.title }} 24 | {{ entry.url }} 25 | {{ entry.postDate|rss }} 26 | {{ entry.author }} 27 | {{ entry.url }} 28 | 31 | 32 | {% endfor %} 33 | 34 | 35 | ``` 36 | 37 | -------------------------------------------------------------------------------- /ja/dev/examples/search-form.md: -------------------------------------------------------------------------------- 1 | # 検索フォーム 2 | 3 | 検索フォームを作成するには、はじめに入力項目 `search` を含む通常の HTML を作成します。 4 | 5 | ```twig 6 |
7 | 8 | 9 |
10 | ``` 11 | 12 | 次に、フォームの送信先にあたるテンプレート(例:`search/results.twig`)で `GET` / `POST` データから検索クエリを取り出し、それを `search` [エントリクエリパラメータ](../element-queries/entry-queries.md#search)に渡します。 13 | 14 | ```twig 15 |

Search Results

16 | 17 | {% set searchQuery = craft.app.request.getParam('q') %} 18 | {% set entries = craft.entries() 19 | .search(searchQuery) 20 | .orderBy('score') 21 | .all() %} 22 | 23 | {% if entries|length %} 24 |

{{ entries|length }} results:

25 | 26 | 31 | {% else %} 32 |

Your search for “{{ searchQuery }}” didn’t return any results.

33 | {% endif %} 34 | ``` 35 | -------------------------------------------------------------------------------- /ja/dev/examples/set-password-form.md: -------------------------------------------------------------------------------- 1 | # パスワードの設定フォーム 2 | 3 | ユーザーがパスワードを忘れたとき、Craft は新しいパスワードを設定するための URL をメールで送信します。その URL は、コンフィグ設定の で定義され、デフォルトでは「setpassword」となります。 4 | 5 | サイトのフロントエンドでパスワードのリセットをサポートしたい場合、コンフィグ設定の「setPasswordPath」で指定されたパスにテンプレートを作成する必要があります。 6 | 7 | そのテンプレートに、次のコードを記述します。 8 | 9 | ```twig 10 |
11 | {{ csrfInput() }} 12 | {{ actionInput('users/set-password') }} 13 | {{ hiddenInput('code', code) }} 14 | {{ hiddenInput('id', id) }} 15 | 16 |

17 | 18 | {% if errors is defined %} 19 |
    20 | {% for error in errors %} 21 |
  • {{ error }}
  • 22 | {% endfor %} 23 |
24 | {% endif %} 25 | 26 | 27 |
28 | ``` 29 | 30 | ユーザーがログインに成功すると、コンフィグ設定 で定義されたパスにリダイレクトされます。 31 | -------------------------------------------------------------------------------- /ja/dev/examples/user-registration-form.md: -------------------------------------------------------------------------------- 1 | # ユーザー登録フォーム 2 | 3 | Craft Pro を使用し、サイトで誰でもユーザーアカウントを登録できるようにしたい場合は、はじめに「設定 > ユーザー > 設定」に移動し、「一般登録を許可しますか?」設定にチェックが入っていることを確認します。 4 | 5 | そして、次のようなフロントエンドの登録フォームを作成します。 6 | 7 | ```twig 8 |
9 | {{ csrfInput() }} 10 | {{ actionInput('users/save-user') }} 11 | {{ redirectInput('') }} 12 | 13 | {% macro errorList(errors) %} 14 | {% if errors %} 15 |
    16 | {% for error in errors %} 17 |
  • {{ error }}
  • 18 | {% endfor %} 19 |
20 | {% endif %} 21 | {% endmacro %} 22 | 23 |

24 | 26 | 27 | {% if user is defined %} 28 | {{ _self.errorList(user.getErrors('username')) }} 29 | {% endif %} 30 | 31 |

32 | 34 | 35 | {% if user is defined %} 36 | {{ _self.errorList(user.getErrors('email')) }} 37 | {% endif %} 38 | 39 |

40 | 41 | 42 | {% if user is defined %} 43 | {{ _self.errorList(user.getErrors('password')) }} 44 | {% endif %} 45 | 46 | 47 |
48 | ``` 49 | 50 | -------------------------------------------------------------------------------- /ja/dev/headless.md: -------------------------------------------------------------------------------- 1 | # ヘッドレス化 2 | 3 | Craft のテンプレートシステムは、Craft のコンテンツを取得する唯一の方法ではありません。 4 | 5 | Craft を通常のウェブサイト(または、それに加える)の代わりにコンテンツ API として動作するという意味でのヘッドレス CMS として使用する場合、いくつかの方法があります。 6 | 7 | ::: tip 8 | Craft をヘッドレス CMS として使用する方法について学ぶために、CraftQuest の [Headless Craft CMS](https://craftquest.io/courses/headless-craft) コースをチェックしてください。 9 | ::: 10 | 11 | ## GraphQL 12 | 13 | Mark Huot 氏による [CraftQL](https://github.com/markhuot/craftql) プラグンは、設定なしの [GraphQL](https://graphql.org/) サーバーをインストールされた Craft に追加します。 14 | 15 | ## JSON API 16 | 17 | ファーストパーティの [Element API](https://github.com/craftcms/element-api) は、コンテンツのための読み取り専用の [JSON API](http://jsonapi.org/) を作成する簡単な方法です。 18 | 19 | ## REST API 20 | 21 | Craft で REST API を作成する方法を詳しく知るために、Nate Iler 氏の Dot All 2017 のプレゼンテーション [How to Create a Full REST API](http://dotall.com/sessions/how-to-create-a-full-rest-api-with-craft-3) を見てください。 22 | 23 | ## カスタムなもの 24 | 25 | モジュールやプラグインは、新しい HTTP エンドポイントを提供するためのカスタムのフロントエンド[コントローラー](https://www.yiiframework.com/doc/guide/2.0/en/structure-controllers)を定義できます。 はじめるには、[Craft の拡張](../extend/README.md)を参照してください。 26 | -------------------------------------------------------------------------------- /ja/dev/tags.md: -------------------------------------------------------------------------------- 1 | # タグ 2 | 3 | [Twig に付随する](https://twig.symfony.com/doc/tags/index.html)テンプレートタグに加えて、Craft がいくつか独自のものを提供します。 4 | 5 | - [cache](tags/cache.md) 6 | - [css](tags/css.md) 7 | - [exit](tags/exit.md) 8 | - [header](tags/header.md) 9 | - [hook](tags/hook.md) 10 | - [js](tags/js.md) 11 | - [nav](tags/nav.md) 12 | - [paginate](tags/paginate.md) 13 | - [redirect](tags/redirect.md) 14 | - [requireLogin](tags/requirelogin.md) 15 | - [requirePermission](tags/requirepermission.md) 16 | - [switch](tags/switch.md) 17 | -------------------------------------------------------------------------------- /ja/dev/tags/css.md: -------------------------------------------------------------------------------- 1 | # `{% css %}` タグ 2 | 3 | `{% css %}` タグは、ページの `` に `