2

in short: Can you please point to some (working?) sample of implementing a barebone default / dev setup (css, js, basic templates, custom fields, groups, users, matrix forms, front-end forms,...) using a plugin?

Also: Is there a way to "enforce" presence (installation and activation) of "related" plugins ("must use" plugins) so I can develop a theme with functions/features related to other plugins I do not own?

Background: I am starting over (again) with craft, simply as I am fed up managing plugins (i.e. with wordpress). One thing that I am really missing - which may be due to limited coding experience with craft - is a simple way to add my "defaults" (css, js, fields, forms, groups & related (test)users,...) to the system to proceed creating templates (internal as well as customers). In wordpress I could simply extend the functions.php or use a custom site or template related plugin providing me the basics I want/need to proceed developing themes or plugins. In craft I don't get the point / simply don't understand where to start just to add custom fields and relations. I also don't see how I could use a plugin to create t theme / copy the related files and have them "managed" by my plugin.

2 Answers 2

5

I'll try and cover as much as I can:

Can you please point to some (working?) sample of implementing a barebone default / dev setup (css, js, basic templates, custom fields, groups, users, matrix forms, front-end forms,...) using a plugin?

I don't think there would be anything where this is implemented with a plugin (unless i'm mistaken), but P&T have an installation of Craft you can either clone on Github or generate from their website called HappyLager, this contains a bunch of boilerplate to you get you started including sections, entry types, matrix fields, relations, assets.

I don't think there is anything with users on there though due to licencing, Craft personal only allows one user and Client 1 Admin and 1 Client account : http://buildwithcraft.com/pricing

Is there a way to "enforce" presence (installation and activation) of "related" plugins ("must use" plugins) so I can develop a theme with functions/features related to other plugins I do not own?

There is sort of a way to do this I believe, you would need to have a set of dependancies you could define as an array in your main plugin class, then when your plugin's CP/settings page is loaded, do the checks through a controller to see if the correct plugins are installed and proceed with notifications, errors when conditionals are met etc.

An example of a plugin i've seen that has done this is the Twitter plugin from Dukt, its free so you should be able to download it and find what you need. TwitterPlugin.php is where the logic is (from what I can see) then controllers/TwitterController.php to put it all together and then templates/settings/_dependancies.html is how it's dealt with in the front end.

https://dukt.net/craft/twitter

It might be worth having a read about plugin development: http://buildwithcraft.com/docs/plugins/introduction

But I think in your themes readme, a simple list of required plugins with links on how to get them would be good enough for most situations.

In craft I don't get the point / simply don't understand where to start just to add custom fields and relations

This should be solved or become apparent in the HappyLager demo? if not the documentation is quite helpful with this:

I also don't see how I could use a plugin to create a theme / copy the related files and have them "managed" by my plugin.

I think the problem with building a theme is there are so many factors involved with regards to how someone might have their backend set up (if retro fitting a theme) as you if you had something like craft.entries.section('news') in one of your templates but the section is called blog your theme isn't going to work.

For a clean install your problem might be with licensing, I'm not an expert on it by any means so if anyone else knows more information please edit this answer, but I would assume you would need to be careful how you add sections and users at the least.

Your plugin could generate sections on it's install, it could even generate users but I would probably check with Craft directly with this or read their license to be sure, but the methods to create such things are there in the internal API, you could take a look at the full class reference to see whats going on and whats available: http://buildwithcraft.com/classreference

With regards to template files, you can change the location of these file, see Custom template location, but I don't think you can get your plugin to do this, unless i'm mistaken.

As for theme files etc you could have a set directory structure when people install your theme and then use something like the File class to interact with these files http://buildwithcraft.com/classreference/etc/io/File

I hope that helps you get off to a start with building on Craft

4
  • Hi Alec, indeed, that helps a lot - thanks! I really do love the way craft looks and feels, as well as the features it offers out of the box that I / customers would have to pay for compared to WP - but WP leaves one huge advantage to me: I can create stuff with very little developer knowledge and can re-use that stuff easily across various projects - even on a single install. I am very confident, craft would be the right choice to move on, especially as it isn´t bloated, but I simply can't afford on filling my dev gaps just to reach the point where I am compared to WP. Craft is serious stuff!
    – frank
    May 20, 2015 at 16:52
  • 2
    Great answer, Alec. I'd add that the Field Manager plugin could be used to handle import/export of fields. May 20, 2015 at 17:21
  • If I could vote this answer up twice, I would.
    – Brad Bell
    May 20, 2015 at 18:20
  • Cheers guys! Happy to have helped :) good shout on the field manager plugin too! May 20, 2015 at 20:50
5

Just my two cents, as Alec has already provided an excellent answer...

It seems like what you're looking for isn't necessarily a collection of plugins, but really a way to manage a base installation. You would then use this base installation as a starting point for your other projects, thus minimizing the amount of setup time you'd need for each new project.

We've done exactly that, and it works beautifully! We've got a Git repo setup with a clean Craft installation, plus the plugins which we use on virtually every project. Any common database changes have already been made, and an export of the database is included within the repo.

Using the base install is simple... Just download the project, install the database, and voila!

  • Make sure the .git folder does not end up in your new project, since you'll probably be setting it up in a new repo.
  • Make sure your /config/license.key file is omitted! The new project will create one automatically the first time it runs, and that license key file is crucial for identifying your site as a unique installation. Upgrades to your Craft edition (Client, Pro) are tied directly to that license file.

This system has worked fantastically for us. It seems like this may be more along the lines of what you are looking for.

1
  • Hi Lindsey, you are right, your guess matches my original intention in some aspects, however, Iwas thinking about a simple business model around craft for a broader audience which I had to drop as it seems that would become too much heavy lifting to kick-off, which is maybe why nobody else has gone that path so far ;)
    – frank
    May 29, 2015 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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