first import
This commit is contained in:
@ -0,0 +1,17 @@
|
||||
<div id="node-16" class="node">
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="content clear-block">
|
||||
<p>We can use access plugins to determine access to a page or visibility of the panes in a page. Basically, we just determine access based on configuration settings and the various contexts that are available to us.</p>
|
||||
<p>The arbitrary example in plugins/access/arg_length.inc determines access based on the length of the simplecontext argument. You can configure whether access should be granted if the simplecontext argument is greater or less than some number.</p>
|
||||
</div>
|
||||
|
||||
<div class="clear-block">
|
||||
<div class="meta">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
@ -0,0 +1,20 @@
|
||||
<div id="node-12" class="node">
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="content clear-block">
|
||||
<p>Contexts are fundamental to CTools, and they almost always start with an argument to a panels page, so we'll start there too.</p>
|
||||
<p>We first need to process an argument.</p>
|
||||
<p>We're going to work with a "Simplecontext" context type and argument, and then with a content type that displays it. So we'll start by with the Simplecontext argument plugin in plugins/arguments/simplecontext_arg.inc.</p>
|
||||
<p>Note that the name of the file (simplecontext_arg.inc) is built from the machine name of our plugin (simplecontext_arg). And note also that the primary function that we use to provide our argument (ctools_plugin_example_simplecontext_arg_ctools_arguments()) is also built from the machine name. This magic is most of the naming magic that you have to know.</p>
|
||||
<p>You can browse plugins/arguments/simplecontext_arg.inc and see the little that it does.</p>
|
||||
</div>
|
||||
|
||||
<div class="clear-block">
|
||||
<div class="meta">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
@ -0,0 +1,19 @@
|
||||
<div id="node-10" class="node">
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="content clear-block">
|
||||
<p>This demonstration module is intended for developers to look at and play with. CTools plugins are not terribly difficult to do, but it can be hard to sort through the various arguments and required functions. The idea here is that you should have a starting point for most anything you want to do. Just work through the example, and then start experimenting with changing it.</p>
|
||||
<p>There are two parts to this demo: </p>
|
||||
<p>First, there is a sample panel provided that uses all the various plugins. It's at <a href="/ctools_plugin_example/12345">ctools_example/12345</a>. You can edit the panel and configure all the panes on it.</p>
|
||||
<p>Second, the code is there for you to experiment with and change as you see fit. Sometimes starting with simple code and working with it can take you places that it's hard to go when you're looking at more complex examples.</p>
|
||||
</div>
|
||||
|
||||
<div class="clear-block">
|
||||
<div class="meta">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
@ -0,0 +1,17 @@
|
||||
<div id="node-14" class="node">
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="content clear-block">
|
||||
<p>Now we get to the heart of the matter: Building a content type plugin. A content type plugin uses the contexts available to it to display something. plugins/content_types/simplecontext_content_type.inc does this work for us.</p>
|
||||
<p>Note that our content type also has an edit form which can be used to configure its behavior. This settings form is accessed through the panels interface, and it's up to you what the settings mean to the code and the generation of content in the display rendering.</p>
|
||||
</div>
|
||||
|
||||
<div class="clear-block">
|
||||
<div class="meta">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
@ -0,0 +1,21 @@
|
||||
<div id="node-13" class="node">
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="content clear-block">
|
||||
<p>Now that we have a plugin for a simplecontext argument, we can create a plugin for a simplecontext context. </p>
|
||||
<p>Normally, a context would take an argument which is a key like a node ID (nid) and retrieve a more complex object from a database or whatever. In our example, we'll artificially transform the argument into an arbitrary "context" data object. </p>
|
||||
<p>plugins/contexts/simplecontext.inc implements our context.</p>
|
||||
<p>Note that there are actually two ways to create a context. The normal one, which we've been referring to, is to create a context from an argument. However, it is also possible to configure a context in a panel using the panels interface. This is quite inflexible, but might be useful for configuring single page. However, it means that we have a settings form for exactly that purpose. Our context would have to know how to create itself from a settings form as well as from an argument. Simplecontext can do that.</p>
|
||||
<p>A context plugin can also provide keywords that expose parts of its context using keywords like masterkeyword:dataitem. The node plugin for ctools has node:nid and node:title, for example. The simplecontext plugin here provides the simplest of keywords.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clear-block">
|
||||
<div class="meta">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
@ -0,0 +1,20 @@
|
||||
<div id="node-11" class="node">
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="content clear-block">
|
||||
<p>Your module must provide a few things so that your plugins can be found.</p>
|
||||
<p>First, you need to implement hook_ctools_plugin_directory(). Here we're telling CTools that our plugins will be found in the module's directory in the plugins/<plugintype> directory. Context plugins will be in ctools_plugin_example/plugins/contexts, Content-type plugins will be in ctools_plugin_example/plugins/content_types.</p>
|
||||
<p><div class="codeblock"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">ctools_plugin_example_ctools_plugin_directory</span><span style="color: #007700">(</span><span style="color: #0000BB">$module</span><span style="color: #007700">, </span><span style="color: #0000BB">$plugin</span><span style="color: #007700">) {<br /> if (</span><span style="color: #0000BB">$module </span><span style="color: #007700">== </span><span style="color: #DD0000">'ctools' </span><span style="color: #007700">&& !empty(</span><span style="color: #0000BB">$plugin</span><span style="color: #007700">)) {<br /> return </span><span style="color: #DD0000">"plugins/$plugin"</span><span style="color: #007700">;<br /> }<br />}<br /></span><span style="color: #0000BB">?></span></span></code></div></p>
|
||||
<p>Second, if you module wants to provide default panels pages, you can implement hook_ctools_plugin_api(). CTools will then pick up your panels pages in the file named <modulename>.pages_default.inc.</p>
|
||||
<p><div class="codeblock"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">ctools_plugin_example_ctools_plugin_api</span><span style="color: #007700">(</span><span style="color: #0000BB">$module</span><span style="color: #007700">, </span><span style="color: #0000BB">$api</span><span style="color: #007700">) {<br /> if (</span><span style="color: #0000BB">$module </span><span style="color: #007700">== </span><span style="color: #DD0000">'panels_mini' </span><span style="color: #007700">&& </span><span style="color: #0000BB">$api </span><span style="color: #007700">== </span><span style="color: #DD0000">'panels_default'</span><span style="color: #007700">) {<br /> return array(</span><span style="color: #DD0000">'version' </span><span style="color: #007700">=> </span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /> }<br /> if (</span><span style="color: #0000BB">$module </span><span style="color: #007700">== </span><span style="color: #DD0000">'page_manager' </span><span style="color: #007700">&& </span><span style="color: #0000BB">$api </span><span style="color: #007700">== </span><span style="color: #DD0000">'pages_default'</span><span style="color: #007700">) {<br /> return array(</span><span style="color: #DD0000">'version' </span><span style="color: #007700">=> </span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /> }<br />}<br /></span><span style="color: #0000BB">?></span></span></code></div></p>
|
||||
</div>
|
||||
|
||||
<div class="clear-block">
|
||||
<div class="meta">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
@ -0,0 +1,18 @@
|
||||
<div id="node-15" class="node">
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="content clear-block">
|
||||
<p>Often a single data type can lead us to other data types. For example, a node has a user (the author) and the user has data associated with it.</p>
|
||||
<p>A relationship plugin allows this kind of data to be accessed. </p>
|
||||
<p>An example relationship plugin is provided in plugins/relationships/relcontext_from_simplecontext.inc. It looks at a simplecontext (which we got from an argument) and builds an (artificial) "relcontext" from that.</p>
|
||||
</div>
|
||||
|
||||
<div class="clear-block">
|
||||
<div class="meta">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
@ -0,0 +1,42 @@
|
||||
[Chaos-Tools--CTools--Plugin-Examples]
|
||||
title = CTools Plugin Examples
|
||||
file = Chaos-Tools--CTools--Plugin-Examples
|
||||
weight = 0
|
||||
parent =
|
||||
|
||||
[Module-setup-and-hooks]
|
||||
title = Module setup and hooks
|
||||
file = Module-setup-and-hooks
|
||||
weight = -15
|
||||
parent = Chaos-Tools--CTools--Plugin-Examples
|
||||
|
||||
[Argument-Plugins--Starting-at-the-beginning]
|
||||
title = Argument Plugins: Starting at the beginning
|
||||
file = Argument-Plugins--Starting-at-the-beginning
|
||||
weight = -14
|
||||
parent = Chaos-Tools--CTools--Plugin-Examples
|
||||
|
||||
[Context-plugins--Creating-a--context--from-an-argument]
|
||||
title = Context plugins: Creating a context from an argument
|
||||
file = Context-plugins--Creating-a--context--from-an-argument
|
||||
weight = -13
|
||||
parent = Chaos-Tools--CTools--Plugin-Examples
|
||||
|
||||
[Content-Type-Plugins--Displaying-content-using-a-context]
|
||||
title = Content Type Plugins: Displaying content using a context
|
||||
file = Content-Type-Plugins--Displaying-content-using-a-context
|
||||
weight = -12
|
||||
parent = Chaos-Tools--CTools--Plugin-Examples
|
||||
|
||||
[Access-Plugins--Determining-access-and-visibility]
|
||||
title = Access Plugins: Determining access and visibility
|
||||
file = Access-Plugins--Determining-access-and-visibility
|
||||
weight = -11
|
||||
parent = Chaos-Tools--CTools--Plugin-Examples
|
||||
|
||||
[Relationships--Letting-one-context-take-us-to-another]
|
||||
title = Relationships: Letting one context take us to another
|
||||
file = Relationships--Letting-one-context-take-us-to-another
|
||||
weight = -10
|
||||
parent = Chaos-Tools--CTools--Plugin-Examples
|
||||
|
Reference in New Issue
Block a user