Showing posts with label drupal. Show all posts
Showing posts with label drupal. Show all posts

Thursday, March 11, 2010

Wordpress for corporate website?

A definite No!

Wordpress is more for hobbyist or blogger.
There are so many limitation in the modified version of tinymce editor in wp which doesnt allow you to have full control over what you wish to publish.
Example: line break, video, googlemap.

Yes, some plugin allow people to insert these things, but its so trouble some, and even most of the plugin does not work properly. Its a huge bummer.

Alternative?
Try out modx ;)
Features wise, we highly recommends it.
The interface is quite user-friendly, but more complex than wordpress.
But its fit to most corporate CMS requirement.

But if you want more Control and Flexibilities? Use Drupal :)

Sunday, January 17, 2010

drupal cron for multiple sites

There are times when we have multiple site to maintain for our drupal based websites.
One way to do it is by doing a shell script.
But i would prefer to do it using php script instead:

runcron.php
------------------------

$aSites = array(
"http://xyz.com/cron.php",
"http://example.com/cron.php"
);
foreach( $aSites as $sSite ):
$sContent = file_get_contents($sSite);
echo "Retrieved: " . $sSite . "\r\n
";
echo substr($sContent,0, 100) . "...\r\n
";
endforeach;

-------------------
And setup the cron in cpanel:
php [path_to_your_php]/runcron.php
etc.: php /home/example.com/public_html/mydrupal/runcron.php > /dev/null

Hope this is helpful :)

Saturday, November 14, 2009

Drupal upload path

To get where is the default path to upload file of the site:
file_directory_path()
example return: sites/xyz.com/files

Reference:
http://api.drupal.org/api/group/file/6

Other interesting discussion here:
http://groups.drupal.org/node/13420

Monday, November 9, 2009

drupal admin mysql has gone away!

Its such a hectic day.
I tried to clear the cache and i'm getting bunch of errors from mysql has gone away!
It turn out to be some very long query to update cache_update table and caused it to started to lost connection to db.. arg! I added a static variable to count the # of queries to database,, wow! 250+ queries! the front page itself about 110+queries!....

my here is my quick fix to the problem:
edit: drupal/includes/database.mysql.inc
function: _db_query
line #111, before mysql_query line.
(updated 10th nov: if ping is placed after mysql_query, db_effected_rows will always return -1, which causes lots of other issues)

//****BEGIN ATTEMPT TO RECONNECT ON ERROR
try {
if (! mysql_ping($active_db))
{
throw new Exception("db closed!");
}
}
catch (Exception $e)
{
//attempt to reconnect
global $db_url;
$urlname = "default";
if (is_array($db_url)) {
$connect_url = array_key_exists($urlname, $db_url) ? $db_url[$urlname] : $db_url['default'];
}
else {
$connect_url = $db_url;
}

$active_db = db_connect($connect_url);
}
//****END ATTEMPT TO RECONNECT ON ERROR


