Archive for December, 2010
How to create Virtual Hosts using Zend Server CE?
by Raza on Dec.27, 2010, under Uncategorized
Hi guys!
I have been using Zend Server CE as my primary WAMP stack for quite a while, and i really love it. Creating virtual hosts in Zend Server CE is very easy and here is the method for:
- Suppose the Zend Server installation directory is C:\Zend. Below i will refer to the install path as INSTALLDIR.
- Open your httpd.conf file located at INSTALLDIR\Apache2\conf in a text editor, and edit the line
#Include conf/extra/httpd-vhosts.conf
to
Include conf/extra/httpd-vhosts.conf
- Now goto the folder at C:\Windows\System32\drivers\etc and open the hosts file. If you havent yet set the permissions on this file, set it accordingly so that you can edit the file. Add the following lines:
127.0.0.1 localhost 127.0.0.1 myapp.localdev
- Open your httpd-vhosts.conf file located at INSTALLDIR\Apache2\conf\extras in a text editor. Uncomment the line (if commented)
NameVirtualHost *:80and put down the following code …<VirtualHost *:80> DocumentRoot "C:/Zend/Apache2/htdocs" ServerName localhost </VirtualHost> <VirtualHost *:80> DocumentRoot "C:/Zend/Apache2/htdocs/myapp" ServerName myapp.localdev <directory "C:/Zend/Apache2/htdocs/myapp"> Options Indexes FollowSymLinks AllowOverride all Order Deny,Allow Deny from all Allow from 127.0.0.1 </directory> </VirtualHost>
- Now restart the apache webserver. Now, check the urls http://localhost/and http://myapp.localdev/. If no error occurs, then you have successfully configured Virtual Hosting in Zend Server…
How to programmatically add nodes in Drupal?
by Raza on Dec.20, 2010, under Drupal
Hi guys! I haven’t posted anything new on my blog for a long time. Because i have been really busy with work. Currently i am working on drupal, and the project is about creating a villa rentals and sales website. One of the tasks was to import the current client database information into the Drupal CMS. The database had all the rates information in the properties table and all different features for the properties like amenities, location, property type etc were stored in separate tables. To do that, i first created all the vocabularies and taxonomies in the drupal backend to mirror to original features data for properties and then i simply created a new folder called propertydata_import in my sites/all/modules folder. The code for the file is:
; $Id$ name = "Import Properties Data" description = "Import Properties Data" core = 6.x package = "MYSITE"
Now create another file called propertydata_import.module and do the following. I have the whole procedure below in a series of steps and it is important that you follow the order.
<?php
function propertydata_import_help($path, $arg) {
switch ($path) {
case "admin/help/propertydata_import":
$output = '
' . t("Import Property Data into Drupal") . '
';
break;
}
return $output;
}
function propertydata_import_perm() {
return array('administer propertydata_import', 'access propertydata_import content');
}
function propertydata_import_menu() {
$items = array();
//Link to the propertydata_import admin page:
$items['admin/propertydata_import'] = array(
'title' => 'Import Property Data into Drupal',
'description' => 'Import Property Data into Drupal',
'page callback' => 'propertydata_import_callback',
'access arguments' => array('administer propertydata_import'),
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
function propertydata_import_callback() {
$conn = mysql_connect('localhost','YOUR_MYSQL_USER','YOUR_MYSQL_USER_PASSWORD');
if($conn) {
mysql_select_db('YOUR_MYSQL_DATABASE',$conn);
}
$properties = mysql_query("select * from properties;");
while($property=mysql_fetch_assoc($properties)) {
$node = new StdClass();
$node->type = 'property';
$node->status = 1; // Set to 0 if you do not want the content published
$node->promote = 0; // Set to 1 if you do not want the content promoted to the front page
$node->sticky = 0; // Set to 1 if you do not want the content sticky
$node->title = $property["title"];
$node->body = $property["description"];
$node->teaser = $property["description"];
$node->format = 2;
$node->language = '';
/*
Refer to other fields in the results by seeing the content type contemplate variables by clicking http://anguillaluxurycollection.com/admin/content/types/templates and select your relevant content type template. Suppose your content type is 'Property'. To see its contemplate settings, click the 'Edit Template' link to view the content type variables for Body ...
You can enter taxonomy using:
$node->taxonomy[] = array();
*/
$node = $node_submit($node);
if($node) {
node_save($node);
$nid = $node->nid;
$vid = $node->vid;
// Publish the node to the default domain ...
db_query("insert into domain_access(nid,gid,realm) values($nid,0,'domain_id');");
}
}
}