11

I'm new to building plugins and I need to make templates for the control panel. How can I use existing Craft UI components to keep things consistent and save myself from having to rebuild everything?

10

Have a look in craft/app/templates for tons of great, easily-reusable examples that make up the existing control panel! They may not be documented, but there's a whole lot of quality stuff there.

You may also want to consider using macros from craft/app/templates/_includes (Craft TemplatesService doc, Twig macro doc), which will go a long way toward good DRY templates.

Bonus: this is also a great way to learn clever ways of doing things in Twig, like breadcrumbs for example. P&T builds excellent stuff, so there's lots to learn from and steal whether it's for the control panel or the front end.

| improve this answer | |
  • 1
    I would point out the macros folder if he's building forms in the Control Panel. And a future thought, it would be great if some of this was documented somewhere. Especially the element layouts and form macros. – Bryan Redeagle Jun 13 '14 at 17:43
  • There I go again, learning something even in a closed-loop self-question! Thanks Bryan. – Matt Stein Jun 13 '14 at 17:51
  • Those macros are sticking with you, heh @Matt? – carlcs Jun 15 '14 at 0:47
  • @Christian You bet! In just a little while, I'll be able to pretend I knew all along. – Matt Stein Jun 15 '14 at 1:19
  • 1
    Same basic advice @RobErskine! Make a pot of coffee, clone github.com/craftcms/cms, and start digging around src/templates. The past few years have also seen a number of first-party plugins worth checking out: github.com/craftcms. A look under the hood at any P&T work is guaranteed to be 100% Crafty. – Matt Stein May 1 '19 at 20:50

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.