And these are my modules i've installed, while some are my custom modules:
/var/www/mydrupal/sites/all/modules/advanced_help
/var/www/mydrupal/sites/all/modules/aes
/var/www/mydrupal/sites/all/modules/apisetting
/var/www/mydrupal/sites/all/modules/apisettinglist
/var/www/mydrupal/sites/all/modules/apiutils
/var/www/mydrupal/sites/all/modules/backup_migrate
/var/www/mydrupal/sites/all/modules/birthdays
/var/www/mydrupal/sites/all/modules/calendar
/var/www/mydrupal/sites/all/modules/captcha
/var/www/mydrupal/sites/all/modules/casetracker
/var/www/mydrupal/sites/all/modules/cck
/var/www/mydrupal/sites/all/modules/computed_field
/var/www/mydrupal/sites/all/modules/content_access
/var/www/mydrupal/sites/all/modules/crm_account
/var/www/mydrupal/sites/all/modules/customcasetracker
/var/www/mydrupal/sites/all/modules/customintranet
/var/www/mydrupal/sites/all/modules/date
/var/www/mydrupal/sites/all/modules/filefield
/var/www/mydrupal/sites/all/modules/flexifilter
/var/www/mydrupal/sites/all/modules/hellomodule
/var/www/mydrupal/sites/all/modules/i18n
/var/www/mydrupal/sites/all/modules/imageapi
/var/www/mydrupal/sites/all/modules/imagecache
/var/www/mydrupal/sites/all/modules/imagefield
/var/www/mydrupal/sites/all/modules/imce
/var/www/mydrupal/sites/all/modules/imce_wysiwyg
/var/www/mydrupal/sites/all/modules/jquery_dataTables
/var/www/mydrupal/sites/all/modules/languageicons
/var/www/mydrupal/sites/all/modules/mail_api
/var/www/mydrupal/sites/all/modules/messaging
/var/www/mydrupal/sites/all/modules/mimedetect
/var/www/mydrupal/sites/all/modules/mimemail
/var/www/mydrupal/sites/all/modules/node_gallery
/var/www/mydrupal/sites/all/modules/node_privacy_byrole
/var/www/mydrupal/sites/all/modules/notifications
/var/www/mydrupal/sites/all/modules/notify
/var/www/mydrupal/sites/all/modules/og
/var/www/mydrupal/sites/all/modules/pear
/var/www/mydrupal/sites/all/modules/print
/var/www/mydrupal/sites/all/modules/rdf
/var/www/mydrupal/sites/all/modules/realname
/var/www/mydrupal/sites/all/modules/schema
/var/www/mydrupal/sites/all/modules/simplemenu
/var/www/mydrupal/sites/all/modules/simplenews
/var/www/mydrupal/sites/all/modules/subscriptions
/var/www/mydrupal/sites/all/modules/swftools
/var/www/mydrupal/sites/all/modules/thickbox
/var/www/mydrupal/sites/all/modules/token
/var/www/mydrupal/sites/all/modules/translation_overview
/var/www/mydrupal/sites/all/modules/transliteration
/var/www/mydrupal/sites/all/modules/ubercart
/var/www/mydrupal/sites/all/modules/video
/var/www/mydrupal/sites/all/modules/views
/var/www/mydrupal/sites/all/modules/views_customfield
/var/www/mydrupal/sites/all/modules/wysiwyg

Sunday, October 18, 2009

drupal custom url / menu permission

Took me some time to figure this out.
If you ever one to have a url which is accessible by anyone,
you may either make a function to return true,
or you may set 'access callback' => '1'...

If it doesn't work, try go to administration > performance > resetting the cache.
The cache is always there, even with cache is off.

drupal access stages

Drupal is built with permission sets in mind.
User may have 1 or more roles.
Content may be limited based on content type, or up to single node level (1record).

When a user is viewing a node / page,
user will have to pass through access "access content".

Next, node may be limited based on content type in:
hook_access

The type of access names can be declared in:
hook_perm


To overwrite permission, you may edit hook_access within the same node module,
or use hook_nodeapi

stages:
  • check for "access content"
  • trigger nodeapi.op = "load"
  • check for hook_access
  • running "hook_view"
  • trigger nodeapi.op = "view"
  • ...
Please advice me if I've missed out or made any mistake here.

Thursday, October 8, 2009

Drupal Logging

Since drupal 6, they have replaced watchdog logging with dblog.
We are open sourcing one of our library for you to easily log onto the database log "watchdog" table.



/*
* log to database
* @param string category
* @param string sLog
* @param string sType
* WATCHDOG_EMERG => t('emergency'),
WATCHDOG_ALERT => t('alert'),
WATCHDOG_CRITICAL => t('critical'),
WATCHDOG_ERROR => t('error'),
WATCHDOG_WARNING => t('warning'),
WATCHDOG_NOTICE => t('notice'),
WATCHDOG_INFO => t('info'),
WATCHDOG_DEBUG => t('debug'),
* @param array variables
*/
function logger_log($sCategory, $sLog, $sType="info", $aVars=array())
{
switch ($sType)
{
case "emergency":
$iType = WATCHDOG_EMERG;
break;
case "alert":
$iType = WATCHDOG_ALERT;
break;
case "critical":
$iType = WATCHDOG_CRITICAL;
break;
case "error":
case "err":
$iType = WATCHDOG_ERROR;
break;
case "warning":
case "warn":
$iType = WATCHDOG_WARNING;
break;
case "note":
case "notice":
$iType = WATCHDOG_NOTICE;
break;
case "info":
$iType = WATCHDOG_INFO;
break;
case "debug":
$iType = WATCHDOG_DEBUG;
break;
default:
$iType = 999;//unknown
}

$aLog = array(
"user" => $GLOBALS["user"],
"type" => $sCategory,
"message" => $sLog,
"variables" => $aVars,
"severity" => $iType,
"request_uri" => $_SERVER["REQUEST_URI"],
"referer" => $_SERVER["HTTP_REFERER"],
"ip" => $_SERVER["REMOTE_ADDR"],
"timestamp" => time()
);

dblog_watchdog($aLog);
}

