Hallo zusammen,
ich bin neu in der Plugin-Entwicklung, daher sorry für die Frage...
Ich möchte ein einfaches Plugin entwickeln, welches den Blog-Dialog im Backend mit einem zusätzlichen Tab versieht, auf dem weitere Informationen eingegeben werden sollen. Im folgenden der relevante Quellcode zur Erzeugung des Tabs. Ich habe mich an den Tutorials im Developer-Bereich orientiert. Aus mir absolut nicht verständlichen Gründen erscheint nach Aktivieren des Plugins nun beim Aufruf des Menüpunktes "Inhalte > Blog" folgende Fehlermeldung:
SyntaxError: Unexpected token :
at http://dev.midevelop.de/engine/Library/ExtJs/ext-all.js?201611151410:21:5361
at Object.Ext.globalEval (http://dev.midevelop.de/engine/Library/ExtJs/ext-all.js?201611151410:21:5369)
at Object.success (http://dev.midevelop.de/backend/base?file=bootstrap&loggedIn=1479396099:477:5)
at Object.callback (http://dev.midevelop.de/engine/Library/ExtJs/ext-all.js?201611151410:21:67496)
at i.onComplete (http://dev.midevelop.de/engine/Library/ExtJs/ext-all.js?201611151410:21:422670)
at i.onStateChange (http://dev.midevelop.de/engine/Library/ExtJs/ext-all.js?201611151410:21:422314)
at XMLHttpRequest.<anonymous> (http://dev.midevelop.de/engine/Library/ExtJs/ext-all.js?201611151410:21:17406)
Nachdem ich jetzt zig Stunden in die Fehlersuche gesteckt habe, bin ich so langsam mit meinem Latein am Ende. Ich hoffe, hier kann mir jemand auf die Sprünge helfen...
Danke!!!
Mathias
MdevBlogEssentials.php:
<?php
namespace MdevBlogEssentials;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Shopware\Components\Plugin\Context\InstallContext;
class MdevBlogEssentials extends \Shopware\Components\Plugin
{
public function install(InstallContext $context)
{
}
public function update(UpdateContext $context)
{
$context->scheduleClearCache(InstallContext::CACHE_LIST_DEFAULT);
}
public function activate(ActivateContext $context)
{
$context->scheduleClearCache(InstallContext::CACHE_LIST_DEFAULT);
}
public function deactivate(DeactivateContext $context)
{
$context->scheduleClearCache(InstallContext::CACHE_LIST_DEFAULT);
}
public function uninstall(UninstallContext $context)
{
}
public function build(ContainerBuilder $container)
{
$container->setParameter('MdevBlogEssentials.PluginDir', $this->getPath());
parent::build($container);
}
public static function getSubscribedEvents()
{
return [
'Enlight_Controller_Action_PostDispatchSecure_Backend_Blog' => 'extendBlogDetails'
];
}
public function extendBlogDetails(\Enlight_Event_EventArgs $args)
{
$extendBlogDetails = $this->container->get('Mdev.BlogEssentials.ExtendBlogDetails');
$extendBlogDetails->execute($args);
}
}
ExtendBlogDetails.php:
<?php
namespace MdevBlogEssentials;
class ExtendBlogDetails
{
private $pluginDir;
public function __construct($pluginDir)
{
$this->pluginDir = $pluginDir;
}
public function execute(\Enlight_Controller_EventArgs $args)
{
$controller = $args->getSubject();
$view = $controller->View();
$view->addTemplateDir(
$this->pluginDir . '/Resources/Views/'
);
$request = $controller->Request();
if ($request->getActionName() == 'index') {
$view->extendsTemplate('backend/ExtendBlog/app.js');
}
if ($request->getActionName() == 'load') {
$view->extendsTemplate('backend/ExtendBlog/view/window.js');
}
}
}
plugin.xml:
<?xml version="1.0" encoding="utf-8"?>
<plugin xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/shopware/shopware/5.2/engine/Shopware/Components/Plugin/schema/plugin.xsd">
<label lang="de">Blog Essentials</label>
<label lang="en">Blog Essentials</label>
<version>0.1.1</version>
<link></link>
<author>Mathias Mittelhäuser</author>
<compatibility minVersion="5.2.0" />
<changelog version="0.1.1">
<changes lang="de">In Entwicklung</changes>
<changes lang="en">In Development</changes>
</changelog>
</plugin>
Resources/services.xml:
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="Mdev.BlogEssentials.ExtendBlogDetails" class="MdevBlogEssentials\ExtendBlogDetails">
<argument type="string">%MdevBlogEssentials.PluginDir%</argument>
</service>
</services>
</container>
Resources/Views/backend/ExtendBlog/app.js:
//{block name="backend/blog/view/blog/app" append}
// {include file="backend/ExtendBlog/view/tab.js"}
//{/block}
Resources/Views/backend/ExtendBlog/view/tab.js:
Ext.define('Mdev.BlogEssentials.ExtendBlog.view.Tab', {
extend: 'Ext.panel.Panel',
border: false,
alias: 'widget.blog-blog-detail-essentials',
region: 'center',
autoScroll:false,
layout: 'border',
ui: 'shopware-ui',
initComponent: function() {
var me = this;
me.callParent(arguments);
}
});
Resources/Views/backend/ExtendBlog/view/window.js:
//{block name="backend/blog/view/blog/window" append}
Ext.define('Mdev.BlogEssentials.ExtendBlog.view.Window', {
override: 'Shopware.apps.Blog.view.blog.Window',
initComponent:function () {
var me = this;
me.callParent(arguments);
},
getTabs: function() {
var me = this;
var result = me.callParent();
result.push(
{
xtype: 'blog-blog-detail-essentials',
title: 'Hallo Welt!!!'
}
);
return result;
}
});
//{/block}