comtersoft » php
Call us today at US: 703 - 349 - 1168 | India: +91 471 - 301 0690

PHP Functions in Javascript - PHP.js

Posted on July 28th, 2009 in Developers Lounge, php | 1 Comment »

 

I found this wonderful site that ports commonly used, built in PHP functions into JavaScript.

Basically, just include the library and you should have all your common PHP functions like strlen, count, in_array, array_keys etc in Javascript. How cool is that!

I find the string manipulation functions most useful. The best part is you can choose to download only the functions that you need, individually, instead of the whole library.

Here is the list of functions currently ported to Javascript: http://phpjs.org/functions/index

Here is the link to the library homepage: http://phpjs.org/

Remember is this just a collection of functions built in PHP and not a framework like Jquery

Drupal eCommerce Framewrok Setup and Configuration

Posted on July 9th, 2009 in Drupal | No Comments »

 

DESCRIPTION:

Drupal eCommerce  module aims to provide an eCommerce framework such as shopping cart for your Drupal website.

INSTALLATION :

It is assumed that you have Drupal site in version 6.x is up and running. Please back up your site and database.

Step1: Download and install the token module for drupal:
http://drupal.org/project/token

Step2: Download and install the rules module for drupal:
http://drupal.org/project/rules

Step3: Download and install the views module for drupal:
http://drupal.org/project/views

Step4: Download and place the entire ecommerce module directory into your desired contrib modules location: eg. /sites/all/modules/

Step5: Enable core modules by going to(use administration Menu module  for easy administration of Drupal driven sites):   > Administer > Site Building > Modules.

With E-Commerce 6.x, each modules are grouped according to function. It is very important to install ecommerce modules in a particular order because of dependencies.

Here is the correct order:

(1) enable the Common and anonymous purchases modules
(2) enable the customer.module
(3) enable the receipting and store.modules
(4) enable the Product API and the address.module
(5) enable the checkout.module
(6) enable the buy now, cart and availability.modules

(Optional) The payment gateway module for paypal is included in the default download of Drupal eCommerce.

Once you have enabled the main Drupal eCommerce modules you can now start to  setup your store by visiting ADMINISTER -> ECOMMERCE CONFIGURATION.

Step6: Drupal eCommerce 4 introduces a cleaner administration section. You can find E-Commerce  settings in two blocks - Just click on Administer then click on:

E-Commerce — day to day administration of your store, managing orders etc.
E-Commerce configuration — your store settings.

You can find individual module settings are also listed there with their descriptions.

Step7: Create new products via:   > Create content > Product

Step8: Optionally, enable the cart block via:  > Administer > blocks :: Shopping Cart

REFERENCES  & LINKS
Main Site           : http://www.drupalecommerce.com
Features list       : http://www.drupalecommerce.org/features
User Documentation  : http://www.drupalecommerce.org/documentation
Support             : http://www.drupalecommerce.org/help

Drupal.org Links:

Project Page         : http://drupal.org/project/ecommerce
Handbook             : http://drupal.org/node/50350
Support Queue        : http://drupal.org/project/issues/ecommerce

eCommerce user group : http://groups.drupal.org/ecommerce
Mailing List         : http://lists.heydon.com.au/listinfo.cgi/ecommerce-heydon.com.au
(Mailing list subject to change)

Developer Links:

Developers API       : http://www.drupalecommerce.org/api
Developers Docs      : http://www.drupalecommerce.org/developers

PHP SimpleXML CDATA Issue - Solution

Posted on July 6th, 2009 in Developers Lounge, php | No Comments »

 

After hours of searching and using complicated functions to parse XML in PHP (simplexml) with CDATA I found this link that gives you the solution simply.

Normal XML files when passed to simplexml_load_file() will return an array with the tag name and value like this:

XML:
<GradeLevel>
	<GradeLevelItem>
		<GradeID type='Number'>1</GradeID>
		<Grade type='Text'>Primary K-3</Grade>
	</GradeLevelItem>
<GradeLevel>
SimpleXML output
SimpleXMLElement Object
(
    [GradeID] => 1
    [Grade] => Primary K-3
)

But, when the value is in CDATA you will not be able to access the value directly, like this:

XML:
<GradeLevel>
	<GradeLevelItem>
		<GradeID type='Number'><![CDATA[1]]></GradeID>
		<Grade type='Text'><![CDATA[Primary K-3]]></Grade>
	</GradeLevelItem>
<GradeLevel>
SimpleXML output
SimpleXMLElement Object
(
    [GradeID] => SimpleXMLElement Object
        (
            [@attributes] => Array
                (
                    [type] => Number
                )
        )

    [Grade] => SimpleXMLElement Object
        (
            [@attributes] => Array
                (
                    [type] => Text
                )
        )
)

To get the outut in the exact same way as the first case (to access the value) all you need to do is to pass a few extra params and the built in simplexml_load_file() function will do it for you automatically like this:

simplexml_load_file($file, 'SimpleXMLElement', LIBXML_NOCDATA);

This is the link that saved me:
http://blog.evandavey.com/2008/04/how-to-fix-simplexml-cdata-problem-in-php.html

The secret of getting ahead is getting started. ComterSoft is the starting point