Skip to content

Commit

Permalink
Merge pull request #11 from Upstatement/10-fix-craft-3-deprecation-er…
Browse files Browse the repository at this point in the history
…rors

Fix Craft 3 deprecation errors
  • Loading branch information
mcclaskiem authored Sep 19, 2018
2 parents 5b4a2a8 + 7630522 commit 00e2808
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
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,
})}}

0 comments on commit 00e2808

Please sign in to comment.