The attached (as both patch and tgz) is a coder's example module for Ctools. It provides example argument, context, content type, access, and relationship plugins, along with a demo panel and advanced help. It also shows how a module can provide a default panel. I hope it can be useful.

Comments

merlinofchaos’s picture

StatusFileSize
new3.43 KB

I've attached the .module file, which I've cleaned up for several style issues. You can use it as a guide for some things that need to be looked at.

  • It should always be ctools or CTools, never Ctools.
  • Avoid heredoc for text since that can't be properly run through t().
  • Titles should only be capitalized on the first word. i.e, "This is a title" not "This is a Title" or "This Is A Title".
  • Mostly avoid two blank lines.
  • Try not to have the @file section accidentlly be the doxy block for a function. A couple of the .inc files have this.
  • This is an artifact of the growth of the plugin system, but the main function of the .inc file should not define an array with a key. Instead it should just return the single array. There are a few in CTools that still do this the old way; I change them as I see them. (patches to fix that would be accepted!).
  • The content types are using an older format. Content types can do a lot more to infer names, particularly on render and settings. Compare to the current content types.
  • Use this format:
     * @param $variable
     *   definition
    
Nick Lewis’s picture

This is very useful, thx!

izmeez’s picture

Yes this is useful, and the explanation includes useful tips in general

rfay’s picture

Title: Ctools Plugin Example module provided for inclusion with Ctools » CTools Plugin Example module provided for inclusion with CTools
Status: Active » Needs review
StatusFileSize
new12.01 KB

Here is another rev of the module that (I hope) addresses the issues in #1. Thanks.

merlinofchaos’s picture

Status: Needs review » Fixed

Ok, committed. Let's run with this and we can patch to refine it as we go.

rfay’s picture

adamo’s picture

Thank you so much!!!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

c.hill’s picture

i don't get it. we created a context plugin. but now we have to make a relationship plugin. why not define the relationship right in the context.
sorry for the dumb question. i'm just typing out loud.