1

I'm trying to create a craft plugin but I have problems with rendering the settings.

Right now I used the same way like here so this is my plugin code

<?php
namespace Craft;

class testPlugin extends BasePlugin
{


    function getName()
    {
        return Craft::t('Test');
    }

    public function getVersion()
    {
        return '0.1';
    }

    public function getDeveloper()
    {
        return 'Secondred Newmedia GmbH';
    }

    public function getDeveloperUrl()
    {
        return 'http://www.secondred.de';
    }

    public function getSourceLanguage()
    {
        return 'de';
    }

    protected function defineSettings()
    {
        return array(
            'accountID' => array(AttributeType::Mixed)
        );
    }

    public function getSettingsHtml()
    {
        return craft()->templates->render('test/tools/config', array(
            'settings' => $this->getSettings()
        ));
    }

    public function hasCpSection()
    {
        return false;
    }
}

And this is my config.twig

{% extends "_layouts/cp" %}
{% import "_includes/forms" as forms %}

{% set page = 'Settings'|t %}
{% set title = 'Settings'|t %}

{% set content %}
    <div class="pane">
        <p>Hello Craft</p>
    </div>

{% endset %}

But it always ends up like this enter image description here The menu is always rendered inside my plugin Settings and If I just use

public function getSettingsUrl()
{
    return 'test/tools/configuration';
}

the template is rendered correctly but I can't pass my variables anymore (of course in that example there are no, but I use some in my real plugin I just didn't want to show you 1000 lines of unneeded code) .

Could you please tell me what I'm doing wrong? My actual real plugin is nearly ready and this is the last error I have to fix but I don't know how. I need your help thank you very much.

2

Just remove the extends and set content. The settings twig-code is rendered in a container inside the CP anyways:

{% import "_includes/forms" as forms %}

<p>Hello Craft</p>
|improve this answer|||||
  • Since I can't upvote your post I'll do it in this way, thank you very much. – Robin Schambach Oct 5 '16 at 8:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.