Friday, Apr 14, 2017
TL; DR. Coding standards are about more that the code on the screen, in the application. They are about culture, trust and collaboration. Smell and readability.
So, coding standards, fun topic eh. Arguing over tabs and spaces (check out Silicon Valley if you haven’t already) for alignment of your code. It may seem like a bit of a petty idea to begin with. However, what I believe is that coding standards should give you better tools as a team to be able to collaborate. ...
Wednesday, Dec 14, 2016
As we have already discussed Docker is a great way to isolate your environment and stop items from crashing into each other. Following on from my last post about running tools from inside a container, we looked at running stuff into your container. Now I am going to have some real life examples. I already expect that you know how to mount your files/directories into the container (-v) and how to assign your workdir (-w), so if you don’t have a look at the last post. ...
Friday, Jul 24, 2015
Making a custom block in Drupal, something other than a block with a title and body which is already core functionality, is something that we often end up doing when integrating services from other locations to control the display of some data. Although it may not be as elegant as integrating with a custom entity, it is far less time consuming overall and where we attempt to deliver value before perfection it fits with most customer requirements. ...
Monday, Jan 19, 2015
We ran into this error PHP Warning: Error while sending QUERY packet. PID=25016 the other day when trying to run an update query on a database with approximately 3.8 million records in it. New data had become available for 2.1 million of these records.
These were submitted using a PHP program which fetched and parsed enormous CSV files before using a PDO statement to insert or update the records into MySQL. ...
Wednesday, Sep 3, 2014
Just a quick code snippet here. I had been looking for a reasonable way to sort an array by the values that are inside it. For example if your array is:
$array = array( 'id' => 1, 'name' => 'Graham', 'id' => 2, 'name' => 'Will', 'id' => 3, 'name' => 'Ryan', ); But you want your array to be order by name; in this order:
$array = array( 'id' => 1, 'name' => 'Graham', 'id' => 3, 'name' => 'Ryan', 'id' => 2, 'name' => 'Will', ); Here is a quick function to help you out. ...
Monday, Mar 12, 2012
After struggling with various adoptions for getting collapsible fieldsets to work within nodes for Drupal 7 I came across a final solution.
Make adjustments to template.php (or in a module if you prefer):
function THEMENAME_preprocess_html(&$variables){ // This function looks for node 1 and only adds the javascript for this. // However it can be extended in different ways if required if ($variables['node']['nid'] = 1){ drupal_add_js('misc/form.js'); drupal_add_js('misc/collapse.js'); } } In D7 you must also make sure that your legend contains a span with class fieldset-legend, and that your content is contained in a div with class fieldset-description, and that you include misc/form. ...
Monday, Mar 12, 2012
Following up on my previous post about collapsible fieldsets in drupal 7 nodes I recently wanted to just add some jQuery UI tabs to another node, and taking inspiration from my previous post about collapsible fieldsets in Drupal 7 nodes, made a little few edits to the template.php to achieve this as well. I actually made this to display vertical tabs from jquery ui, which is why the ui-tabs-vertical class has been added to the JavaScript, so if you don’t want that then just remove it. ...
Tuesday, Aug 16, 2011
So, it has been a while since I last blogged, probably because I have had a lot of work on recently, which certainly isn’t something to complain about. The latest little snippet I have for you is concerning webforms, and more specifically overriding the submit button with an image button.
Basically when I searched around drupal.org, I found a range of differing answers, none of which appeared to solve the problem for me. ...
Wednesday, Nov 11, 2009
I was recently asked the question of how applicable Drupal/Joomla are for a large site. Here is my answer:
I have attempted to break down your points to make answering some of your questions easier. I have been developing with Joomla and Drupal for over 2 years and have created around 20 joomla sites and 20 drupal sites, one of which is a 15 site multisite.
1. Complex(but user friendly) navigation/categorisation Obviously the flexibility afforded by Drupal is a contrast to the user friendly nature of Joomla. ...
Sunday, Nov 1, 2009
Just been hacking away at this to get the idea across of migrating and validating data from one database into the Drupal core (Drupal 6). It relies on the user having created a content type of news from CCK.
<?php mysql_connect('localhost', 'user', 'password') or die('Cannot connect to MySql'); mysql_select_db('database') or die('Cannot connect to database'); // get the required data from the database $sql = 'select * from tableName'; $query = mysql_query($sql); // give it a timestamp $unixTimestamp = 1230800640; //starting unix timestamp $increment = 1012745; //could be replace by a rand() //beginning of the mysql insert sql queries $insertToNode = "INSERT INTO `node` (`nid`, `vid`, `type`, `language`, `title`, `uid`, `status`, `created`, `changed`, `comment`, `promote`, `moderate`, `sticky`, `tnid`, `translate`) VALUES "; $insertToNodeCommentStats = "INSERT INTO `node_comment_statistics` (`nid`, `last_comment_timestamp`, `last_comment_name`, `last_comment_uid`, `comment_count`) VALUES "; $insertToNodeRevisions = "INSERT INTO `node_revisions` (`nid`, `vid`, `uid`, `title`, `body`, `teaser`, `log`, `timestamp`, `format`) VALUES "; //get the total number of rows $totalRows = mysql_num_rows($query); $startNid = 3; // the first Node id (Nid) to be added $userUid = 1; // the id of the user (1 = admin) // create the insert queries while($result = mysql_fetch_assoc($query)){ // sanitise strings ready for insertion $headline = mysql_real_escape_string($result['headline']); $content = mysql_real_escape_string($result['content']); $snippet = mysql_real_escape_string($result['teaser']); // create looping additois to database $insertToNode = $insertToNode. ...
Connect on LinkedIn. Follow me on Twitter. Grab the RSS Feed