Dollar Dad - Drupal 7 http://kevinphillips.co.nz/taxonomy/term/1 en Build a node content type http://kevinphillips.co.nz/news/build-node-content-type <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>Drupal 7 Reference Material<br /> Whilst I'm converting from Drupal 7 (D6) to Drupal 7 (D7) I thought that I'd keep a set of useful notes and references online rather than private so that anyone can use them.<br /> Whilst naturally I'm using a number of reference points I will try to maintain backward links to any site that I'm using material from. I'm certainly not intending to just copy and paste code in the hope that I get a search engine result.<br /> If anyone feels I'm breaching their copyright please contact me and I'll remove the content<br /> I also promise to theme this site but with so much work on it may be awhile!!!!</p> </div></div></div><div class="field field-name-field-tags field-type-taxonomy-term-reference field-label-above clearfix"><h3 class="field-label">Tags: </h3><ul class="links"><li class="taxonomy-term-reference-0" rel="dc:subject"><a href="/taxonomy/term/1" typeof="skos:Concept" property="rdfs:label skos:prefLabel">Drupal 7</a></li><li class="taxonomy-term-reference-1" rel="dc:subject"><a href="/taxonomy/term/2" typeof="skos:Concept" property="rdfs:label skos:prefLabel">Module Development</a></li></ul></div> Sun, 16 Jan 2011 23:10:35 +0000 kevin 1 at http://kevinphillips.co.nz http://kevinphillips.co.nz/news/build-node-content-type#comments Drupal 7 is not ready yet http://kevinphillips.co.nz/news/drupal-7-not-ready-yet <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>Having spent sometime now working with Drupal 7 I've come to the opinion that it is still someway off being good to use for production websites.  Just too many contributed models are not ready. So it's back to codeigniter for me</p> </div></div></div><div class="field field-name-field-tags field-type-taxonomy-term-reference field-label-above clearfix"><h3 class="field-label">Tags: </h3><ul class="links"><li class="taxonomy-term-reference-0" rel="dc:subject"><a href="/taxonomy/term/1" typeof="skos:Concept" property="rdfs:label skos:prefLabel">Drupal 7</a></li><li class="taxonomy-term-reference-1" rel="dc:subject"><a href="/tags/codeigniter" typeof="skos:Concept" property="rdfs:label skos:prefLabel">Codeigniter</a></li></ul></div> Tue, 08 Mar 2011 21:50:40 +0000 kevin 12 at http://kevinphillips.co.nz http://kevinphillips.co.nz/news/drupal-7-not-ready-yet#comments Programmatically change node settings http://kevinphillips.co.nz/news/programmatically-change-node-settings <div class="field field-name-field-image field-type-image field-label-hidden"><div class="field-items"><div class="field-item even" rel="og:image rdfs:seeAlso" resource="http://kevinphillips.co.nz/sites/default/files/styles/large/public/field/image/pulling_hair.jpg"><img typeof="foaf:Image" src="http://kevinphillips.co.nz/sites/default/files/styles/large/public/field/image/pulling_hair.jpg" alt="Drupal API documentation is like digging through liqueified mud" /></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>A couple of interesting finds whilst creating my own node type with a module.</p> <p>Having built the node type through a module, I then spent hours trying to find out how to control the node form settings like comments and promote to front page. I even spent some time on the IRC but nobody knew the answer.</p> <p>Sometime going through the API documentation is like digging through liqueified mud.</p> <p>However the first way I found was to add this to hook_install</p> <p>variable_del('comment_node_example');</p> <p>but reading on lots of people are saying that it's bad to do it that way because of caching - If anyone can expand on that I would be grateful.</p> <p>The second method and the one I went with was</p> <p>function node_example_node_prepare(&amp;$node) {<br />  if($node-&gt;type == 'node_example') {<br />    $node-&gt;promote = 0;<br />    $node-&gt;comment = 0;<br />  }<br />}</p> <p>I hope this helps anyone someone else.</p> <p>A bug - issue exists in drupal 7 in that you get lots of comment errors when you uninstall a module that has a content type.</p> <p><em class="placeholder"><span style="background-color: rgb(255, 0, 0);">Notice</span></em><span style="background-color: rgb(255, 0, 0);">: Trying to get property of non-object in </span><em class="placeholder"><span style="background-color: rgb(255, 0, 0);">comment_node_type_delete()</span></em></p> <p>You need to set the base - 'node_content'</p> <p>  // Define the node type.<br />  $node_example = array(<br />    'type' =&gt; 'node_example',<br />    'name' =&gt; $t('Example Node'),<br />    'base' =&gt; 'node_content',<br />    'description' =&gt; $t('This is an example node type with a few fields.'),<br />    'body_label' =&gt; $t('Example Description'),<br />        'promote' =&gt;0,<br />  );</p> </div></div></div><div class="field field-name-field-tags field-type-taxonomy-term-reference field-label-above clearfix"><h3 class="field-label">Tags: </h3><ul class="links"><li class="taxonomy-term-reference-0" rel="dc:subject"><a href="/taxonomy/term/1" typeof="skos:Concept" property="rdfs:label skos:prefLabel">Drupal 7</a></li><li class="taxonomy-term-reference-1" rel="dc:subject"><a href="/taxonomy/term/2" typeof="skos:Concept" property="rdfs:label skos:prefLabel">Module Development</a></li></ul></div> Fri, 18 Feb 2011 05:37:04 +0000 kevin 11 at http://kevinphillips.co.nz http://kevinphillips.co.nz/news/programmatically-change-node-settings#comments Error in webform module http://kevinphillips.co.nz/news/error-webform-module <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>Small error in Webform module when using pre built list</p> <p>modules/webform/components/select.inc<br /> line 786<br /> change<br /> $options_args = array();<br /> to<br /> $arguments = array();</p> <p>Has been reported and a patch is available, hopefully it will be resolved on the next update</p> <p><a href="http://drupal.org/files/issues/1024748.patch">http://drupal.org/files/issues/1024748.patch</a></p> <p><a href="http://drupal.org/node/1024748">http://drupal.org/node/1024748</a></p> </div></div></div><div class="field field-name-field-tags field-type-taxonomy-term-reference field-label-above clearfix"><h3 class="field-label">Tags: </h3><ul class="links"><li class="taxonomy-term-reference-0" rel="dc:subject"><a href="/taxonomy/term/1" typeof="skos:Concept" property="rdfs:label skos:prefLabel">Drupal 7</a></li><li class="taxonomy-term-reference-1" rel="dc:subject"><a href="/tags/webform" typeof="skos:Concept" property="rdfs:label skos:prefLabel">webform</a></li></ul></div> Mon, 14 Feb 2011 21:03:25 +0000 kevin 10 at http://kevinphillips.co.nz http://kevinphillips.co.nz/news/error-webform-module#comments Pro Drupal 7 Development http://kevinphillips.co.nz/news/pro-drupal-7-development <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>This book is probably the worst I've come across for learning Drupal 7, it's no way up to the standard of Drupal 6 version.</p> <p>It has so many errors in it. Typos I can understand but these are technical errors that for any newbie would have them running back to Wordpress or Joomla.</p> <p>I've made a full statement on the drupal site</p> <p><a href="http://groups.drupal.org/node/114029" target="_blank">Pro Drupal 7 Development</a></p> <p>I wonder if they come back to me.</p> </div></div></div><div class="field field-name-field-tags field-type-taxonomy-term-reference field-label-above clearfix"><h3 class="field-label">Tags: </h3><ul class="links"><li class="taxonomy-term-reference-0" rel="dc:subject"><a href="/taxonomy/term/1" typeof="skos:Concept" property="rdfs:label skos:prefLabel">Drupal 7</a></li></ul></div> Sat, 12 Feb 2011 03:38:01 +0000 kevin 9 at http://kevinphillips.co.nz http://kevinphillips.co.nz/news/pro-drupal-7-development#comments Multiple Submit Buttons http://kevinphillips.co.nz/news/multiple-submit-buttons <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>Whilst creating a custom form, for a custom module that uses a non node content type, I came across an issue with multiple submit buttons.</p> <p>Whilst Drupal does document using multiple submit buttons here:</p> <p><a href="http://api.drupal.org/api/drupal/modules--node--node.pages.inc/function/node_form/7" target="_blank">http://api.drupal.org/api/drupal/modules--node--node.pages.inc/function/node_form/7</a></p> <p>For all the tea in china I couldn't get this to work.</p> <p>The form API seemed to pick up the first submit button and work with that.</p> <p>  print '&lt;pre&gt;';<br />  print_r($form_state);<br />  print '&lt;/pre&gt;';</p> <p>An array inside $form_state ['clicked_button'] showed that the clicked button was the first submit button in the form, not the button that was clicked.</p> <p>$form_state ['values'] again shows the first submit button</p> <p>Although $form_state['input'] did show that button that was clicked.</p> <p>The answer in the end was very simple</p> <p>All your submit buttons must share the same '#name' value :</p> <p>  $form['another'] = array(<br />    '#type' =&gt; 'submit',<br />    '#value' =&gt; 'Save and add another',<br />   <span style="background-color: rgb(255, 255, 0);"> '#name' =&gt; 'attribute_save',</span><br />    '#weight' =&gt; 5,<br />    '#submit' =&gt; array('product_another_submit'),<br />  );<br />  $form['return'] = array(<br />    '#type' =&gt; 'submit',<br />    '#value' =&gt; 'Save and return',<br />    <span style="background-color: rgb(255, 255, 0);">'#name' =&gt; 'attribute_save',</span><br />    '#weight' =&gt; 10,<br />    '#submit' =&gt; array('product_return_submit'),<br />  );<br />  $form['cancel'] = array(<br />    '#type' =&gt; 'submit',<br />    '#value' =&gt; 'Cancel',<br />    <span style="background-color: rgb(255, 255, 0);">'#name' =&gt; 'attribute_save',</span><br />    '#weight' =&gt; 15,<br />    '#submit' =&gt; array('product_cancel_submit'),<br />  );</p> <p> </p> <p>Hope that helps anyone else stuck with the same problem</p> </div></div></div><div class="field field-name-field-tags field-type-taxonomy-term-reference field-label-above clearfix"><h3 class="field-label">Tags: </h3><ul class="links"><li class="taxonomy-term-reference-0" rel="dc:subject"><a href="/taxonomy/term/1" typeof="skos:Concept" property="rdfs:label skos:prefLabel">Drupal 7</a></li><li class="taxonomy-term-reference-1" rel="dc:subject"><a href="/taxonomy/term/2" typeof="skos:Concept" property="rdfs:label skos:prefLabel">Module Development</a></li><li class="taxonomy-term-reference-2" rel="dc:subject"><a href="/tags/custom-forms" typeof="skos:Concept" property="rdfs:label skos:prefLabel">Custom Forms</a></li></ul></div> Tue, 25 Jan 2011 02:31:48 +0000 kevin 6 at http://kevinphillips.co.nz http://kevinphillips.co.nz/news/multiple-submit-buttons#comments Custom Drupal 7 Module http://kevinphillips.co.nz/news/custom-drupal-7-module <div class="field field-name-field-image field-type-image field-label-hidden"><div class="field-items"><div class="field-item even" rel="og:image rdfs:seeAlso" resource="http://kevinphillips.co.nz/sites/default/files/styles/large/public/field/image/iStock_000001416113XSmall_0.jpg"><img typeof="foaf:Image" src="http://kevinphillips.co.nz/sites/default/files/styles/large/public/field/image/iStock_000001416113XSmall_0.jpg" alt="Drupal is secure" /></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>To really get under the hood of Drupal 7 I've decided to build an e-brochure module. Some would say that I should start with something easier but what the the hell I've already built it on <a href="http://codeigniter.com" target="_blank">Codeigniter</a> so I've got the basics already.</p> <p>Outline:</p> <ul><li>Categories that can be used for menu, blocks etc.</li> <li>Product can belong to one or more categories.</li> <li>Product can be a single product type with or without children products (Attributes)</li> <li>Products can be updated online or through uploading a 'csv' file. This is particularly useful for price updates.</li> <li>Specials or featured function that can be used for displaying in a custom block.</li> <li>Discount Groups that can be added on the fly, setup through the user page.</li> <li>Each product has multiple prices according to the discount group (note I call it buying group).</li> <li>Each child (or attribute) has prices set by discount group</li> <li>NO CART</li> <li>Order form that allows customers to place and email an order.</li> </ul><p> </p> <p>I've decided not to use the node entity for this module, I want to really understand what is going on inside drupal so I shall create my own tables and build up from there.</p> <p>I tried something like this with Drupal 6 but I really couldn't get on with Drupal 6 so I continued to develop using <a href="http://codeigniter.com" target="_blank">Codeigniter</a>. If you are new to programming, with a bit of basic PHP you can really rock with Codeigniter and learn PHP development within the MVC (Model View Controller) pattern. Something that Drupal is not. However I'm keen to use Drupal because to me it's not just CMS (Content Management System) but because it Content Management Framework. Meaning ! Drupal looks after the core issues such as Access Control, Email Library, Forms PLUS PLUS PLUS.  I want to create the code that does stuff (solves the clients problem) and not spend most of my time repeating all the functionality that runs the admin system. Joomla and Word Press do not cut the mustard for me.</p> </div></div></div><div class="field field-name-field-tags field-type-taxonomy-term-reference field-label-above clearfix"><h3 class="field-label">Tags: </h3><ul class="links"><li class="taxonomy-term-reference-0" rel="dc:subject"><a href="/taxonomy/term/1" typeof="skos:Concept" property="rdfs:label skos:prefLabel">Drupal 7</a></li><li class="taxonomy-term-reference-1" rel="dc:subject"><a href="/taxonomy/term/2" typeof="skos:Concept" property="rdfs:label skos:prefLabel">Module Development</a></li><li class="taxonomy-term-reference-2" rel="dc:subject"><a href="/tags/custom-forms" typeof="skos:Concept" property="rdfs:label skos:prefLabel">Custom Forms</a></li></ul></div> Mon, 24 Jan 2011 03:33:45 +0000 kevin 7 at http://kevinphillips.co.nz http://kevinphillips.co.nz/news/custom-drupal-7-module#comments Codeigniter vs Drupal http://kevinphillips.co.nz/news/codeigniter-vs-drupal <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>Well Drupal 7 has landed with a bang.</p> <p>I'm not 100% sure that I would drop codeigniter but Drupal 7 is worth a look.</p> </div></div></div><div class="field field-name-field-tags field-type-taxonomy-term-reference field-label-above clearfix"><h3 class="field-label">Tags: </h3><ul class="links"><li class="taxonomy-term-reference-0" rel="dc:subject"><a href="/taxonomy/term/1" typeof="skos:Concept" property="rdfs:label skos:prefLabel">Drupal 7</a></li></ul></div> Mon, 17 Jan 2011 08:01:11 +0000 kevin 3 at http://kevinphillips.co.nz http://kevinphillips.co.nz/news/codeigniter-vs-drupal#comments Default Text Field Types for nodes http://kevinphillips.co.nz/news/default-text-field-types-nodes <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"><h2>Building a Module</h2> <p>I'm building a new module and after a lot of searching for the built in standard text field (body if you like) I found a link to the Drupal API <a href="http://api.drupal.org/api/drupal/modules--field--modules--text--text.module/7/source">http://api.drupal.org/api/drupal/modules--field--modules--text--text.mod...</a> which shows all the stuff you need.</p> </div></div></div><div class="field field-name-field-tags field-type-taxonomy-term-reference field-label-above clearfix"><h3 class="field-label">Tags: </h3><ul class="links"><li class="taxonomy-term-reference-0" rel="dc:subject"><a href="/taxonomy/term/1" typeof="skos:Concept" property="rdfs:label skos:prefLabel">Drupal 7</a></li><li class="taxonomy-term-reference-1" rel="dc:subject"><a href="/taxonomy/term/2" typeof="skos:Concept" property="rdfs:label skos:prefLabel">Module Development</a></li></ul></div> Sun, 16 Jan 2011 23:27:05 +0000 kevin 2 at http://kevinphillips.co.nz http://kevinphillips.co.nz/news/default-text-field-types-nodes#comments