Tuesday, October 6, 2009

Planning on a CMS?

Developing a CMS with proper framework is not easy.
cox in php, u get nothing like dotnet framework has, unless we are taking up other framework to build from. But a lot of things to be considered when building a cms.
from user, roles n permissions, to modules, module access permissions, theming an templating, database layer, workflow of articles, sticky, search engine, tags, sections and categories and media of publishing(html, pdf, print). And all this has to be within MVC concept...

Good thing about using drupal is that it gives a lot of control to developer, without having to hack the core of drupal.
If we don't need to hack the drupal core, then can get security fixes easily.
Drupal has their team of security hacker do tests on codes of community contributed modules for flaws. Using drupal is like having team of unlimited n growing community to help build the portal, and someone to keep an eye watch on the updates and customise things based on user requirement.

Here are some good example of benefit of drupal:
http://www.youtube.com/watch?v=lzt-9vbXztI

The Drupal Advantage
* Most popular and most powerful open-source CMS
o huge install base
o massive, active development community
* Drupal is a CMS and an effective application framework
o clean, extensible code base
o many high-quality modules available for add-on capability
o keep custom, proprietary code to a minimum
o build highly functional custom modules to accomplish practically any task
* High performance
o built-in caching
o integrates easily with 3rd party caching mechanisms
o infinitely scalable
* SEO friendly right out of the box
o standards-compliant HTML/CSS
o capable of custom (HTML) page titles, meta descriptions
o customizable, friendly URLs
o permalinks
o simple Google Analytics integration (without writing or inserting code)
* Extremely well documented
* Mature, going into seventh major release
* Flexible, powerful theming engine separates content completely from presentation; a Drupal site's look-and-feel is limited only to the constraints of imagination and the modern web browser.
* Easy to install and support, runs on Windows or practically any AMP (Apache, mySQL, PHP) stack
* Notable Drupal Features and Selling Points
o Powerful taxonomy system for categorizing content
o User registration and profiles
o Role-based permission system
o Out-of-box RSS feeds
o Browser-based administration

Web sites running on Drupal include:
* The Onion, http://www.theonion.com
* Fast Company, http://www.fastcompany.com
* The Pulitzer Prizes, http://www.pulitzer.org
* Churchill Downs, http://www.churchilldowns.com
* The Kentucky Derby, http://kentuckyderby.com (built by Digett 2004 - 2008)
* Warner Brothers Records, http://www.warnerbrosrecords.com
* AOL Corporate, http://corp.aol.com
* Popular Science, http://www.popsci.com
* thousands more, including virtually all those on Digett's portfolio page

More sites using drupal:
* http://www.avenuewebmedia.com/high-profile-sites-run-drupal

Thursday, September 17, 2009

useful drupal module

Drupal creator has come out with their own drupal hosting service.
It seems that this list of modules would be helpful for most website to have a look into :)

http://acquia.com/products-services/acquia-drupal-modules

Sunday, September 6, 2009

Which CMS is good?

Choice of CMS is pretty much dependent on the purpose of the website and what the users are familiar with.
Its in no doubt that Wordpress is much more user friendly, but its CMS capabilities is not strong. Wordpress is efficient enough for anyone who needs a blog or a normal website with commenting functionality. In designer point of view, it is easy to customise the design to suit websites appearance.

While a lot of people choose Joomla for its CMS features and has more complex usabilities compared to Wordpress. Some websites require more functionality such forums, calendar / event and better component add-on. There is high popularity among providers of websites to choose Joomla in Malaysia in in as their CMS platform.

