ommadawn.dk stuff - drupal http://ommadawn.dk/stuff/tags/drupal en Views http://ommadawn.dk/stuff/wiki/views <div class="field field-name-field-tags field-type-taxonomy-term-reference field-label-above"><div class="field-label">Tags:&nbsp;</div><div class="field-items"><div class="field-item even"><a href="/stuff/tags/computers" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">computers</a></div><div class="field-item odd"><a href="/stuff/tags/drupal" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">drupal</a></div></div></div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p>Important, basic points about views:</p> <ul><li> Using views, you can create a particular look at already existing data, e.g. a list of tags.</li> </ul><p><img alt="" src="http://www.ommadawn.dk/stuffpics/views.png" style="width: 273px; height: 467px;" /></p> <ul><li> The same view can have several <strong>displays</strong>, meaning the same look can exist in multiple formats, e.g. both as page and feed.</li> <li> Under <strong>Fields </strong>we can choose which fields will be shown or used in other ways (like a later comparison). <ul><li> Fields, <strong>add</strong>, remember to use <strong>Search</strong> and the <strong>Filter</strong>, it makes it much easier to find the field you need to add to your view</li> <li> <strong>Configure field</strong> <ul><li> <strong>Exclude from display</strong>, precisely if you don't need to display this field, but need it for some other reason</li> <li> <strong>Link this field to the original piece of content</strong> will sometimes be displayed, this is a simple shortcut for linking from a field back to the content, this field is from.</li> <li> <strong>Rewrite results</strong> <ul><li> <strong>Output this field as a link</strong>, if you want to create other kinds of links <ul><li> <strong>Use absolute path</strong>, very good for links in rss feeds</li> </ul></li> </ul></li> </ul></li> <li> <strong>Sort criteria</strong> <ul><li> <strong>Expose this sort to visitors, to allow them to change it</strong>, if you enable this, you will get a filter</li> </ul></li> </ul></li> <li> When an included field is a (term?) reference, a link to the relevant page will be created automatically or by default (e.g. from term to page of content linked to term). It is also possible to include the linked to content.</li> </ul><p>If you're used to SQL, this might help you:</p> <p><img alt="select from where order by" src="http://www.ommadawn.dk/stuffpics/views_sql.png" style="width: 273px; height: 467px;" /></p> <p>If the value for filtering comes from the URL, use Contextual filters:</p> <ul><li> The view is available as a page, with a path: <a href="http://www.example.com/my-view">www.example.com/my-view</a></li> <li> I want to get the term ID from the URL, if it's available, and only show content matching that term.</li> <li> <strong>Contextual filters, add</strong></li> <li> Choose the right field, apply, apply.</li> <li> A relevant term has tid = 7.</li> <li> Test <a href="http://www.example.com/my-view/7">www.example.com/my-view/7</a></li> </ul><p>If fields are needed from more than one entity, relationships are needed, like this:</p> <ul><li> I want to create a view showing articles + the name of the author.</li> <li> Create<strong> </strong>a view showing articles.</li> <li> Create a <strong>relationship</strong> to Content: Author.</li> <li> Now you can select a new field: User: Name.</li> </ul><p>Using relationships is like <strong>joining</strong> tables in SQL.</p> <p>Want to display your content with a view included? Use <a href="http://drupal.org/project/viewfield">Viewfield</a>. <a href="http://drupal.org/node/1210142">Viewfield Tutorial</a>. This applies, when you actually want to link youre content to a view. You can also use <a href="http://drupal.org/project/views_field_view">Views field view</a>, where you can still use another view a field, without relating it to your content type.</p> <p>Have a hierachal taxonomy structure? Then of course you want to show it hierachally in your view. Use <a href="http://drupal.org/node/1493366">Views tree</a>.</p> <ol start="0"><li> <em>First, create a new term view using the fields row style. Then:</em></li> <li> <em>Add relationship for taxonomy term: parent term</em></li> <li> <em>Add field term id (do not use relationship) and exclude it from display</em></li> <li> <em>Add field term id with relationship, exclude from display</em></li> <li> <em>Add any fields you want to display, like term name, term description, etc...</em></li> <li> <em>Change style plugin to Tree (Adjacency model)</em></li> <li> <em>Set Main field to Term ID</em></li> <li> <em>Set Parent field to Term ID with parent relationship</em></li> </ol><p>0, "the fields row style". What is actually meant is "unformatted list of fields".</p> <p><img alt="" src="http://www.ommadawn.dk/stuffpics/viewstree0.png" /></p> <p>1, find and relate to the parent term.</p> <p><img alt="" src="http://www.ommadawn.dk/stuffpics/viewstree1.png" /></p> <p>2, add field term id.</p> <p><img alt="" src="http://www.ommadawn.dk/stuffpics/viewstree2a.png" /></p> <p>2, without relationship, excluding from display.</p> <p><img alt="" src="http://www.ommadawn.dk/stuffpics/viewstree2b.png" /></p> <p>3, again, now with relationship.</p> <p><img alt="" src="http://www.ommadawn.dk/stuffpics/viewstree3.png" /></p> <p>5-7, change style (or rather, format).</p> <p><img alt="" src="http://www.ommadawn.dk/stuffpics/viewstree6.png" /></p> </div></div></div> Fri, 30 Nov 2012 14:28:53 +0000 d7lise 31 at http://ommadawn.dk/stuff http://ommadawn.dk/stuff/wiki/views#comments Features http://ommadawn.dk/stuff/wiki/features <div class="field field-name-field-tags field-type-taxonomy-term-reference field-label-above"><div class="field-label">Tags:&nbsp;</div><div class="field-items"><div class="field-item even"><a href="/stuff/tags/drupal" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">drupal</a></div><div class="field-item odd"><a href="/stuff/tags/computers" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">computers</a></div></div></div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p>How does a feature figure out, whether it's been updated?</p> <ul><li> The "normal" state of the feature is the state of e.g. the fields involved. The relevant resource is asked: What is the state? E.g., for a field you'd look at field_config and field_config_instance and see how the field was configured.</li> <li> The "default" state of the feature is stored in the feature itself. There are functions that will return how things should be configured, e.g. a function implementing hook_field_default_fields.</li> <li> These 2 requests result in arrays. Bascially the 2 arrays are compared. If they're the same, you know that the feature and the database are in sync.</li> <li> If the feature and the database aren't in sync, it is decided where the problem lies. Other configurations are checked and compared in order to make the decision.</li> </ul></div></div></div> Fri, 30 Nov 2012 08:27:10 +0000 d7lise 30 at http://ommadawn.dk/stuff http://ommadawn.dk/stuff/wiki/features#comments Configuring fields http://ommadawn.dk/stuff/wiki/configuring-fields <div class="field field-name-field-tags field-type-taxonomy-term-reference field-label-above"><div class="field-label">Tags:&nbsp;</div><div class="field-items"><div class="field-item even"><a href="/stuff/tags/computers" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">computers</a></div><div class="field-item odd"><a href="/stuff/tags/drupal" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">drupal</a></div></div></div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p>Custom fields also have custom configuration, and this configuration can be changed through many modules. How is this done?</p> <ul><li> 2 tables keep the relevant information: field_config and field_config_instance</li> <li> field_config notes, that a field exists, and certain basic and default information about it (one row for every field)</li> <li> field_config_instance notes, that the field has been related to an entity (one row for every relation)</li> </ul><p>A look at field_config:</p> <p><img alt="" src="http://www.ommadawn.dk/stuffpics/field_config.png" style="width: 662px; height: 320px;" /></p> <p>Every field has an id (an integer), a machine name, a type and a relation to a module.</p> <p>Let's look at the field for tags:</p> <ul><li> id = 3</li> <li> name = field_tags</li> <li> type = taxonomy_term_reference</li> <li> module = taxonomy</li> </ul><p>Let's look at field_config_instance too:</p> <p><img alt="" src="http://www.ommadawn.dk/stuffpics/field_config_instance.png" style="width: 700px; height: 368px;" /></p> <p>Looking at field_tags again is interesting:</p> <ul><li> articles have tags</li> </ul><p>Both tables have a very important column called data. This is where most of the actual configuration is stored. We won't look directly at that field a lot, but mostly look at manipulating it instead. First let's look at how the above rows were <strong>created </strong>in the install profile:</p> <pre> $field = array( 'field_name' =&gt; 'field_tags', 'type' =&gt; 'taxonomy_term_reference', // Set cardinality to unlimited for tagging. 'cardinality' =&gt; FIELD_CARDINALITY_UNLIMITED, 'settings' =&gt; array( 'allowed_values' =&gt; array( array( 'vocabulary' =&gt; 'tags', 'parent' =&gt; 0, ), ), ), ); field_create_field($field);</pre><p>The array called settings feeds the column called data. This is what data contains afterwards (I've shortened it a little):</p> <pre> a:6:{s:8:"settings";a:1:{s:14:"allowed_values";a:1:{i:0;a:2:{s:10:"vocabulary";s:4:"tags";s:6:"parent";i:0;}}}...}</pre><p>Let's format that a bit:</p> <pre> a:6:{ s:8:"settings"; a:1:{ s:14:"allowed_values"; a:1:{ i:0; a:2:{ s:10:"vocabulary"; s:4:"tags"; s:6:"parent"; i:0; } } } ... }</pre><p>Hopefully you can see the similarity between the 2 formats.</p> <ul><li> a = array</li> <li> s = string</li> <li> i = integer</li> <li> i:0 = this integer has the value 0</li> <li> s:8:"settings" = this string is 8 characters long and has the value settings</li> </ul><p>Assume I want to <strong>add some configuration</strong> to the term reference, how do I do that?</p> <ul><li> load the configuration for our field <ul><li> $field = field_info_field('field_tags');</li> </ul></li> <li> update the configuration by adding the new configuration (which will be an array structured like allowed_values above*) <ul><li> $new_configuration = array( NEW CONFIGURATION );</li> <li> $field['settings'] += $new_configuration;</li> </ul></li> <li> save the configuration <ul><li> field_update_field($field);</li> </ul></li> </ul><p>* Details about my new configuration:</p> <pre> $new_configuration = array( 'new_conf' =&gt; array( array( 'newstate' =&gt; 'something', ), ), ); </pre><p>In case I want to do something a little more complicated, for a lot of fields, this might be the place to begin; it does the same but in a way that's easier to modify.</p> <ul><li> load the configuration for all fields <ul><li> $fields = field_read_fields();</li> </ul></li> <li> narrow it down to looking only at the configuration for tags <ul><li> foreach ($fields as $field_name =&gt; $field) { if ($field_name == 'field_tags') { STUFFBELOW } }</li> </ul></li> <li> update the configuration by adding the new configuration (which will be an array structured like allowed_values above) <ul><li> $new_configuration = array( NEW CONFIGURATION );</li> <li> $field['settings'] += $new_configuration;</li> </ul></li> <li> save the configuration <ul><li> field_update_field($field);</li> </ul></li> </ul></div></div></div> Tue, 13 Nov 2012 12:10:59 +0000 d7lise 27 at http://ommadawn.dk/stuff http://ommadawn.dk/stuff/wiki/configuring-fields#comments Granting access http://ommadawn.dk/stuff/wiki/granting-access <div class="field field-name-field-tags field-type-taxonomy-term-reference field-label-above"><div class="field-label">Tags:&nbsp;</div><div class="field-items"><div class="field-item even"><a href="/stuff/tags/computers" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">computers</a></div><div class="field-item odd"><a href="/stuff/tags/drupal" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">drupal</a></div></div></div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p>Apart from the permissions system in Drupal, it is possible to implement a system based on grants. This relates nodes to realms (based on role, term references or other attributes related to users), granting (or denying) access. In the table node_access rows consist of 6 values, (nid, gid, realm, grant_view, grant_update, grant_delete).</p> <p>E.g. (3, 5, 'superusers', 1, 1, 1).</p> <ul><li> If the user is trying to access node 3,</li> <li> if the user is related to the realm superusers</li> <li> with grant id 5,</li> <li> then the user can view, update and delete the node.</li> </ul><p>E.g. (7, 4, 'mice', 1, 0, 0).</p> <ul><li> If the user is trying to access node 7,</li> <li> if the user is related to the realm mice</li> <li> with grant id 4,</li> <li> then the user can view the node.</li> </ul><p>How exactly realms and grant ids are used, depends on the module using it.</p> <p><a href="http://api.drupal.org/api/drupal/modules!node!node.api.php/function/hook_node_grants/7">http://api.drupal.org/api/drupal/modules!node!node.api.php/function/hook_node_grants/7</a></p> <p> </p> <p>An example: The <a href="http://drupal.org/project/abt">ABT</a> module</p> <p><img alt="" src="http://www.ommadawn.dk/stuffpics/accessterms2.png" style="width: 354px; height: 108px;" /></p> <ul><li> I create a taxonomy, or use the existing taxonomy tags.</li> <li> I create a content type, with a term reference to this taxonomy.</li> <li> While saving this field, I will be asked further details about this field.</li> </ul><p><img alt="" src="http://www.ommadawn.dk/stuffpics/termref3abt.png" style="width: 786px; height: 534px;" /></p> <ul><li> Likewise, I add a field to the user profile, a term reference to the same taxonomy.</li> </ul><p><img alt="" src=" http://www.ommadawn.dk/stuffpics/user3abt.png" style="width: 792px; height: 341px;" /></p> <ul><li> I create some content in my new content type, and add a tag.</li> </ul><p><img alt="" src="http://www.ommadawn.dk/stuffpics/content1abt.png" style="width: 452px; height: 91px;" /></p> <ul><li> I create a new user, and add the same tag.</li> <li> Now node_access looks like this:</li> </ul><p><img alt="" src="http://www.ommadawn.dk/stuffpics/node_access.png" style="width: 542px; height: 212px;" /></p> <ul><li> The new table abt_map will now look like this:</li> </ul><p><img alt="" src="http://www.ommadawn.dk/stuffpics/abt_map.png" style="width: 535px; height: 90px;" /></p> <p>How did ABT do it?</p> <ul><li> there's more info in abt_map</li> <li> the gid in this case is the same as the tid / term id for the term in question ("testterm")</li> <li> the realm is named after the module (abt) and the field (field_termref)</li> </ul><p>What about a hierachy?</p> <ul><li> Example: term "Europe" is above term "Denmark"</li> <li> user is related to "Europe"</li> <li> node is related to "Denmark"</li> <li> then the user has access to the node</li> <li> (the other way around doesn't work, as it probably shouldn't)</li> </ul><p>What about a combination of tags?</p> <ul><li> content (jeans) and users are tagged with languages and brands</li> <li> specific pair of jeans: German Calvin Klein</li> <li> if user is tagges with either "German" or "Calvin Klein", there is access</li> </ul><p>An example: The <a href="http://drupal.org/project/taxonomy_access">Taxonomy Access Control</a> module</p> <p><img alt="" src="http://www.ommadawn.dk/stuffpics/accessterms.png" /></p> <ul><li> I use the taxonomy called tags.</li> <li> I create a content type, with a field referencing this taxonomy.</li> <li> I create content with a term for this reference ("version1.0").</li> <li> I create a role called "mayversion1.0".</li> <li> I configure Taxonomy Access Control: <ul><li> Authenticated users get a new row, based on the term, with deny in all 3 columns.</li> <li> mayversion1.0 users get a new row, based on the term, with allow in all 3 columns.</li> <li> (When 2 different roles say allow and deny, allow wins.)</li> </ul></li> <li> I create a new user. It is related to the role mayversion1.0.</li> <li> This new user can access my content.</li> </ul><p>How did TAC do it?</p> <ul><li> there's more info in taxonomy_access_default:</li> </ul><p><img alt="" src="http://www.ommadawn.dk/stuffpics/tac_tad.png" style="width: 630px; height: 312px;" /></p> <ul><li> and taxonomy_access_term:</li> </ul><p><img alt="" src="http://www.ommadawn.dk/stuffpics/tac_tat.png" style="width: 684px; height: 309px;" /></p> <ul><li> the gid in this case is the same as the rid / role id for the role in question:</li> </ul><p><img alt="" src="http://www.ommadawn.dk/stuffpics/tac_na.png" style="width: 581px; height: 294px;" /></p> <ul><li> the realm is named by TAC, "taxonomy_access_role"</li> <li> role 1 = admin, role 2 = authenticated user, role 4 = mayversion1.0</li> <li> node 3 = my content</li> <li> vocabulary 0 = tags</li> </ul><p>What about a hierachy?</p> <ul><li> Example: term "Europe" is about term "Denmark", and were so when TAC was configured</li> <li> role is related to "Europe"</li> <li> node is related to "Denmark"</li> <li> then the user has access to the node</li> </ul><p>The module <a href="http://drupal.org/project/workbench_access">Workbench Access</a> does not use node_access. Also, it only controls create/edit rights, not view rights. <a href="http://www.youtube.com/watch?v=mFENFkwneGo">Video</a>.</p> <p>Note:</p> <ul><li> <a href="http://drupal.org/project/term_access">Term access</a> only exists in a development version.</li> <li> <a href="http://drupal.org/project/content_access">Content access</a> only exists in beta.</li> <li> <a href="http://drupal.org/project/nodeaccess">Nodeaccess</a> only exists in a development version.</li> <li> <a href="http://drupal.org/project/tac_lite">Taxonomy access control lite</a> only exists in an "other" version.</li> <li> <a href="http://drupal.org/project/access">Access control kit</a> only exists in a development version.</li> <li> <a href="http://drupal.org/project/menu_access">Menu access</a> is only for drupal 6.</li> <li> <a href="http://drupal.org/project/taxonomy_access">Taxonomy Access Control</a> is minimally maintained.</li> </ul></div></div></div> Tue, 30 Oct 2012 12:00:30 +0000 d7lise 25 at http://ommadawn.dk/stuff http://ommadawn.dk/stuff/wiki/granting-access#comments Basic Drupal module building http://ommadawn.dk/stuff/wiki/basic-drupal-module-building <div class="field field-name-field-tags field-type-taxonomy-term-reference field-label-above"><div class="field-label">Tags:&nbsp;</div><div class="field-items"><div class="field-item even"><a href="/stuff/tags/computers" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">computers</a></div><div class="field-item odd"><a href="/stuff/tags/drupal" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">drupal</a></div></div></div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p><style type="text/css"> <!--/*--><![CDATA[/* ><!--*/ /*--><!]]>*/ </style></p> <p>Learned from</p> <p> <a href="http://buildamodule.com/video/drupal-7-development-core-concepts-welcome-to-module-building-our-module-recreated-in-2-minutes-and-next-steps">http://buildamodule.com/video/drupal-7-development-core-concepts-welcome-to-module-building-our-module-recreated-in-2-minutes-and-next-steps</a></p> <ul><li> cd sites/all/modules</li> <li> mkdir &lt;<span style="background-color:#ffff00;">modulename</span>&gt;</li> <li> cd &lt;<span style="background-color:#ffff00;">modulename</span>&gt;</li> <li> edit &lt;<span style="background-color:#ffff00;">modulename</span>&gt;.info <ul><li> name</li> <li> description</li> <li> package</li> <li> core</li> <li> files[]</li> </ul></li> <li> edit &lt;<span style="background-color:#ffff00;">modulename</span>&gt;.module <ul><li> edit function &lt;<span style="background-color:#ffff00;">modulename</span>&gt;_menu() (creates URL)</li> <li> add “$items['&lt;<span style="background-color:#ffff00;">modulename</span>&gt;-&lt;<span style="background-color:#00ff00;">something</span>&gt;']”</li> <li> add “page callback = '&lt;<span style="background-color:#ffff00;">modulename</span>&gt;_&lt;<span style="background-color:#00ff00;">something</span>&gt;' “</li> <li> edit function &lt;<span style="background-color:#ffff00;">modulename</span>&gt;_&lt;<span style="background-color:#00ff00;">something</span>&gt;()</li> <li> return content to be shown on screen</li> </ul></li> <li> enable module</li> <li> go to &lt;drupalsite&gt;/&lt;<span style="background-color:#ffff00;">modulename</span>&gt;-&lt;<span style="background-color:#00ff00;">something</span>&gt;</li> </ul><p> </p> <p>Learned from</p> <p><a href="http://buildamodule.com/video/drupal-7-development-core-concepts-how-to-build-module-scaffolding-setting-up-the-module-file-structure">http://buildamodule.com/video/drupal-7-development-core-concepts-how-to-build-module-scaffolding-setting-up-the-module-file-structure</a> etc.</p> <p><a href="http://buildamodule.com/video/drupal-7-development-core-concepts-how-hooks-work-and-how-to-use-them-what-hooks-are-and-a-demo-of-our-final-module">http://buildamodule.com/video/drupal-7-development-core-concepts-how-hooks-work-and-how-to-use-them-what-hooks-are-and-a-demo-of-our-final-module</a> etc.</p> <ul><li> edit &lt;<span style="background-color:#ffff00;">modulename</span>&gt;.info <ul><li> ; $Id$</li> <li> configure = admin/config/&lt;<span style="background-color:#ffff00;">modulename</span>&gt;</li> <li> dependencies[] = &lt;some_other_module&gt;</li> </ul></li> <li> edit &lt;<span style="background-color:#ffff00;">modulename</span>&gt;.module <ul><li> // $Id:$</li> <li> Info about file <ul><li> /**</li> <li> * @file</li> <li> * &lt;text&gt;</li> <li> */</li> </ul></li> <li> Info about functions <ul><li> /**</li> <li> * Implements hook_menu().</li> <li> */</li> </ul></li> <li> Content in &lt;<span style="background-color:#ffff00;">modulename</span>&gt;_menu() <ul><li> $items['admin/config/&lt;<span style="background-color:#dda0dd;">modulename</span>&gt;']</li> <li> 'page arguments' =&gt; array('&lt;<span style="background-color:#ffff00;">modulename</span>&gt;-&lt;<span style="background-color:#00ff00;">stuff</span>&gt;')</li> <li> &lt;<span style="background-color:#ffff00;">modulename</span>&gt;-&lt;<span style="background-color:#00ff00;">stuff</span>&gt;()</li> </ul></li> </ul></li> <li> edit README.txt</li> </ul><p>Example:</p> <p><strong><span style="background-color:#ffff00;">example</span>.info:</strong></p> <p> ; $Id$<br />  <br /> name = <span style="background-color:#ffff00;">example</span><br /> description = Example module<br /> core = 7.x</p> <p> <strong><span style="background-color:#ffff00;">example</span>.module:</strong></p> <p> &lt;?php<br /> function <span style="background-color:#ffff00;">example</span>_menu(){<br />   $items['<span style="background-color:#dda0dd;">example</span>'] = array(<br />     'title'            =&gt; t('Example module'),<br />     'page callback'    =&gt; 'example_<span style="background-color:#00ff00;">output</span>',<br />     'access arguments' =&gt; array('access content'),<br />   );</p> <p>   return $items;<br /> }</p> <p> /*<br /> * Display output<br /> */<br /> function <span style="background-color:#ffff00;">example</span>_<span style="background-color:#00ff00;">output</span>() {<br />   return 'This is an example';<br /> }</p> <p><strong>Other cool stuff</strong></p> <ul><li> example.admin.inc: contains code needed for administration and configuration, is not needed on every page load.</li> <li> white screen of death: tail /var/log/apache2/error.log (or something similar)</li> <li> where is the tmp directory? check admin/config/media/file-system (d7)</li> <li> when defining a page / menu item, a lot of times you don't define "access callback", so "user_access" will be called by default</li> </ul><p><strong>This module is not perfect for me, what do I do?</strong></p> <ul><li> The changes are very specific to us: Find the right hook, and create an extra module using that.</li> <li> The changes are generic: Patch the module and upload the patch to drupal.org</li> <li> I have a lot of time on my hands, and this module is important to me: Become a maintainer.</li> <li> 75% functionality needs to be added, and I don't care about maintenance of the 25% already there: Make a copy of the module.</li> </ul><p><strong>Choices:</strong></p> <ul><li> for menu types: <a href="http://api.drupal.org/api/drupal/includes!menu.inc/7">menu.inc</a> (Constants)</li> <li> for user access modes: <a href="http://drupal.stackexchange.com/questions/2764/how-can-i-find-out-a-list-of-available-string-values-for-user-accessstring-f">user permissions</a></li> <li> if function 1 exists, function 1_2 will be searched for automatically: <ul><li> <a href="http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#validate">the default form validation function which is the form ID with _validate appended to it</a></li> <li> <a href="http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#submit_property">the default form validation function which is the form ID with _submit appended to it</a></li> <li> <a href="http://erikwebb.net/blog/drupal-design-patterns/menus">load functions</a></li> </ul></li> </ul></div></div></div> Fri, 14 Sep 2012 15:22:27 +0000 d7lise 21 at http://ommadawn.dk/stuff http://ommadawn.dk/stuff/wiki/basic-drupal-module-building#comments Drupal http://ommadawn.dk/stuff/wiki/drupal <div class="field field-name-field-tags field-type-taxonomy-term-reference field-label-above"><div class="field-label">Tags:&nbsp;</div><div class="field-items"><div class="field-item even"><a href="/stuff/tags/computers" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">computers</a></div><div class="field-item odd"><a href="/stuff/tags/drupal" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">drupal</a></div></div></div><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p>Windows:</p> <ul><li> <a href="http://www.apachefriends.org/f/viewtopic.php?f=16&amp;t=50078&amp;p=193085&amp;hilit=skype#p193085">Any way to have XAMPP and Skype working at the same time?</a></li> <li> <a href="http://samsami2u.wordpress.com/2008/07/18/phpexe-is-not-recognized-as-an-internal-or-external-command/">Hook up drush with php</a></li> </ul><p>Ubuntu:</p> <ul><li> <a href="http://www.howtogeek.com/howto/ubuntu/install-mysql-server-5-on-ubuntu/">Install MySQL Server 5 on Ubuntu</a></li> <li> <a href="https://help.ubuntu.com/community/phpMyAdmin">Install phpmyadmin</a></li> <li> <a href="http://drupal.org/node/1248790">Installing/Upgrading Drush on Ubuntu</a></li> <li> <a href="http://drupal.org/node/29325">Configuring vim</a> <ul><li> <a href="http://www.cyberciti.biz/faq/howto-install-full-vim-under-ubuntu-linux/">Not available in this version: syntax on</a></li> </ul></li> </ul><p><a href="http://www.leveltendesign.com/tutorial/course/getting-started-drupal-7">Getting Started with Drupal 7 Tutorials</a></p> <p> </p> <p><a href="http://www.youtube.com/watch?v=KHsjjHzYOSg">Setting Up a Wiki in Drupal 7</a></p> <p> </p> <p>Before updating module or core:</p> <ul><li> <a href="http://www.phpmyadmin.net/documentation/#faq6_4">How can I backup my database or table?</a></li> <li> Backup root directory (e.g. with Filezilla)</li> </ul><p>Updating core:</p> <ul><li> <a href="http://drupal.org/node/1494290">Update Drupal Core</a></li> <li> Remember sites and modules.</li> </ul><p>The manual way:</p> <p> </p> <p><span style="font-family:courier new,courier,monospace;">cd sites/all/modules<br /><em># backup old module</em><br /> tar cvf DATE.tar MODULE                            <br /><em>(find PATH to new version of module on drupal.org)<br /> # get new module</em><br /> wget PATH                                <br /><em>through site:<br /> # backup database<br /> - Configuration / System / Backup and Migrate / Do backup        <br /> # go into maintenance mode<br /> - Configuration / Development / Maintenance mode / Switch on        <br /> # move old module away</em><br /> mv MODULE MODULE.tmp                            <br /><em># unpack new module</em><br /> tar xzvf MODULE-NEW.tar.gz                        <br /><em>through site:<br /> # do update related to new module<br /> - Configuration / Development / Maintenance mode / Update script    <br /> # leave maintenance mode<br /> - Configuration / Development / Maintenance mode / Switch off        <br /> check that everything is running<br /> # delete the temporary file</em><br /> rm MODULE-NEW.tar                            <br /><em># delete old module</em><br /> rm -r MODULE.tmp                            <br /><em># move the backup away</em><br /> mv DATE.tar ~/backup                           </span></p> <p> </p> <p>Multi-site functionality:</p> <ul><li> <a href="http://drupal.org/documentation/install/multi-site">In general</a></li> <li> <a href="http://www.acquia.com/blog/migrating-drupal-way-part-iii-managing-multiple-sites-drupal">With Acquia</a></li> </ul><p>(Place copies of default in the folder below MAIN drupal, not any other sites, that may be located differently.)</p> <p> </p> <p>REST server:</p> <ul><li> <a href="http://drupal.stackexchange.com/questions/4718/how-to-create-test-endpoint">How to create test_endpoint</a></li> </ul><p> </p> <p><a href="http://docs.cksource.com/CKEditor_for_Drupal/Open_Source/Drupal_7/Installation">CKEditor for Drupal 7 Installation Process</a></p> <p><a href="http://www.youtube.com/watch?v=Qd3wZ8ZxwOs&amp;feature=related">Install CK Editor in Drupal 7</a></p> <p><a href="http://drupal.stackexchange.com/questions/9904/how-to-delete-all-unpublished-comments">How to delete all unpublished comments?</a></p> <p> </p> <p>* <a href="/stuff/wiki/basic-drupal-module-building">Basic Drupal module building</a></p> <p>* <a href="/stuff/wiki/configuring-fields">Configuring fields</a></p> <p>* <a href="/stuff/wiki/features">Features</a></p> <p>* <a href="/stuff/wiki/granting-access">Granting access</a></p> </div></div></div> Wed, 08 Aug 2012 12:40:19 +0000 d7lise 19 at http://ommadawn.dk/stuff http://ommadawn.dk/stuff/wiki/drupal#comments