Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Craft 3 deprecation errors #11

Merged
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
4 changes: 4 additions & 0 deletions src/UserManual.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,14 @@ protected function settingsHtml(): string
];
}

// Get override settings from config file.
$overrides = Craft::$app->getConfig()->getConfigFromFile(strtolower($this->handle));

return Craft::$app->view->renderTemplate(
'usermanual/settings',
[
'settings' => $this->getSettings(),
'overrides' => array_keys($overrides),
'options' => $options,
'siteTemplatesPath' => Craft::$app->getPath()->getSiteTemplatesPath(),
]
Expand Down
4 changes: 2 additions & 2 deletions src/templates/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
{% set title = craft.userManual.name|t %}
{% set sidebar %}
<nav>
{% set help = craft.entries.sectionId(sectionSelected) %}
{% set help = craft.entries.sectionId(sectionSelected).all() %}
<ul>
{% nav page in help %}
{% set active = page.slug == craft.request.lastSegment or loop.first and craft.request.lastSegment == 'usermanual' %}
{% set active = page.slug == craft.app.request.segments|last or loop.first and craft.app.request.segments|last == 'usermanual' %}
<li>
<a {% if active %}class="sel"{% endif %}
href="{{ url('usermanual/' ~ page.uri) }}">
Expand Down
10 changes: 5 additions & 5 deletions src/templates/settings.twig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

{% from _self import configWarning %}

{% set configOverride = craft.config.get('pluginNameOverride', 'usermanual') is not null %}
{% set configOverride = 'pluginNameOverride' in overrides %}
{{ forms.textField({
label: "Plugin Name"|t,
id: 'pluginNameOverride',
Expand All @@ -38,7 +38,7 @@
readonly: configOverride,
})}}

{% set configOverride = craft.config.get('section', 'usermanual') is not null %}
{% set configOverride = 'section' in overrides %}
{% set inputMacro = configOverride ? 'textField' : 'selectField' %}
{% set opts = {
label: "User Manual Section"|t,
Expand All @@ -47,7 +47,7 @@
instructions: 'Entries in this section must have associated urls.'|t,
value: settings.section,
options: options,
warning: configOverride ? configWarning('pluginNameOverride'),
warning: configOverride ? configWarning('section'),
disabled: configOverride,
readonly: configOverride,
} %}
Expand All @@ -57,7 +57,7 @@
For more control over the output, you may optionally override the default template.<br>
Path is relative to <code>{{ siteTemplatesPath }}</code>.
{% endset %}
{% set configOverride = craft.config.get('templateOverride', 'usermanual') is not null %}
{% set configOverride = 'templateOverride' in overrides %}

{{ forms.textField({
label: "Template Override"|t,
Expand All @@ -67,7 +67,7 @@ Path is relative to <code>{{ siteTemplatesPath }}</code>.
instructions: instructions|raw,
value: settings.templateOverride,
errors: '',
warning: configOverride ? configWarning('pluginNameOverride'),
warning: configOverride ? configWarning('templateOverride'),
disabled: configOverride,
readonly: configOverride,
})}}