In contrast, Drupal is more for developer / programmer. Its advance architecture allows most of modules / add-on to be developed without having to modify the core system of the CMS. In terms of components / features availabilities, you may find more add-on available free of charge compared to Joomla add-on.

In developer's point of view, Joomla community has been concentrating on maintaining existing infrastructure, whereby they are keeping a lot of old technology in order to have old compatibility with older version of the CMS. As of joomla version 1.5, they are lacking a lot of back-end administration component builder, forcing developers to hack the CMS core in order to achieve add-on for administration. Hacking the CMS core leads to maintenance update problem as security update cannot be patched without programmer's intervention.
Meanwhile, Drupal community has been actively developing a new platform version which is not compatible with older version of add-on, but maintains security patches for the previous version. The community also actively rewrites most of the core module to suit the new infrastructure changes and new technology changes. While security patches can be updated without much programmer intervention, it will be more cost efficient for maintenance.

Conclusion:
Wordpress Pros
Simple to use - No need for modifications
Excellent for blogging or sharing thoughts in a sequential manner
Even the most elderly of users can get the hang of it quickly
Very user friendly
Easy direct update from administration
Wordpress Cons
Not developer friendly
The community seems to like to complain
Upgrades bring more bugs than fixes sometimes
Possible security issue as hacking core needs long term security maintenance

Joomla Pros
Friendly for all types of users - Designers, Developers and Administrators
Huge community is awesome for assisting with creation of websites
Has been rapidly growing and improving itself for the past three years
Joomla Cons
Still not user-friendly enough for everyone to understand
Not quite as powerful as Drupal, and can be a bit confusing for some to jump into
Possible security issue as hacking core needs long term security maintenance

Drupal Pros
Extremely developer friendly.
Strong community to help discern the dozens (hundreds) of functions and tags available.
Can be used to create some really awesome websites that can outperform a majority of other sites out there.
Low security maintenance as its unlikely the need to hack the core, therefore patching drupal is easy.
More search engine friendly as article URL can be defined as like static page without the need of using dynamic id in URL.
Drupal Cons
Not very designer and user-friendly. It's hard for someone with little code knowledge to make the leaps required to do the very cool things that Drupal is becoming known for.
Theming of Drupal has been a huge case of fail (until recently). Probably because it has been developers, not designers, that are making the themes.
Getting a Drupal website published could cost you more time, and thus more money, than Wordpress or Joomla.

There are no one CMS which will be best suit for all your need. Dependant on your requirements, it would be more time efficient to choose the CMS which you are familiar with and suits your feature requirements.
If you are looking for a simple blog or website with simple commenting and ranking of articles, you may choose Wordpress. If you are looking for more features like forums and calendar /event system without having to change any of the features, it would be best to be Joomla. While if you are planning to choose a very features pack or planning to customise features of the CMS, it would be best to use Drupal.

In business sense, budget CMS would be Wordpress and Joomla. While for corporation looking to customise their own company system and thinking into expanding the system as the corporation grow, it would be best to choose Drupal.

I find myself agreeing with Tim post @

http://www.goodwebpractices.com/other/wordpress-vs-joomla-vs-drupal.html


Tuesday, September 1, 2009

drupal node form

There are times when we needed to create custom layout form design for your node.
In drupal, the theme it called to retrieve the form layout are:
1. [modulename]_node_form
2. node_form

[module]_theme()
{
//... return the array to declare node_form
}

Monday, June 22, 2009

drupal vs wordpress vs joomla

My findings:

Drupal:
Good:
  • very modular
  • able to reuse other module
  • allow theming overrides
  • drag n drop ordering of fields
  • allow custom fields
  • front end & back end having similar login and path
  • good interface
  • inserting folder as module make things simple
  • cutting edge - using tinymce3...
Bad:
  • Complicated admin
  • Slow admin interface as 2 much form input in 1 screen

Wordpress:
Good:
  • allow theming overrides
  • drag n drop ordering of fields
  • allow custom fields
  • nicest gui and friendliness among 3 cms
  • cutting edge technology - using wikimedia, tinymce3...
Bad:
  • TODO

Joomla:
Good:
  • Clearly separate module, controller & view
  • allow theming overrides
  • support hooks

