diff --git a/.craftplugin b/.craftplugin new file mode 100644 index 0000000..84cc4de --- /dev/null +++ b/.craftplugin @@ -0,0 +1 @@ +{"pluginName":"usermanual","pluginDescription":"Craft User Manual allows developers (or even content editors) to provide CMS documentation using Craft's built-in sections (singles, channels, or structures) to create a 'User Manual' or 'Help' section directly in the control panel.","pluginVersion":"2.0.0","pluginAuthorName":"Rob Erskine","pluginVendorName":"hillholliday","pluginAuthorUrl":"https://twitter.com/erskinerob","pluginAuthorGithub":"hillholliday","codeComments":"","pluginComponents":["settings","twigextensions","variables"],"consolecommandName":"","controllerName":"","cpsectionName":"","elementName":"","fieldName":"","modelName":"","purchasableName":"","recordName":"","serviceName":"","taskName":"","utilityName":"","widgetName":"","apiVersion":"api_version_3_0"} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..bde3e77 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +; top-most EditorConfig file +root = true + +; Unix-style newlines +[*] +indent_style = space +indent_size = 2 +end_of_line = LF +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.php] +indent_style = space +indent_size = 4 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a17970c --- /dev/null +++ b/.gitignore @@ -0,0 +1,32 @@ +# CRAFT ENVIRONMENT +.env.php +.env.sh +.env + +# COMPOSER +/vendor + +# BUILD FILES +/bower_components/* +/node_modules/* +/build/* +/yarn-error.log + +# MISC FILES +.cache +.DS_Store +.idea +.project +.settings +*.esproj +*.sublime-workspace +*.sublime-project +*.tmproj +*.tmproject +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +config.codekit3 +prepros-6.config diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..74cebcb --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,9 @@ +# usermanual Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). + +## 2.0.0 - 2018-08-24 +### Added +- Initial Craft 3 release diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..96a4c99 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,9 @@ +The MIT License (MIT) + +Copyright (c) 2018 Rob Erskine + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index 5102121..5e8e7e0 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,67 @@ -# Craft User Manual +# Craft User Manual plugin for Craft CMS 3.x Craft User Manual allows developers (or even content editors) to provide CMS documentation using Craft's built-in sections (singles, channels, or structures) to create a "User Manual" or "Help" section directly in the control panel. -![How it works](http://cl.ly/image/2a3g0J3h3d3j/Craft-User-Manual-2.5.jpg) +![Screenshot](resources/img/screenshot.jpg) ---- +## Requirements + +This plugin requires Craft CMS 3.0.0-beta.23 or later. ## Installation -1. Copy the included **usermanual** folder into craft/plugins. -2. Navigate to Plugins in the Craft CP. -3. Click the Install button in the row for the **User Manual** plugin. + +To install the plugin, follow these instructions. + +1. Open your terminal and go to your Craft project: + + cd /path/to/project + +2. Then tell Composer to load the plugin: + + composer require hillholliday/usermanual + +3. In the Control Panel, go to Settings → Plugins and click the “Install” button for usermanual. + 4. Select the section the plugin should use as the **User Manual** page in the CP. * (Optional) - Replace the plugin's name to something your user's will understand. * (Optional) - Use more than the default `body` fieldhandle by setting up custom template overrides. + 5. Click the **User Manual** link in the CP nav. +## Configuration + +* All settings may be optionally configured using a [config file](http://buildwithcraft.com/docs/plugins/plugin-settings#config-file). The values, contained in [`config.php`](https://github.com/hillholliday/Craft-User-Manual/blob/master/usermanual/config.php), are described below: + + +### pluginNameOverride +Intuitive, human-readable plugin name for the end user. + + +### templateOverride +For more control over the output, you may optionally override the default template. + +Path is relative to ../craft/templates/. + + +### section +Entries in this section must have associated urls. + ## Some notes * The plugin currently only pulls in the `body` field from each entry in the selected section, unless you're using a template override. * While the **User Manual** section works best with `Structures`, you can certainly get away with using a one-off `Single`. * If you're running _Craft Client_ or _Craft Pro_ make sure your content editors don't have permission to edit whatever section you've selected to use as your **User Manual** * Only sections with entry URLs may be used as your **User Manual** section. -* All settings may be optionally configured using a [config file](http://buildwithcraft.com/docs/plugins/plugin-settings#config-file). See [`config.php`](https://github.com/hillholliday/Craft-User-Manual/blob/master/usermanual/config.php) for possible values. ## Thanks This plugin was inspired by the team over at [70kft](http://70kft.com/) for their work on [Craft-Help](https://github.com/70kft/craft-help). While their plugin is definitely more flexible in terms of writing custom markdown in separate files, we wanted to create something that would make it easier for anyone to edit documentation without making any changes to the server. This works particularly well for larger projects where more than one person (especially non-devs) are writing documentation for how to use the CMS. ## Releases +* **2.0.0** - Craft3 version of Craft User Manual. * **1.1.1** - Adding in RTL language support * **1.1.0** - Merging in @timkelty's work which includes template overrides, updated error prompts, and other misc improvements * **1.0.1** - Adding support for plugin custom icons in Craft 2.5 * **1.0.0** - Initital release of Craft User Manual. We hope this plugin is useful, and we'd love to hear any suggestions or issues you may have. [@erskinerob](https://twitter.com/erskinerob). + +Brought to you by [Rob Erskine](https://twitter.com/erskinerob) diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..ff603e4 --- /dev/null +++ b/composer.json @@ -0,0 +1,40 @@ +{ + "name": "hillholliday/Craft-User-Manual", + "description": "Craft User Manual allows developers (or even content editors) to provide CMS documentation using Craft's built-in sections (singles, channels, or structures) to create a `User Manual` or `Help` section directly in the control panel.", + "type": "craft-plugin", + "version": "2.0.0", + "keywords": [ + "craft", + "cms", + "craftcms", + "craft-plugin", + "usermanual" + ], + "support": { + "docs": "https://github.com/hillholliday/Craft-User-Manual/blob/master/README.md", + "issues": "https://github.com/hillholliday/Craft-User-Manual/issues" + }, + "license": "MIT", + "authors": [ + { + "name": "Rob Erskine", + "homepage": "https://twitter.com/erskinerob" + } + ], + "require": { + "craftcms/cms": "^3.0.0-RC1" + }, + "autoload": { + "psr-4": { + "hillholliday\\usermanual\\": "src/" + } + }, + "extra": { + "name": "User Manual", + "handle": "usermanual", + "hasCpSettings": true, + "hasCpSection": true, + "changelogUrl": "https://raw.githubusercontent.com/hillholliday/Craft-User-Manual/master/CHANGELOG.md", + "class": "hillholliday\\usermanual\\UserManual" + } +} diff --git a/resources/img/screenshot.jpg b/resources/img/screenshot.jpg new file mode 100644 index 0000000..88b5f94 Binary files /dev/null and b/resources/img/screenshot.jpg differ diff --git a/src/UserManual.php b/src/UserManual.php new file mode 100644 index 0000000..c0cedb5 --- /dev/null +++ b/src/UserManual.php @@ -0,0 +1,226 @@ +name = $this->getName(); + + // Register twig extensions + $this->_addTwigExtensions(); + + // Register CP routes + Event::on( + UrlManager::class, + UrlManager::EVENT_REGISTER_CP_URL_RULES, + [$this, 'registerCpUrlRules'] + ); + + // Register variables + Event::on( + CraftVariable::class, + CraftVariable::EVENT_INIT, + function (Event $event) { + /** @var CraftVariable $variable */ + $variable = $event->sender; + $variable->set('userManual', UserManualVariable::class); + } + ); + + // Plugin Install event + Event::on( + Plugins::class, + Plugins::EVENT_AFTER_INSTALL_PLUGIN, + [$this, 'afterInstallPlugin'] + ); + + Craft::info( + Craft::t( + 'usermanual', + '{name} plugin loaded', + ['name' => $this->name] + ), + __METHOD__ + ); + } + + /** + * Returns the user-facing name of the plugin, which can override the name + * in composer.json + * + * @return string + */ + public function getName() + { + $pluginName = Craft::t('usermanual', 'User Manual'); + $pluginNameOverride = $this->getSettings()->pluginNameOverride; + + return ($pluginNameOverride) + ? $pluginNameOverride + : $pluginName; + } + + public function registerCpUrlRules(RegisterUrlRulesEvent $event) + { + $rules = [ + 'usermanual/' => ['template' => 'usermanual/index'], + ]; + + $event->rules = array_merge($event->rules, $rules); + } + + public function afterInstallPlugin(PluginEvent $event) + { + $isCpRequest = Craft::$app->getRequest()->isCpRequest; + + if ($event->plugin === $this && $isCpRequest) { + Craft::$app->controller->redirect(UrlHelper::cpUrl('settings/plugins/usermanual/'))->send(); + } + } + + // Protected Methods + // ========================================================================= + + /** + * @inheritdoc + */ + protected function createSettingsModel() + { + return new Settings(); + } + + /** + * @inheritdoc + */ + protected function settingsHtml(): string + { + $options = [[ + 'label' => '', + 'value' => '', + ]]; + foreach (Craft::$app->sections->getAllSections() as $section) { + $siteSettings = Craft::$app->sections->getSectionSiteSettings($section['id']); + $hasUrls = false; + foreach ($siteSettings as $siteSetting) { + if ($siteSetting->hasUrls) { + $hasUrls = true; + } + } + + if (!$hasUrls) { + continue; + } + $options[] = [ + 'label' => $section['name'], + 'value' => $section['id'], + ]; + } + + return Craft::$app->view->renderTemplate( + 'usermanual/settings', + [ + 'settings' => $this->getSettings(), + 'options' => $options, + 'siteTemplatesPath' => Craft::$app->getPath()->getSiteTemplatesPath(), + ] + ); + } + + /** + * @inheritdoc + */ + public function getSettings() + { + $settings = parent::getSettings(); + $config = Craft::$app->config->getConfigFromFile('usermanual'); + + foreach ($settings as $settingName => $settingValue) { + $settingValueOverride = null; + foreach ($config as $configName => $configValue) { + if ($configName === $settingName) { + $settingValueOverride = $configValue; + } + } + $settings->$settingName = $settingValueOverride ?? $settingValue; + } + + // Allow handles from config + if (!is_numeric($settings->section)) { + $section = Craft::$app->getSections()->getSectionByHandle('homepage'); + if ($section) { + $settings->section = $section->id; + } + } + + return $settings; + } + + // Private Methods + // ========================================================================= + + private function _addTwigExtensions() + { + Craft::$app->view->twig->addExtension(new UserManualTwigExtension); + } +} diff --git a/src/assetbundles/usermanual/UserManualAsset.php b/src/assetbundles/usermanual/UserManualAsset.php new file mode 100644 index 0000000..916f65b --- /dev/null +++ b/src/assetbundles/usermanual/UserManualAsset.php @@ -0,0 +1,51 @@ +sourcePath = "@hillholliday/usermanual/assetbundles/usermanual/dist"; + + $this->depends = [ + CpAsset::class, + ]; + + $this->js = [ + 'js/UserManual.js', + ]; + + $this->css = [ + 'css/UserManual.css', + ]; + + parent::init(); + } +} diff --git a/usermanual/resources/css/help.css b/src/assetbundles/usermanual/dist/css/UserManual.css old mode 100755 new mode 100644 similarity index 91% rename from usermanual/resources/css/help.css rename to src/assetbundles/usermanual/dist/css/UserManual.css index 62b85d5..6855935 --- a/usermanual/resources/css/help.css +++ b/src/assetbundles/usermanual/dist/css/UserManual.css @@ -1,5 +1,17 @@ -/* - * lifted from craft-help from the super smart devs over at 70kft https://github.com/70kft/craft-help +/** + * usermanual plugin for Craft CMS + * + * usermanual CSS + * + * @author Rob Erskine + * @copyright Copyright (c) 2018 Rob Erskine + * @link https://twitter.com/erskinerob + * @package Usermanual + * @since 2.0.0 + */ + + /* + * lifted from craft-help from the super smart devs over at 70kft https://github.com/70kft/craft-help */ #user-manual { diff --git a/src/assetbundles/usermanual/dist/img/UserManual-icon.svg b/src/assetbundles/usermanual/dist/img/UserManual-icon.svg new file mode 100644 index 0000000..c8afbcd --- /dev/null +++ b/src/assetbundles/usermanual/dist/img/UserManual-icon.svg @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assetbundles/usermanual/dist/js/UserManual.js b/src/assetbundles/usermanual/dist/js/UserManual.js new file mode 100644 index 0000000..a4366fd --- /dev/null +++ b/src/assetbundles/usermanual/dist/js/UserManual.js @@ -0,0 +1,11 @@ +/** + * usermanual plugin for Craft CMS + * + * usermanual JS + * + * @author Rob Erskine + * @copyright Copyright (c) 2018 Rob Erskine + * @link https://twitter.com/erskinerob + * @package Usermanual + * @since 2.0.0 + */ diff --git a/src/config.php b/src/config.php new file mode 100644 index 0000000..e51ccde --- /dev/null +++ b/src/config.php @@ -0,0 +1,32 @@ + null, + 'templateOverride' => null, + 'section' => null, // section ID (int) or handle (string) +]; diff --git a/usermanual/resources/icon-mask.svg b/src/icon-mask.svg similarity index 100% rename from usermanual/resources/icon-mask.svg rename to src/icon-mask.svg diff --git a/usermanual/resources/icon.svg b/src/icon.svg similarity index 100% rename from usermanual/resources/icon.svg rename to src/icon.svg diff --git a/src/models/Settings.php b/src/models/Settings.php new file mode 100644 index 0000000..e05a003 --- /dev/null +++ b/src/models/Settings.php @@ -0,0 +1,59 @@ + + {% set help = craft.entries.sectionId(sectionSelected) %} + + +{% endset %} + +{% set content %} +
+ {{ getHelpDocument(sectionSelected)|raw }} +
+{% endset %} diff --git a/usermanual/templates/settings.html b/src/templates/settings.twig old mode 100755 new mode 100644 similarity index 56% rename from usermanual/templates/settings.html rename to src/templates/settings.twig index 32f6556..17487b5 --- a/usermanual/templates/settings.html +++ b/src/templates/settings.twig @@ -1,9 +1,24 @@ +{# @var craft \craft\web\twig\variables\CraftVariable #} +{# +/** + * usermanual plugin for Craft CMS 3.x + * + * usermanual Settings.twig + * + * @author Rob Erskine + * @copyright Copyright (c) 2018 Rob Erskine + * @link https://twitter.com/erskinerob + * @package Usermanual + * @since 2.0.0 + */ +#} + {% import "_includes/forms" as forms %} {% macro configWarning(setting, file) -%} - {{ "This is being overridden by the {setting} config setting."|t({ - setting: ''~setting~'' - })|raw }} + {{ "This is being overridden by the {setting} config setting."|t({ + setting: ''~setting~'' + })|raw }} {%- endmacro %} {% from _self import configWarning %} @@ -19,22 +34,22 @@ first: true, errors: '', warning: configOverride ? configWarning('pluginNameOverride'), - disabled: configOverride, - readonly: configOverride, + disabled: configOverride, + readonly: configOverride, })}} {% set configOverride = craft.config.get('section', 'usermanual') is not null %} {% set inputMacro = configOverride ? 'textField' : 'selectField' %} {% set opts = { - label: "User Manual Section"|t, - id: 'section', - name: 'section', - instructions: 'Entries in this section must have associated urls.'|t, - value: settings.section, - options: options, - warning: configOverride ? configWarning('pluginNameOverride'), - disabled: configOverride, - readonly: configOverride, + label: "User Manual Section"|t, + id: 'section', + name: 'section', + instructions: 'Entries in this section must have associated urls.'|t, + value: settings.section, + options: options, + warning: configOverride ? configWarning('pluginNameOverride'), + disabled: configOverride, + readonly: configOverride, } %} {{ configOverride ? forms.textField(opts) : forms.selectField(opts) }} @@ -52,7 +67,7 @@ instructions: instructions|raw, value: settings.templateOverride, errors: '', - warning: configOverride ? configWarning('pluginNameOverride'), - disabled: configOverride, - readonly: configOverride, + warning: configOverride ? configWarning('pluginNameOverride'), + disabled: configOverride, + readonly: configOverride, })}} diff --git a/src/translations/en/usermanual.php b/src/translations/en/usermanual.php new file mode 100644 index 0000000..fb9debc --- /dev/null +++ b/src/translations/en/usermanual.php @@ -0,0 +1,21 @@ + 'usermanual plugin loaded', +]; diff --git a/src/twigextensions/UserManualTwigExtension.php b/src/twigextensions/UserManualTwigExtension.php new file mode 100644 index 0000000..acad6d1 --- /dev/null +++ b/src/twigextensions/UserManualTwigExtension.php @@ -0,0 +1,105 @@ +getSettings(); + $query = Entry::find(); + + $segments = Craft::$app->request->segments; + $segment = end($segments); + $sectionId = $settings->section; + + if (count($segments) === 1 && $segment === 'usermanual') { + $slug = null; + } else { + $slug = $segment; + } + + $criteria = [ + 'sectionId' => $sectionId, + 'slug' => $slug, + ]; + + Craft::configure($query, $criteria); + $entry = $query->one(); + + // If the app has not been set up at all or there are no entires, + // redirect to the settings page + if (!$sectionId || !$entry) { + Craft::$app->controller->redirect(UrlHelper::cpUrl('settings/plugins/usermanual/'))->send(); + } else { + if ($settings->templateOverride) { + // Setting the mode also sets the templatepath to the default for that mode + Craft::$app->view->setTemplateMode(View::TEMPLATE_MODE_SITE); + $template = $settings->templateOverride; + } else { + $template = 'usermanual/_body.twig'; + } + + $output = Craft::$app->view->renderTemplate($template, [ + 'entry' => $entry, + ]); + + // Ensure template mode is set back to control panel + Craft::$app->view->setTemplateMode(View::TEMPLATE_MODE_CP); + + return $output; + } + } +} diff --git a/src/variables/UserManualVariable.php b/src/variables/UserManualVariable.php new file mode 100644 index 0000000..62f86c3 --- /dev/null +++ b/src/variables/UserManualVariable.php @@ -0,0 +1,43 @@ +getName(); + + return $name; + } + + public function getSettings() + { + $settings = UserManual::$plugin->getSettings(); + + return $settings; + } +} diff --git a/usermanual/UserManualPlugin.php b/usermanual/UserManualPlugin.php deleted file mode 100644 index c28fb30..0000000 --- a/usermanual/UserManualPlugin.php +++ /dev/null @@ -1,104 +0,0 @@ -getSettings()->pluginNameOverride; - - return ($pluginNameOverride) ? $pluginNameOverride : $pluginName; - } - - public function getVersion() - { - return '1.1.1'; - } - - public function getDeveloper() - { - return 'Hill Holliday'; - } - - public function getDeveloperUrl() - { - return 'http://hhcc.com'; - } - - public function hasCpSection() - { - return true; - } - - public function addTwigExtension() - { - Craft::import('plugins.usermanual.twigextensions.UserManualTwigExtension'); - - return new UserManualTwigExtension(); - } - - public function registerCpRoutes() - { - return [ - 'usermanual/(?P[a-zéñåA-Z0-9\-\_\/]+)' => 'usermanual/index', - ]; - } - - protected function defineSettings() - { - return [ - 'pluginNameOverride' => AttributeType::String, - 'templateOverride' => AttributeType::Template, - 'section' => AttributeType::Number, - ]; - } - - public function getSettingsHtml() - { - $options = [[ - 'label' => '', - 'value' => '', - ]]; - - foreach (craft()->sections->getAllSections() as $section) { - if (!$section->hasUrls) { - continue; - } - $options[] = [ - 'label' => $section['name'], - 'value' => $section['id'], - ]; - } - - return craft()->templates->render('usermanual/settings', [ - 'settings' => $this->getSettings(), - 'options' => $options, - 'siteTemplatesPath' => craft()->path->getSiteTemplatesPath(), - ]); - } - - public function onAfterInstall() - { - craft()->request->redirect(UrlHelper::getCpUrl('settings/plugins/usermanual/')); - } - - public function getSettings() - { - $settings = parent::getSettings(); - foreach ($settings as $name => $value) { - $configValue = craft()->config->get($name, 'usermanual'); - $settings->$name = is_null($configValue) ? $value : $configValue; - } - - // Allow handles from config - if (!is_numeric($settings->section)) { - $section = craft()->sections->getSectionByHandle('homepage'); - if ($section) { - $settings->section = $section->id; - } - } - return $settings; - } -} diff --git a/usermanual/config.php b/usermanual/config.php deleted file mode 100644 index c2e61ae..0000000 --- a/usermanual/config.php +++ /dev/null @@ -1,6 +0,0 @@ - null, - 'templateOverride' => null, - 'section' => null, // section ID (int) or handle (string) -]; diff --git a/usermanual/templates/index.html b/usermanual/templates/index.html deleted file mode 100644 index a64f39c..0000000 --- a/usermanual/templates/index.html +++ /dev/null @@ -1,33 +0,0 @@ -{% extends "_layouts/cp" %} - -{% set sectionSelected = (craft.userManual.settings.section is defined) ? craft.userManual.settings.section : "Homepage" %} -{% set title = craft.userManual.name|t %} - -{% set sidebar %} - -{% endset %} - -{% set content %} - {% includeCssResource('usermanual/css/help.css') %} -
- {{ getHelpDocument(sectionSelected)|raw }} -
-{% endset %} diff --git a/usermanual/twigextensions/UserManualTwigExtension.php b/usermanual/twigextensions/UserManualTwigExtension.php deleted file mode 100755 index 09dabbc..0000000 --- a/usermanual/twigextensions/UserManualTwigExtension.php +++ /dev/null @@ -1,61 +0,0 @@ - new Twig_Function_Method($this, 'getHelpDocument'), - ); - } - - public function getHelpDocument() - { - $oldPath = craft()->path->getTemplatesPath(); - $newPath = craft()->path->getPluginsPath().'usermanual/templates/'; - $template = '_body.html'; - $settings = craft()->plugins->getPlugin('usermanual')->getSettings(); - $segments = craft()->request->segments; - $segment = end($segments); - $sectionId = $settings->section; - - $criteria = craft()->elements->getCriteria(ElementType::Entry); - $criteria->sectionId = $sectionId; - $criteria->slug = $segment; - - if (!$criteria->total()) { - $criteria->slug = null; - } - - $entry = $criteria->first(); - - // If the app has not been set up at all or there are no entires, redirect to the settings page - if (!$sectionId || !$entry) { - craft()->request->redirect(UrlHelper::getCpUrl('settings/plugins/usermanual/')); - } else { - if ($settings->templateOverride) { - $newPath = craft()->path->getSiteTemplatesPath(); - $template = $settings->templateOverride; - } - - craft()->path->setTemplatesPath($newPath); - - $output = craft()->templates->render($template, [ - 'entry' => $entry, - ]); - craft()->path->setTemplatesPath($oldPath); - - return $output; - } - } -} diff --git a/usermanual/variables/UserManualVariable.php b/usermanual/variables/UserManualVariable.php deleted file mode 100644 index 4080f01..0000000 --- a/usermanual/variables/UserManualVariable.php +++ /dev/null @@ -1,18 +0,0 @@ -plugins->getPlugin('usermanual')->getSettings(); - } - - public function getName() - { - $plugin = craft()->plugins->getPlugin('usermanual'); - - return $plugin->getName(); - } -}