2

I'm aware that I could enable the plugin to have it's own CP section, but I don't feel that this would be the right place for it to live due to its nature, when you view the settings page it wouldn't be a list of inputs, it would be a table view.

Ideally the plugin page would reside in settings > plugins > myPlugin but have the same template as a plugin with a CP section, just like the sections settings page.

This is my template in pluginHandle/settings.html

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

{% set title = "My Plugin" %}

{% set content %}
  Some content should appear here maybe?
{% endset %}

I don't get any errors when I view the page it just looks like this:

Plugin settings page

As you can see the title variable gets ignored and has taken the plugin name, but if I remove the {% set title = '' %} part it throws an error of Variable "title" does not exist.

I tried to match the basics of what the sections settings template that craft has. Am I just trying to do something that was never an intended purpose or is just bad practice ?

Any clearance would be great, thanks!

4

Your settings page doesn't need to include {% extends "_layouts/cp" %}.

Also there's no need to define any block section. What's in your template/settings.html file will be shown within that CP-area per default.

  • Yeah you're right, the issue I have with this though is that it's wrapped in a form element with a save button at the bottom, this is something I want to avoid and I figured extending _layouts/cp would be the way to go about that. – Alec Ritson Oct 28 '14 at 12:43
  • 1
    You could use the {% redirect %} tag on your settings page and redirect the user to another page with your own custom settings. It's not super-fancy but it might work if you need to make something very custom... – naboovalley Oct 28 '14 at 12:55
  • Thanks for your help, I think I will go down the redirect route, that way if I do end up needing settings it'll be easier to switch it out etc – Alec Ritson Oct 29 '14 at 11:44
  • I just tried to do the same, get rid of that "Save" button on a settings page. redirect sounded like a good suggestion but it didn't work for me, because it redirected each and every settings page with that set up (even settings/plugins !). Did you get that working or found another solution, @AlecRitson? – carlcs May 7 '15 at 16:28
  • 3
    @Alec I found out that it work if you use setSettingsUrl instead of setSettingsHtml. Stupid us ;) – carlcs May 8 '15 at 14:25

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.