Bad:
  • no custom field support
  • admin no hook support, therefore hacking core is unavoidable
  • some bad component design like jevents use their own templating, which is bad
  • inconsistant template - esp. between category & section
  • interface is like erp, not so good...
  • difficult to reuse other module functions
  • mootool 1.1 & tinymce2 legacy stuff!
  • component/module/plugin installation is tedious, need to pack and clear db if something went wrong

Wednesday, July 16, 2008

Development CheckPoint

We have been working on PHP framework since 2006.
The development was inspired by the popular J2EE project called hibernate data layer, with Zoop Framework for PHP.
Yet, we can call this another PHP Framework.
We wanted full control over the system flow, therefore we have to develop a new one.

There have been many changes on the framework. As we develop on more business modules, we have evolved the framework for many times.
The initial framework was to have a standardized runtime platform to standardize all page call.
From the long URL request,
[Old Method]
http://www.xyz.com/index.php?request=xxx&module=yyy&var1=12345&var2=56443
[New Method]
http://www.xyz.com/runtime.php/xxx/yyy?var1=12345&var2=56443

The end result of URL is much more shorter.
Data Layer
The concept of data layer helps a lot on the standardization on each table.

Example scenario:
On the traditional method, it is difficult to change business /data logic especially on data validation. Any changes on the data logic requirement will effect all modules which uses that table. Traditional method will burden the programmer to work on more modules on each changes requested from the business view. With the new data layer concept, we need only to add the validation onto 1 class file, and it applies to all the modules. This save time and hassle for the programmer.

Presentation Layer
By using PHP Smarty templating, we were able to change the layout of the website easily and fast. Each template can be utilized in many other modules, thus saving time on development.

AMFPHP Web Service
It was later on that we have made our framework to be AMFPHP Service class compatible. Each call to the service (likely to be flash) goes through similar process as the webbrowser. The debug function of our page call were replaced by NetDebug function of AMFPHP for AMFPHP projects.





S.O.A.P Web Service
Then, it was SOAP trend. People were asking if its possible to extend what we develop with third party solutions! It was amazing ! By using XML technology, developer from different languages are able to cooperate on a concept where nearly every development platform could understand. But the initial development wasn't easy. We have to create WSDL defination file to define our services. And in the final stage, our framework took care of the WSDL generation by using Class! No more hassle on WSDL XML file. Just simple OOP declaration! Cool and Simple :)

http://en.wikipedia.org/wiki/SOAP


Modular Concept
It was later we got inspired by Drupal modular and event hook concept. We couldn't resists more of our ego to implement the concept. W00t, we got it running. We each module detectable by the system, user may install, activate or deactivate modules, and even uninstall the module. It was a big leap for us. We no longer requires all files to be chunked into the objectclass folder, but instead, those files now belong to their respective module folder.

Each module is able to have its own data layers and objects folder. It was able to define its own menu list, installation function, uninstall function, page header runtime, page footer runtime, and even declare its own dependencies module list.
User will be able to adminstrate these modules easily from a form in the back office administration screen.



Google Map API

In our recent project, we were requested by our client to develop a map positioning system to map their site intranet software. It was just the right time when Google open up their Google API. It was fantastic! We linked the data type in the data layer of the table column as Google GPS. And several tweaks on the frontend via javascript enable us to allow user to plot their site position on the map. They were as excited as we are :D. We save both the Longtitude and Latitue with the zoom level to the table field. and Wala, our 1st web based Map plotting software integrated as part of our framework :)
We just found out that Google Map API is now available for flash... cool :)


AJAX Field Update
Ajax has been the fancy word behind Web2.0 trend. We were dreaming of having full control of web front end with data layer. As we have a popup "pick" a record window to allow user to choose the field value from another table, we couldn't control the pick data from the value entered into another field. Therefore, we had put ourself in day and night sweat to work on a Ajax field update concept, similar to DotNet concept. The data layer class were stored into database. Everytime someone update a field in the form, it will trigger ajax call to update the data class. JQuery proves to saved us lots of time. Using the Ajax function of jquery was simple and easy. By using JSON, we were able to convert the updated changes from data class to the front end for updates on the form.


Hmm mm.. okay, lets look at our files count, 91 + 4 files of classes ...