Drupal 6 Maximum Amount of Blocks

Posted in Under the Sun on December 3, 2009 by gentec

We have a client that required us to build the project on Drupal 6. For all what is worth I am not even going to start to complain from this CMS , there are people that love it and people that hate it,  and unfortunately I have to say I am from the second half.  It is what it is and does what it needs to do I guess, but stepping outside of the line with it is not a walk in the park.

But anyway to the point. We came to face a situation where the admin interface would not update the position of the blocks anymore. You can drag ‘n drop them as much as you want, but that won’t do it – they keep their original position as you have never updated them at all. I started researching the problem, and it seems that with previous versions of the Drupal ( < 6 ) the column in the DB ( table called “blocks” ) was of datatype TinyInt(4) , which eventually gives you only up to +127 blocks. Not very helpful when you need a lot of them.

In Drupal 6 though that has been fixed, the column that got me wondering was the “weight” one in the blocks table. Ideally with combination of “delta” ( delta should be at least 1/2 of total number of blocks in that area ) it will let you order them the way you want. I actually changed the column type to “smallint“,  hoping that it will give it bigger numbers to work with.Blah, that was a mistake that cost me couple of hours to fix.

Basically the problem seems to be complex one – the data type of that field should be changed, but because the number of the blocks will be submitted every time with the form on the admin page, your PHP will most likely hit the max post size limit and the new blocks won’t be updated again , regardless of the increased data type. So, based on your hosting settings either make a custom php.ini or add those lines in your settings file

post_max_size = 120M;
max_execution_time = 1000;
max_input_time = 1000;

If that feels rediculously high, just adjust the numbers, and you should be all good.

Cheers !

It’s a fact

Posted in Under the Sun on November 14, 2008 by gentec

It’s been 30 wonderful years under the sun, and today the number has changed once again to 31. I can only say that it feels like the most important years are just ahead, and the adventure is not even close to an end. I lived in 3 regimes, on 2 continents, 1 sea and 2 oceans so far, so I can only wait to see what the feature holds for me from now on. Whatever it might be, one thing is for sure, it’s going to be interesting! So cheers all, and I will try to be more productive in the blog from now on.

Returning JSON data using jQuery

Posted in JavaScript with tags , , , on June 27, 2008 by gentec

I started playing with jQuery lately, and I am absolutely pleased with how easy it makes my life and saves me tons of mundane operations. I had to change the way I think about working with AJAX lib’s since I am a long time SAJAX user, but it wasn’t that big of a deal. It took me a second to realize something i want to share with you, and I hope it will help you get started using this great tool.

One thing that makes things way easier is to use Services JSON ( or the PEAR version of it if you have it available ) , to return structured JS objects or arrays back into jQuery.

I would say for $_GET operations use something like this

     $.getJSON("/yourscript.php", ( { val1: value } ),
            function(databack)
             {
                $.each(databack,function(i , val) {
                       alert(i+"="+val);
              });
      });
);

This simple example will send a GET request to “yourscript.php”, with variables val1=value ,which means on the php end you will see this $_GET["val1"] = value.  Because jQuery Ajax call will fetch whatever the output of the php script is , make sure you process and print the desired variable at the end.

What makes your life real easy is using JSON


..... some code 

 $aOut = array("1"=>"One","2"=>"Two");
 $oJSON = new JSON_Services();

 echo $oJSON->encode($aOut);

This will return a well formatted JS object back to JQuery so you don’t have to worry to properly format it on the php end. Once the object is returned, I am using $.each ( or jQuery.each ) , to loop over the object. The result is as expected – “i” would be “1″ , then “2″ , and “val” would be – “One”  and “Two” on the next iteration.

Let’s talk for a second about the second parameter of the $.getJSON function. It’s obvious that this is where it sends the values to the Php script. You can easily fetch a value, for example from an input field using jQuery selectors like this


   $.getJSON("/yourscript.php",
        ( { value: $( "#myfield" ).attr( "value" ) ,
           value2: $( "#myfield2" ).attr( "value" ) } ) ,
      function(databack)
       { ............ }
   );

Web development companies : Software or Not ?

Posted in Under the Sun with tags on May 11, 2008 by gentec

Is your web development company a software company or not ?

Maybe it’s a straight forward answer for you, whether it’s yes or no, or maybe it’s in this gray area of not-really-sure kinda deals. Well, in the light of some conversations i had lately, and to the people that are saying that web development business is not a software business, I want to say that I feel nothing but disagreement on this topic.

Lets look at what Wikipedia has to say on this :

computer systems divide software systems into three major classes: system software, programming software and application software, although the distinction is arbitrary, and often blurred.

Do you see where I am going with this ? Application software.

The more complex Web 2.0 gets, the more we use all kinds of tricks to make websites better, more useful and more task oriented, the more web development process would become an application software process. Business software companies have been around for many, many years and they have jump through hoops improving the processes of creating a viable software application ( some are still struggling with this though ).

I believe that one major differentiation needs to be made here : In the web world we probably should not think about a service/site as a “release” , or at least not as a piece of software that we forget ( or patch ) after the deployment. Web sites are constantly and instantly deployed to the customers, and our patches are “live” and delivered in real time to the consumer. We tend to look at this as an ever-changing and ever-growing environment that we adapt constantly. There is no – “end” date in the sense of “patch tree is closed at this day” , the border is often blurred for us, since if a feature doesn’t preform as it suppose to, we will fix it asap and we won’t have to “re-deploy” the application. We will “invent” some new feature and will deliver it straight away.

But, on the other hand the process of building a site/service comes closer to application development than ever before. Building a maintainable structure, programming interfaces, connect to some api or providing and api service of a kind is something normal these days. Even using things like “xml over http” type of communications takes it closer to a regular protocol user/client services. There are tons of sites out there like flickr or others that are a great example of this. Unobtrusive java script is not just something that is in fashion now and it will go away after some time. It’s just another key to make better and more complex sites/services that will bring the user closer to what a “web desktop” is going to be ( and I don’t doubt that this is going to happen ).

So, are we software companies or are we web application software companies? I would probably stick with the second statement. It’s more distinguishing and carries more definition of what the new world of web based software companies would be.

Cheers!

gMaps openInfoWindowHTML

Posted in JavaScript with tags on May 6, 2008 by gentec

I was building a small tool for visitflorida.com today using google Maps which we all love.

I ran into a small problem when I was passing the html content of the infoWindow in a div. It seems that for some reason I could restrict the max width of the info window but it was adding white space under the content, that made the info windows look pretty ugly. I was playing around with negative margins but that even made the problem worst in IE.

Eventually i ran across this – the inherited CSS problem. If you read this article it’s pretty clear when the window size is computed and it actually makes a lot of sense. So you may or may not have some kind of an CSS inheritance going on, but for the purposes of this lets say you do.

Lets imagine you have a CSS class that defines default div style , tricking the infoWindow is very simple, just add to the div that holds your infoWindow content something like style=”font-size: XXpx;” . This will help the gMap to properly compute the needed height for the container before it gets displayed.

Sounds stupid but it took me about an hour figuring out where that ugly white space was coming from.

I hope this helps !

moved to wordpress

Posted in PHP on April 29, 2008 by gentec

I was mighty frustrated with BlogSpot, and the unability to post code snippets. It took me about 10 mins to find how to do this in wordpress, and I am definitely moving over here.

     $sMyMood = "Happy!";