Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Events
Videos
Audiobooks
Packt Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds

How-To Tutorials

7019 Articles
article-image-cms-made-simple-16-getting-started-e-commerce-website
Packt
19 Mar 2010
10 min read
Save for later

CMS Made Simple 1.6: Getting Started with an E-commerce Website

Packt
19 Mar 2010
10 min read
With the Products module, you can manage: Products Product attributes that will have an impact on the price (like size or color) Categories Product hierarchy Custom fields This module is the basis for all other modules that you will use later on. After all, you cannot start a shop if you do not have any place to store the products. Install the Products module with the Module Manager. Pay attention to the Dependencies section of the module before installing it. There are two (CGExtensions and CGSimpleSmarty) modules that provide convenience APIs, reusable forms, and Smarty tags for use in other modules. If you are not a programmer, you probably will not need to do anything with these modules besides adjusting some preferences if you ever need them. In the workshop described here, you just need to install them. Time for action – adding the first product After the Products module is installed, we will display it on the page Shop and add the first product to it as follows: Create a new content page Shop (Content | Pages | Add New Content). Add the Smarty tag {Products} into the field Content of the page. If you see the page in browser, it will not show anything at this time as you have not added any product to the shop so far. In the admin console of CMS Made Simple, click on Content | Product Manager. Under the Products tab, click on the Add A Product link and add your product as shown in the following screenshot: Click on Submit and see the Shop page on your website. What just happened? You have added the first product to the Products module. This product is displayed on the page with the Price and Weight (we can delete this field later on). Click the product link to see the detailed view of the product. The template looks very technical, but with some HTML, CSS, and Smarty knowledge you can change its look and feel later on. Let's concentrate on the functionality of the module first and not on the design. Add some more products in the Product Manager and see the list of products on the Shop page. Pay attention that the detailed view of every product is displayed in the same way. In the Products module, there are some fields like Price and Weight already defined. But you will need to add your own fields. Creating custom fields Usually one or more pictures of the product can be found in an online shop. However, there is no special image field where you can upload the product picture. Luckily, you can add as many custom fields as you need. In the next step, you will create a custom field, where the image of the product can be uploaded. In the admin area of the Product Manager, choose the tab Field Definitions and click on the link Add A Field. Name is a kind of technical field that is not displayed to your visitors. You should not use any special characters or spaces in the name of the field. Use only letters and numbers, no dashes, slashes, or anything else non-alphanumeric. The Prompt field is the label of the field that you will see in the admin area of the Product Manager during adding or editing products. You can use any characters in this field. The Type of the field should be Image. By selecting this type you ensure that the field is displayed as a field for file uploads in the admin area. This field will also be validated, so that only images can be uploaded here. Additionally, thumbnails for the uploaded images (small preview versions) will be created automatically after upload. Let the field be public by selecting the checkbox for Is this a public field? It means that the content of the field (the image itself) will be shown to the visitors of your shop. If you make it private, only the administrator of the website can see the field in the admin area of the module. Save the field. This field is automatically added to the detail template on the page and the editing view of the product in the admin area of the Product Manager. To test the field, open any product for editing in the admin area, and the field Product image (Prompt), and upload an image for the product using this field. Control the display of the field in the detailed view of the product on the website. The small preview version of the product is added to the section Custom Fields of the detailed view. We still do not care of how it looks like, but how it works. We will change the detailed view of the product when we are ready with all the custom fields and the product hierarchy. Image already exists When you try to upload the same image twice you will get an error saying that the image has been already uploaded. To control what images are already saved for the product and delete them, open Content | File Manager in the admin console. Find the folder Products and then the folder name product_[ID]. The ID of the product is displayed in the list of products in the admin area. Click on this folder and remove the images already uploaded. Now, you can upload the same image in the admin area of the Product Manager. Define your own fields Create as many custom fields as you need to display and manage the product. With the Type of the field you decide how the field is displayed in the admin area. The output of the field on the page can be fully customized and does not depend on the type. If you need a Product Number field, create a new custom field (Text Input) with maximum length of 12 characters and make the field public. Then edit each of your products and enter a number in this field. You can adjust the order of the fields under the Field Definitions tab. Again, this order only applies to how the admin area for the product management looks; the output on the page can be completely different. Creating a product hierarchy Next, let us create a product hierarchy. In the official shop that I am trying to reproduce here, there are four hierarchy items: Shirts (short) Shirts (long) Home & Office Mugs You should understand the difference between product categories and product items in the Product Manager module. Product categories are kind of tags for the products. It is not possible to arrange them in the hierarchy. However, you can assign one product to multiple categories if you like. In contrast to the categories, a product can belong to only one hierarchy item. That means the structure above should be implemented as a hierarchy and not as categories. One product cannot be a shirt and a mug at the same time. We will use categories later on to mark the products as: New Popular Discounted Categories will allow you to make one product both new and discounted at the same time. A hierarchy would not, as multiple assignment is not possible. In the admin area of Product Manager, click on the Product Hierarchy tab and create four hierarchy items displayed in the first list. It is your choice if you want to add any description or image to the hierarchy or leave it empty. Once the hierarchy is created, go through your already created products and assign them to the proper hierarchy item. The hierarchy can now be displayed in the sidebar navigation on the page. Open the main page template (Layout | Templates) and find the section with sidebar navigation. Add the Smarty tag for the product hierarchy shown as follows: {Products action="hierarchy"} Customizing product templates The display of the product hierarchy template is very technical. Let's customize all the templates for the module. There are three of them: Summary Templates Detail Templates Hierarchy Report Templates Let's start with  the Hierarchy Report Templates. This template defines how the hierarchy in the sidebar is displayed. In the admin area of the Product Manager, click on the Hierarchy Report Templates tab and find the list of existing templates for the hierarchy. The template Sample is the one that is used by default. You can customize this template or create your own by clicking on the New Template link. I choose the second way. It is generally advisable not to change sample templates, but create your own and set them as default. This way you can delete anything from the custom template and use the Sample template for reference if you need parts removed from the custom template. For the template name, I chose My Shop. However, you can use any name you wish. In the Template Text field, the sample template code is already suggested. Leave this code as it is and submit the new template. Now you see two templates in the list. Make the template My Shop the default one by clicking on the red cross in the Default column. Let's see what we have in the template and what we actually need. Open the new template for editing: Smarty variable Description {$hierarchy_item.name} The name of the hierarchy item {$hierarchy_item.id} The ID of the hierarchy item {$upurl} The URL to the parent hierarchy item. Only applicable if there are more than one hierarchy level. {$mod} The object containing all the information about the module Products. In the template the object is used to get translations: {$mod->Lang('parent')} returns the translation for the key parent from the translation file. You can replace this variable with your custom text if your website is monolingual and the language of the website will never be changed. {$parent} This array supposes to hold the information about the parent item. However, it is not assigned in the current version of the module and cannot be used. {$child_nodes} The array that contains information about all child hierarchy items. The information from this array: {$child_nodes.id} - ID of the hierarchy item {$child_nodes.name} - name of the hierarchy item {$child_nodes.description} - description of the hierarchy item {$child_nodes.parent_id} - ID of the parent hierarchy item {$child_nodes. image } - the name of the image file for the hierarchy item {$child_nodes. thumbnail} - the name of the thumbnail file for the hierarchy item {$child_nodes. long_name} - the full name of the hierarchy item (including the names of all parents) {$child_nodes. extra1} - the value saved in the Extra Field 1 {$child_nodes. extra2} - the value saved in the Extra Field 2 {$child_nodes. downurl} - the URL for this hierarchy item {$hierarchy_image_location} Path to the folder where images for the product are saved. {$hierarchy_item} An array that contains the id of the actual item hierarchy.
Read more
  • 0
  • 0
  • 2574

article-image-enlighten-your-desktop-elive
Packt
19 Mar 2010
9 min read
Save for later

Enlighten your desktop with Elive

Packt
19 Mar 2010
9 min read
Enlighten your desktop with Elive Unless you're an old Linux user, you've only probably used the KDE, GNOME or Xfce desktop environments. But since the time when these desktops were in their infancy, the Enlightenment desktop environment has been impressing users. Bringing this mature, visually appealing environment to new Linux users is what the Elive distribution is all about. On its website, Elive claims to be more than a simple Linux distro, rather a work of art. I might be a little biased but that's probably true. One look at Elive's graceful and charming environment and you are sold. And unlike today's 3D visualization, Elive can run efficiently on older systems as well with a gamut of desktop applications. Its got detailed documentation Wiki and an active forum to answer questions. Elive's been in development for several years now and in fact is so popular that its developer, Samuel "Thanatermesis" F. Baggen, works on it full time. In this month's article, Samuel explains his reasons for spinning Elive and how the distro has evolved over the years. Mayank Sharma: Please tell us a little about yourself and your interest in computers in general and Linux in particular. Samuel Baggen: When I was 12 years old I got my first computer -- an 8086 with MS-DOS command line. Shortly after I got that system, the monopoly of Microsoft swept in and introduced Windows. A simple front-end of MS-DOS in graphical mode, which took a lot of memory for computers (especially my little PC). I grew very tired of Windows and wanted to go back to the command line after some years, but it seemed I was going against the grain. The majority of the systems were using Windows and all the applications too were written for Windows. It seemed I had no other option except Windows. When I was 18 years old, a friend of mine started telling me about this thing called "Linux" -- an ingenious system without errors, reboots, problems or viruses. It was much faster, efficient, and finally free of charge... an unbelievable thing. Then I started using Linux, reading the documentation and learning how to use its very powerful command-line system. I needed to spend some serious time learning the graphical system, but when I got the GUI running, it didn't appeal to me. I tried many window-managers, but I was never satisfied. There was one that piqued my curiosity...Enlightenment. I promised myself to take a better look at this curious window-manager between my time working at the command line. Soon I found a system called Knoppix -- a Linux system that worked directly from the CD-ROM without installing. I really liked the system and the many others that came after, but I found they were all just a simple copy of the standard Knoppix, with the background and the name changed. I couldn't find any with Enlightenment. So I chose to make a very different modification of Knoppix that included Enlightenment. The resulting system was called Tezcatlipotix, but I couldn't put it to the public because it contained copy-written music, video clips, and other commercial applications too. I decided to share my vision with the public, so I started working on Elive. My goal was to make a liveCD that was very different, easy to use, intuitive, and most importantly ran Enlightenment. I tailored it for my tastes and for practical functionality. For example, Elive won't use icons on the desktop, even if Enlightenment 17 adds a feature to include desktop icons.   MS: But what was it about Enlightenment that made you spin a distribution around it? SB: I was very disappointed by the other window-managers. Most are slow, unattractive, non-functional, but most importantly I felt they were counter-intuitive and lacked practicality. I firmly believe that you don't have to emulate Microsoft Windows, to achieve a responsive and functional system. You all are more than welcome to test the easy, usable and lightning fast responsiveness of Elive.   MS: Break down Elive for us technically. Why choose Debian as base? Do you bundle non-free software like MP3 codecs, etc? Does Elive have a repository of its own? SB: Yes, Elive has it own repository with more than 400 Elive specific packages. Some are just rebuilt with minor changes like tweaking their default configuration files, or including skins, etc. Everyone knows why you'd choose Debian as a base system, this is no secret. It's package management is pristine, it's the most stable, secure and trustworthy system available. If a thing such as an MP3 codec is not free, but free to redistribute, Elive includes it. MP3's are heavily used by everyone, whether in your MP3 player, or for internet streaming. Elive is a usable product that is practical in this day and age. We want everyone to have readily access to their MP3's as soon as the system boots.   MS: Are you a one-man development house as well? Do you get any contributions from users? Talking of which, how's Elive's user community? SB: Yes, I'm the only developer of Elive. It's a tremendous amount of work and very time consuming. Yet I realize that If I'm to have total control over my vision of Elive, then this must be the case, so that no one can say, "Don't do this or that!" I have full discretionary power, but Elive is made for the public, so user suggestions are pertinent to Elive's development. On the other hand, I receive much help from a small community of people in many ways. Translations, system tests, benchmarks (very important, without tests and bug reporting, the systems won't work correctly), and also some coding for miscellaneous things. The community helps design art, applications, and PHP code for the Elive website. Support also comes from Elive users who make a donation for the Elive stable downloads and the new Bonus Discs. This is very important. Without this collaboration, Elive wouldn't exist because developing Elive is my full-time profession.   MS: What are these Bonus discs? SB: This is a new feature of Elive. Put simply it consists of a CD that you insert in your Elive system and it's directly launched. The Bonus Disc then installs the package. For example, the first (and currently the only one available) is the Bonus Disc for OpenOffice. You just burn the iso and put it in your Elive system. The Bonus Disc installs OpenOffice automatically, prompting only for language preferences. With this bonus disk you have a very easy and fast way to properly install OpenOffice with the menus having the GTK look. I have more bonus-disks planned for the future, especially for games. I'm hard pressed to find time to make them, but they will come sooner or later.   MS: On the website you say Elive's more of a distro than a Live CD. Could you explain this a little? SB: Yes, I continue to stress this fact because of the misconception that Elive is just a Live CD. The name alone causes some to think otherwise. Some people think, Elive is "Enlightenment Live". The install button is a little hard to find for some users for the first time :) Elive started as a Live CD, but actually it's more a complete system than a live CD. This is why I have moved from Knoppix to Morphix, and after that to DSS (Debased Scripts Set). Elive has a very good installer with nice internal features, and it's own repository with more than 400 packages. Elive in the liveCD mode is just the pure Elive system with virtual changes to make it all work in live mode. Which means installing Elive to the hard disk, installs a clean system without any trace of the live CD elements. Elive is a system for day to day usage. Its goal is to be a system that's ready to use, and quick and easy to work with. There are many users who have used Elive day-to-day as their main system for years.   MS: You can't read a review of Elive without the reviewer mentioning the Elive Panel. Is that something you wrote? What areas of Elive does the panel control? Have you written more such custom tools for Elive? SB: Yes, I wrote Elpanel as a central control center for managing the entire Elive system. Elpanel has menus icons to control the look and feel of the system, do some user configurations and general administration. The icons launch a separate, but integrated Elpanel menu, with animations that tempt the eye. I have written many tools for Elive, some are visible applications, but most are shell scripts for auto-configurations, etc.   MS: How has Elive evolved over the years? Do you still recommend using ReiserFS? SB: I have tried to make the system easier to use overall. The hardware recognition has gotten a lot better. Some users say that it's better than some of the bigger distributions :) I have also added most of the things that users have requested between releases. Since so many users have laptops, it's mostly Wifi drivers and such, adding which is truly a daunting task. As for the filesystem, yes, I personally continue recommending Reiserfs (version 3). In my experience it's the best, but I don't want to get into that discussion here because many people like to debate about things (flame wars). It's just my personal preference.   MS: You've just released Elive 1.0. What are the highlights of this release? SB: It's very stable system that's ready for day to day usage. Elive 1.0 has been rigorously tested, has great drivers, nice auto configurations, and enhancements for the end-user. The Elpanel application is always getting better and better. There are many more things that are listed on the Elive website.   MS: What are you working on for the next Elive release? SB: On top of my list are, new kernel, more drivers (especially more Wifi implementations), and the very much sought after Enlightenment 17 in Elive Gem 1.0. Mayank Sharma is a freelance writer from New Delhi, India. He is blown away by the power of Free and Open Source Software and its usefulness to developing nations. Check out his blog at http://www.geekybodhi.net/         Share This Article Save to del.icio.us      
Read more
  • 0
  • 0
  • 3741

article-image-roles-alfresco-14
Packt
19 Mar 2010
9 min read
Save for later

Roles In Alfresco 1.4

Packt
19 Mar 2010
9 min read
Roles in Alfresco 1.4   The article explains the basics involved in understanding Alfresco authorization and the means to extend its functionality, for example, to adapt it for any special requirements through configuration files. The concepts explained in the article will be useful for anyone who has started working with Alfresco code. In addition to this, a little step-by-step example towards the end helps you extend the initial Alfresco roles. Read out more in the article written by Alfonso Martin. Once you have started with Alfresco, you will realize that you need to create or expand the default roles included with Alfresco. This task (at this moment) must be done manually through configuration files. Before diving into the Alfresco.war file to search for the property configuration files, you will need to understand a few concepts. This article will introduce you to the basics in Alfresco's role policy. The basic concept in action authorization in Alfresco is that of permission. Permissions dictate when an action can be executed on an object by a user. Key concepts in defining authorization policy in Alfresco are: PermissionSets PermissionGroups Permissions GlobalPermissions Such elements are declared in the permissionDefinitions.xml file, located in WEB‑INF/classes/alfresco/model inside the Alfresco.war file. PermissionSet Collections of permission groups, permissions, and dynamic authorities with common attributes: type: (Mandatory) PermissionSet is defined over a type or aspect. If it is defined over a type, then it is applicable for all objects of that type; if it is defined over an aspect, then it is applicable for all objects that have the same aspect. expose: (Optional) This attribute restricts the domain of Type. If the value is all, it is allowed to apply a PermissionSet to objects, which have a parent that satisfies the Type attribute. Otherwise, if the value is selected, the set is only applied to objects that satisfy Type attribute. All is assumed, if the attribute is undefined. PermissionGroup PermissionGroup defines its behaviour through several attributes: name: (Mandatory) Group identifier. type: (Optional) Same as in permissionSet. extends: Determines if the permissionGroup extends the definition of a previous group with the same name. If undefined, default value is false. expose: Restricts the domain of type, and if true, the permissionGroup will be applied to objects (and derivatives) that satisfy the attribute type. If it is undefined, then false is assumed. allowFullControl: If true, group has all privileges, else the privileges are to be assigned. requiresType: If false, permissionGroup can be applied to any object, otherwise only to objects that satisfies type. If undefined, the default value is true. PermissionGroup can be composed by several permissionGroups, whose sub groups will be identified by name and type. If type is omitted, the parent’s type will be used. Permission A permission is the minimal unit to represent an authorization of an action on an object. It is defined by: name: Permission identifier expose: If true, the permission can be applied to derivative objects, otherwise only to objects defined in a permissionGroup context. Default value is false requiresType: If true, a permission can only be applied to objects defined by its group context. If it is omitted, default is false A permission can require the authorization of other permissions, such permissions are identified by: name type on: Specifies where the permission is required—node, parent, or children. implies: If true, the required permission grants itself the parent’s permission. There can be only one required permission with attribute implies equal to true. If omitted, the default value is false. Inside the permission are the declarations of the permissionGroups that contain said permission. These declarations require existent permissionGroups, and can optionally specify the node types where the permission will be applied will be applied to all nodes. GlobalPermission These kinds of permissions are defined outside a permissionSet, and are applied to all nodes in the hierarchy (irrespective of its type and related aspects). This kind of permission prevails over other permission types. Roles Roles in Alfresco are a special type of permission group, concretely permissionGroups, which are defined in permissionSets applied to nodes of type content. To use these roles in the Alfresco GUI, it is necessary to create appropriate tags in the internationalization files, more specifically, the webclient.properties (this file can vary in function of language/country) and is typically located in WEB‑INF/classes/alfresco/messages Predefined Roles Alfresco defines a few basic roles in the permissionDefinitions.xml. These roles are defined in an incremental manner. First, it creates a Consumer role and then defines the rest of the roles, adding functionality to the Consumer role. Predefined roles are: Consumer: Allows read properties, content, and children of a node. Editor: Adds to consumer privileges the ability to write nodes (properties, content, and children) and execute CheckOuts in nodes with aspect lockable. Contributor: Adds to consumer privileges the possibility of adding children and execute CheckOuts in nodes with aspect lockable. Collaborator: This role has the same capabilities as Contributor and Editor. Coordinator: This role has all privileges including the possibility of taking ownership of nodes, and changing its owner. Administrator: Same as Coordinator, it is defined for backward compatibility. Default Permission Policy After a first check out of the permissionDefinitions.xml file in Alfresco 1.4, you will find five major PermissionSets. These sets establish node permissions across the Content Model hierarchy: It starts with base type, which defines basic low-level permissions. The next set defines permissions for the cmobject node types, which at this level are defined in the permissionGroups and later will be extended by roles. Content nodes have a set, which defines the available roles. In addition to these sets, the permissionDefinitions.xml file includes two other sets. One of these sets is for nodes that have the aspect ownable, and the other is for nodes that have the aspect lockable. The permissions defined in such sets allow the execution of typical specialised actions with these kinds of nodes—Check In, Check Out, Take Ownerships, Change owner, Lock, and Unlock. After PermissionSets, the configuration file declares GlobalPermissions. These permissions will be applied to all nodes, and they have priority over other permission types. At the moment, these permissions are: FullControl: Allows users who have any of these roles—ROLE_ADMINISTRATOR or ROLE_OWNER. Unlock, CheckIn and CancelCheckOut: All these allow users who have their role defined as ROLE_LOCK_OWNER New role definition example: This example is based on ideas explained in one of the Alfresco forums. The case study is the typical context, where three specialized folders are needed—Drafts, Pending approval and Published. Drafts: Stores actual working documents. Pending approval: This folder contains documents whose author(s) has/have requested approbation. Published: Stores final versions of documents. Preconditions There exist two differentiated user groups—Creators and Approvers. Creators have full access to folder Drafts and read access in Published; Approvers have full access to Pending approval and Published. Creators need to move documents from Drafts to Pending approval, but cannot see the folder files. To model this situation, we create two user groups called Creators and Approvers. Then create three spaces Drafts, Pending approval and Published. Each space will have the following configuration: Drafts: Uncheck Inherit Parent Space Permissions checkbox. Invite group Creators with role Collaborator. Pending approval: Uncheck Inherit Parent Space Permissions checkbox. Invite group Approvers with role Coordinator. Published: Uncheck Inherit Parent Space Permissions checkbox. Invite group Approvers with role Coordinator. But as you can see, with this configuration there exists a situation with the prerequisite: Creators need to move documents from Drafts to Pending approval, but cannot see the folder or files. Alfresco does not include any role that satisfies this. So, it lets you create it. Open the permissionDefinitions.xml file. First define a low level permissionGroup called CreateNodes, this group should be defined inside permissionSet with type base; in other words, available for all kinds of nodes. Also inside this set we need to declare the permissions that compose this permission group: In our case only the permission _CreateNodes. ...   <permissionSet type="sys:base" expose="all"> .../p>   <permissionGroup name="CreateNodes" expose="true"   allowFullControl="false"/> ...   <permission name="_CreateChildren" expose="false">     <grantedToGroup permissionGroup="CreateChildren"/>     <grantedToGroup permissionGroup="CreateNodes"/> <!-- New -->   </permission> ...   <permissionSet/> Then we need to define a role called Writer (remember, in set with type content), this role extends the behavior of a permission role declared in the set with type cmobject. The permissionGroup, Writer will include previously defined CreatedNode. ...   <permissionSet type="cm:cmobject" expose="selected"> ...     <permissionGroup name="Writer" allowFullControl="false"                                                        expose="true">       <includePermissionGroup type="sys:base"                                       permissionGroup="CreateNodes"/>     </permissionGroup> ...     <permissionSet/>   <permissionSet type="cm:content" expose="selected"> ...     <permissionGroup name="Writer" extends="true" expose="true"/> ... With these additions, we have created a new role called Writer that will solve our little situation. To be allowed to use it in the Alfresco GUI we need only to add a properly internationalization tag in webclient.properties: Writer=Writer role [...] Writer= OurWriter role And now we can invite the Creators group to the Pending approval space with the Writer role. The creators will be able to move documents from Drafts to Pending approval, but they will not be able to read the folder. The last operation is to add a rule called Request approval in the space Drafts that moves documents from Drafts to the space Pending approval. This is a trivial example for homework where you can try to add rules  in spaces with simple workflows to formalize the process  of  approbations and rejections.
Read more
  • 0
  • 0
  • 2334

article-image-increase-website-traffic-free
Packt
19 Mar 2010
5 min read
Save for later

Increase Website Traffic for FREE

Packt
19 Mar 2010
5 min read
Increase Website Traffic for FREE There are many techniques to getting more visitors to your website or blog. Here are a few of the better ways of getting more visitors to your website. Oh, and they're all free and you should be able to implement most in just a few minutes. Firstly, some things to keep in mind as you read these tips and tricks for getting more, free, website visitors... Google looks at your website and tries to think how a human would think.If a real person would rate your website highly, then so will Google. Google reads the words on your website.Phrases that you want to get found with should at least appear somewhere on your website. A real person would rank more highly a website with lots of links to it. If lots of other people link to the site then it must be popular.Google ‘thinks’ in exactly the same way using a technique called Page Rank or PR. More on this later. Content that changes is more interesting for repeat visitors,and Google rates more highly websites that change frequently for this exact reason. OK, with these key ideas in mind, lets move on to sending more people to your website. Who knows, the increase in website traffic may increase inquiries, orders and profit! Change your writing style As an example, take the last sentence from the previous paragraph. It used to read like this... OK, with these key ideas in mind, lets move on... This sentence would be OK in the real world, but it contains no words of any importance or relevance to our topic. The sentence was edited to contain pertinent words relating to increasing website traffic and now reads like this... OK, with these key ideas in mind, lets move on to sending more people to your website. Who knows, the increase in website traffic may increase inquiries, orders and profit! Look at every sentence on your website. Does it stand up on its own? Cut out the clutter and add key words and phrases. If you sell cars, avoid impotent phrases like "Customer Service to Rely On" and use phrases such as "Discount Car Dealership, Midlands UK". Potential visitors searching on Google won't be searching for "customer service", but they will be searching for "car dealership, midlands". Another small tip relating to your writing style is to use all derivatives of words. Take for example the car dealership. Visitors searching Google might type "dealership" or they might type "dealer". Try to use both in your text to appear in as many search results as possible.Get Inbound Links Links to your website from others offer two great benefits. Visitors to the other sites might see the link to your site and pay your site a visit. Your website Page Rank will be increased as your site now looks more popular. One of my favourite websites for blagging a free link from is www.pagemost.com. Fill in the small form on the home page and they build a page for you based on your location (give a false postcode if you're not location based). This free page is built to do well on search engines and includes a link back to your website. www.pagemost.com has a Page Rank of 5 at the time of writing, which is well worth getting a link from. To get your free page found, www.pagemost.com do recommend that you link to it from your own page, otherwise the search engines won't know it exists. On this note it's worth mentioning that although you want to get as many inbound links as you can, you should also avoid adding too many outbound links. Ebay How can Ebay help increase traffic to your website? Ebay is a very popular website and links from it to your own website will make your site look more popular. By ensuring that you always have auctions on the go at Ebay, you will always have links to your own website. It doesn't matter what you are selling as long as you remember to add links to your own website from each auction. Wikipedia It's not relevant to all websites, but why not give your website a mention and a link in Wikipedia. Most pages in Wikipedia have links to external sites, so why not add yours! If you are blatantly spamming then be prepared to be removed straight away, so make sure your website is related to the topic in question. Home Page Re-write a portion of your home page every month. Adding news items is a great way to force you to do this and gives you a reason to change the page monthly. And don't forget, a website with out of date news items looks as though the company has gone bust, so once you start this technique for generating website traffic it is most definitely an on-going process. Conclusion Re-write your website content or get somebody to do this for you. Include good words and phrases and cut out the dross! Get links to your site from sites like www.pagemost.com Get some auctions underway on Ebay See if any pages in Wikipedia or similar will handle a link to your site  
Read more
  • 0
  • 0
  • 2006

article-image-setting-python-development-environment-mac-os-x
Packt
19 Mar 2010
12 min read
Save for later

Setting Up Python Development Environment on Mac OS X

Packt
19 Mar 2010
12 min read
I decided to use the /usr/local directory as destination and compile everything from source. Some people favor binaries. However, binary distributions are often pre-packaged and end up in some sort of installer - they could contain certain things that we dislike and so on. This is also the case with Python on Mac OS X. You can download binary distribution from the official Python website (and you are in fact encouraged to do so, if using OS X), which suffers exactly from these kind of problems. It comes with an installer and installs some stuff out of the /usr/local directory which we don't need. It maybe useful to some of the Cocoa developers who deal with the Python code also, as it eases the installation of the PyObjC (a bridge between the Python and Objective-C) later on. But we don't need that either. We will end up with the pure, lean and mean installation of Python and some supportive applications. Setting Up Python Development Environment on Mac OS X Background First, a bit of a background. You run Mac OS X, one of the finest operating systems available to date. It's not just the looks, there is a fine machinery under the hood that makes it so good. OS X is essentially a UNIX system, more specifically BSD UNIX. It contains large chunks of FreeBSD code which is a good thing, because FreeBSD is a very robust and quality product. On top of that, there is a beautiful Aqua interface for you to enjoy. For some people, this combination is the best of both worlds. Because of the UNIX background, you get many benefits as well. For instance, you have quite a collection of useful UNIX tools available for you to use. In fact, Apple even ships Python out of the box! You may as well ask yourself why do I then need to install and set it up? - Good question. It depends. OS X is a commercial product and it takes some time from release to release and because of that Python version that is shipped with the current OS X (10.4) is a bit old. Maybe that is not an issue for you, but for some people it is. We will focus on getting and installing the newest Python version as that brings some other benefits we will mention later. Remember that /usr/local thing from the beginning? And what's up with that "safe heaven" talk? Well, there is a thing that is called Filesystem Hierarchy Standard, or FHS. The FHS sets up some basic conventions for use by UNIX and UNIX-like systems when mapping out a filesystem. Mac OS X breaks it at some places (as do many other UNIX variants) but most systems respect it. The FHS defines the /usr/local as the "tertiary hierarchy for local data installed by the system administrator", which basically means that it is the safe, standard place for you to put your own custom compiled programs there. Using the /usr/local directory for this purpose is important for many reasons but there is one that is most critical: System Updates. System Updates are automatic methods used by operating systems to deliver newer versions of the software to their users. This new software pieces are then installed at their usual location often with brute force, regardless of what was there before. So, for instance if you had modified or installed some newer version of some important system software, the Software Update process will overwrite it, thus rendering your changes lost. To overcome this problem, we will install all of our custom software in this safe place, the /usr/local directory. Getting to Work At last, the fun part (or so I hope). Requirements First, some prerequisites. You will need the following to get going: Mac OS X 10.4 XCode 2.4 or newer (this contains the necessary compilers) XCode is not installed by default on new Macs, but it can be obtained from the Mac OS X install DVD or from the Apple Developer Connection for free. Strategy As you might have guessed from the previous discussion, I decided to use the /usr/local directory as destination and compile everything from source. Some people favor binaries. However, binary distributions are often pre-packaged and end up in some sort of installer - they could contain certain things that we dislike and so on. This is also the case with Python on Mac OS X. You can download binary distribution from the official Python website (and you are in fact encouraged to do so, if using OS X), which suffers exactly from these kind of problems. It comes with an installer and installs some stuff out of the /usr/local directory which we don't need. It maybe useful to some of the Cocoa developers who deal with the Python code also, as it eases the installation of the PyObjC (a bridge between the Python and Objective-C) later on. But we don't need that either. We will end up with the pure, lean and mean installation of Python and some supportive applications. Additional benefit of compiling from source is that we can look through the actual source code and audit or modify it before we actually install it. I will focus on Python installation that is web development oriented. You will end up with a basic set of tools which you can use to build database-driven web sites powered by Python scripting language. Let's begin, shall we? Using /usr/local In order for all this to work, we will have to make some slight adjustments. For a system to see our custom Python installation, we will have to set the path to include /usr/local first. Mac OS X, like other UNIX systems, uses a "path" to determine where it should look for UNIX applications. The path is just an environment variable that is executed (if it's set) each time you open a new Terminal window. To set up a path, either create or edit a file .bash_login (notice the dot, it's hidden file) in your home directory using a text editor. I recommend the following native OS X text editors: TextMate, BBEdit or TextWrangler, and the following UNIX editors: Emacs or vi(m). To edit the file with TextMate for example, fire up the Terminal and type: mate ~/.bash_login This will open the file with TextMate. Now, add the following line at the end of the file: export PATH="/usr/local/bin:$PATH" After you save and close the file, apply the changes (from terminal) with the following command: . ~/.bash_login While we're at it, we could just as well (using the previous method) enter the following line to make the Terminal UTF-8 aware: export LC_CTYPE=en_US.UTF-8 In general, you should be using UTF-8 anyway, so this is just a bonus. And it is even required to do for some things to work, Subversion for example has some problems if this isn't set. Setting Up the Working Directory It's nice to have a working directory where you will download all the source files and possibly revert to it later. We'll create a directory called src in the /usr/local directory: sudo mkdir -p /usr/local/srcsudo chgrp admin /usr/local/srcsudo chmod -R 775 /usr/local/srccd /usr/local/src Notice the sudo command. It means "superuser do" or "substitute user and do". It will ask you for your password. Just enter it when asked. We are now in this new working directory and will download and compile everything here. Python Finally we are all set up for the actual work. Just enter all the following commands correctly and you should be good to go. We are starting off with Python, but to compile Python properly we will first install some prerequisites, like readline and sqlite. Technically, SQLite isn't required, but it is necessary to compile it first, so that later on Python picks up its libraries and makes use of them. One of the new things in the newest Python 2.5 is native SQLite database driver. So, we will kill two birds with one stone ;-). curl -O ftp://ftp.cwru.edu/pub/bash/readline-5.2.tar.gztar -xzvf readline-5.2.tar.gzcd readline-5.2./configure --prefix=/usr/localmakesudo make installcd .. If you get an error about no acceptable C compiler, then you haven't installed XCode. We can now proceed with SQLite installation. curl -O http://www.sqlite.org/sqlite-3.3.13.tar.gztar -xzvf sqlite-3.3.13.tar.gzcd sqlite-3.3.13./configure --prefix=/usr/local --with-readline-dir=/usr/localmakesudo make installcd .. Finally, we can download and install Python itself. curl -O http://www.python.org/ftp/python/2.5/Python-2.5.tgztar -xzvf Python-2.5.tgzcd Python-2.5./configure --prefix=/usr/local --with-readline-dir=/usr/local --with-sqlite3=/usr/localmakesudo make installcd .. This should leave us with the core Python and SQLite installation. We can verify this by issuing the following commands: python -Vsqlite3 -version Those commands should report new version numbers we just compiled (2.5 for Python and 3.3.13 for SQLite). Do the happy dance now! Before we get to excited, we should also verify are they properly linked together by entering interactive Python interpreter and issuing few commands (don't type ">>>", these are here for illustrative purposes, because you also get them in the interpreter): python>>> import sqlite3>>> sqlite3.sqlite_version'3.3.13' Press C-D (that's CTRL + D) to exit the interactive Python interpreter. If your session looks like the one above, we're all set. If you get some error about missing modules, that means something is not right. Did you follow all the steps as mentioned above? We now have the Python and SQLite installed. The rest is up to you. Do you want to program sites in Django, CherryPy, Pylons, TurboGears, web.py etc.? Just install the web framework you are interested with. Need any additional modules, like Beautiful Soup for parsing HTML? Just go ahead and install it… For development needs, all frameworks I tried come with a suitable development server, so you don't need to install any web server to get started. CherryPy in addition even comes with a great production-ready WSGI web server. Also, for all your database needs, I find SQLite more then adequate while in development mode. I even find it more then enough for some live sites also. It's great little zero-configuration database. If you have bigger needs, it's easy to switch to some other database on the production server (you are planning to use some database abstraction layer, do you?). For completeness sake, let's pretend you're going to develop sites with CherryPy as web framework, SQLite as database, SQLAlchemy as database abstraction layer (toolkit, ORM) and Mako for templates. So, we are missing CherryPy, SQLAlchemy and Mako. Let's get them while they're hot: cd /usr/local/srccurl -O http://download.cherrypy.org/cherrypy/3.0.1/CherryPy-3.0.1.tar.gztar -xzvf CherryPy-3.0.1.tar.gzcd CherryPy-3.0.1sudo python setup.py installcd ..curl -O http://cheeseshop.python.org/packages/source/S/SQLAlchemy/SQLAlchemy-0.3.5.tar.gztar -xzvf SQLAlchemy-0.3.5.tar.gzcd SQLAlchemy-0.3.5sudo python setup.py installcd ..curl -O http://www.makotemplates.org/downloads/Mako-0.1.4.tar.gztar -xzvf Mako-0.1.4.tar.gzcd Mako-0.1.4sudo python setup.py installcd .. Do the happy dance again! This same pattern applies for many other Python web frameworks and modules. What have we just achieved? Well, we now have "invisible" Python web development environment which is clean, fast, self-contained and in the safe place to rest on. Combine it with TextMate (or any other text editor you like) and you will have some serious good times. Again, for even more completeness sake, we will cover Subversion. Subversion is a version control system. Sounds exciting, eh? Actually, it's a very powerful and sane thing to learn and use. But, I'm not covering it because of actual version control, but because many software projects use it, so you will sometimes have the need to checkout (download your own local copy) some projects code. For example, Django project uses it, and their development version is often better than the actual released "stable" version. So, the only way of having (and keeping up with) the development version is to use Subversion to obtain it and keep it updated. All you usually need to do in order to obtain the latest revision of some software is to issue the following command (example for Django): svn co http://code.djangoproject.com/svn/django/trunk/ django_src Here are the steps to download and compile Subversion: curl -O http://subversion.tigris.org/downloads/subversion-1.4.3.tar.gzcurl -O http://subversion.tigris.org/downloads/subversion-deps-1.4.3.tar.gztar -xzvf subversion-1.4.3.tar.gztar -xzvf subversion-deps-1.4.3.tar.gzcd subversion-1.4.3./configure --prefix=/usr/local --with-openssl --with-ssl --with-zlibmakesudo make installcd .. However, even on some moderate recent computer hardware, Subversion can take a long time to compile. If that's the case you don't want to compile it, or you simply just use it for time to time to do some checkouts, you may prefer to download some pre-compiled binary. I know what I said about binaries before, but there is a very fine one over at Martin Ott. It's packaged as a standard Mac OS X installer, and it installs just where it should, in /usr/local directory. When speaking about version control, I'm more a decentralized version control person. I really like Mercurial — it's fast, small, lightweight, but it also scales fairly well for more demanding scenarios. And guess what, it's also written in Python. So, go ahead, install it too, and start writing those nice Python powered web sites! That would be all from me today. While I provided the exact steps for you to follow, that doesn't mean that you should pick the same components. These days (coming from the Django background), I'm learning Pylons, Mako, SQLAlchemy, Elixir and a couple of other components. It makes sense currently, as Pylons is strongly built around WSGI compliance and philosophy which makes the components more reusable and should make it easier to switch to or from any other Python WSGI-centric framework in the future. Good luck!
Read more
  • 0
  • 0
  • 10856

article-image-easy-install-gentoo-bling-bling-no-other-one
Packt
19 Mar 2010
13 min read
Save for later

The easy to install Gentoo with bling-bling. No, the other one!

Packt
19 Mar 2010
13 min read
The easy to install Gentoo with bling-bling. No, the other one! Gentoo is a source-based Linux distribution that helps users put together a streamlined custom system. But Linux users spoiled by the see-before-you-try Live CDs would often shy from Gentoo. Then along came Kororaa. Kororaa is a pre-configured binary Live CD for Gentoo Linux that also features an installer. Kororaa's package selection not only makes it an all-round Linux desktop, but has also ruffled feathers of Linux kernel developers. Kororaa's developer Chris Smart probably had the best tutors introduce him to Linux, including Andrew Tridgell, the author of Samba file server. In this discussion with Chris, he talks about why he developed Kororaa, why people interested in learning Linux should use Gentoo, and his new project to help users make the move to Free and Open Source software. Mayank Sharma: Chris tell us a little about yourself? How did you get started on computers? What drew you towards FOSS? Chris Smart: My name is Chris Smart and I live in Canberra, the capital of Australia. My Father was a computer teacher and so I grew up with computers and developed a talent for using them. Over the years through high school I was often fixing friends' computers and this has pretty much continued ever since (although I now only touch open source). When I left high school I deferred University deciding instead to work in the IT industry and in 1999 I started working for a local Internet service provider. At the time certain people were working for a company called "LinuxCare" who were on the same floor in our building. One of these people was Andrew Tridgell (of samba, rsync, etc fame) and it was here I first learned about Linux. Spending time with these fantastic guys gave me perhaps the best introduction to Linux I could have possibly had and I simple fell in love with open source software. Tridge set me up with RedHat 5.2 and I remember him fixing my screen resolution for me in X so that it would work nicely on my 19" CRT monitor. Those were the days :) From there I tried various Linux distributions, moving on from Red Hat and the 'RPM hell' I found myself constantly falling into. It was the year 2000 that I discovered Gentoo and from there I never really looked back. MS: So you had the best tutors. Over to Kororaa and the million dollar question -- Why Kororaa? What hole does it plug? CS: I used Gentoo for many years and over time got tired of the time consuming install process. I also had friends that I wanted to move over to Linux but I found myself spending hours and hours installing their own custom Gentoo for them. This was when Kororaa was born. I wanted a way to easily install a Gentoo system on other computers. At the time there was no installer for Gentoo and so initially my mate Matt and I set out to write an installer for the distro. Not long after however, the "Gentoo Linux Installer" project was launched. This made Kororaa switch focus towards a more custom 'install method' for Gentoo. We wrote our installer and released our first version of Kororaa, which was essentially a pre-configured Gentoo system which installed binary packages onto a computer and automated most of the configuration tasks. MS: Share some of Kororaa's highlights, the High-points, etc. CS: The biggest highlight of Kororaa was when it shot to fame as the first Linux distro to showcase Xgl on a live CD. We had hundreds of thousands of downloads and I think, from memory, we shot up the Distrowatch.com rankings to number 25. Even today, Kororaa is still known as the 'Xgl live CD', even though that was really just a side project to the main aspect which was having a binary install for Gentoo. Even before we released the Xgl live CD however, we were number 100 on the rankings and our Gentoo installer was doing quite well in its own right. MS: But you had trouble with the Xgl Live CD as well. What was that all about? CS: One fine day while we were basking in the success of the Xgl live CD, I received an email from a kernel developer who claimed that distributing the NVIDIA and ATI drivers with the Linux kernel was a breach of the GPL license that the kernel is under. He stated that the drivers were derived works of the kernel and therefore had to be under the GPL license. Either I had to stop distributing the drivers, or stop distributing the Linux kernel. Obviously I couldn't stop using the Linux kernel, but the greater issue for me was "what was the right thing to do?". I spent months and months researching the topic and gathering information to support both sides. In the end I found there was no actual answer and so it came down to a moral judgement more or less. I decided that if it could not be shown that distributing the drivers with the kernel was perfectly legal, then I should be giving the Linux developers the benefit of the doubt and not distribute the drivers. In the end this is what I did. MS: From what I know, you got little help from the community, legal and otherwise. Did the whole episode discourage you? CS: I didn't get much real legal help from the community, just a lot of opinions. You think you have it worked out and then someone from the other side makes a point and then it turns it on its head again. The bottom line for is that there is currently no legal precedence for this issue. As such that makes it hard to find the legal rights and wrongs. I think most people would know that distributing these drivers against the license of the Linux kernel, that's why no-one was doing it for so long. But, because there is this grey area, people convince themselves they are able to do it because no-one can say it's wrong. What's the answer? Legally, I'm not sure. But the Kernel is GPL and so all drivers distributed with the Linux kernel MUST be GPL, that part is very simple and everyone understands that. It becomes grey area when people say that the NVIDIA drivers aren't a derived work of the kernel and therefore don't need to be GPL. But seeing as that is hard to proveeither way, then what we do know is that we are distributing a video card driver for Linux that is not GPL and that to me seems like the wrong thing to do. What I found discouraging was the lack of real answers. Of course there was flaming from both sides with very, very passionate Linux-using people (often without much clue) weighing into the argument with their flaming 2 cents. People told me 'this is why they hate Linux and everyone should use BSD', others telling me to 'grow some balls' and all that sort of junk. But I tried to filter out those and gather information from reputable people, specifically those who could back up their arguments. In the end, removing the drivers killed the popularity of Kororaa, but that is something I was prepared to accept. Still, even now I'm happy that I felt I did the right thing, which was what it was all about in the first place. MS: Hmm. But why did you choose to base it on Gentoo? Any particular reasons, advantages? CS: Because Gentoo is source based, our goal was to quickly replicate a Gentoo system without having to compile packages to do so. Had we been using a different Linux distribution this would not have been necessary. Gentoo gave me the flexibility to build a binary system exactly the way I wanted to and then Kororaa made that easily installable. Originally Kororaa was a great way (well I think anyway) to install Gentoo without having to build it manually yourself. I selected specific packages that I felt fulfilled a certain purpose and this meant that the end user didn't need to know how Gentoo worked, nor what packages they needed. They could simply install Kororaa and have a pre-configured Gentoo system out of the box from where they could begin to learn Gentoo through using and maintaining it. MS: So initially Kororaa had features that Gentoo lacked. But now when Gentoo too sports an installer, is available on installable Live CD and Live DVD versions, where does Kororaa fit in? CS: You are right. Now that Gentoo has their own (working) installer and a live CD as their default environment I'm not sure what role Kororaa can fill, or whether it needs to continue at all. I think Kororaa still is a more customised and simplified system, whereas Gentoo still gives you a lot of flexibility during install time. We also clean up the system andadded our own artwork, attempting to make it look pretty out of the box whereas Gentoo generally just uses the defaults. Still, this might not be enough to warrant the continuation of Kororaa and with the popularity of other Gentoo based distros such as Sabayon, I think Kororaa has reached the end of its usefulness (unless we find some other hole we can fill in Gentoo land). MS: Was Gentoo your first distro? What sort of computer user would you suggest Gentoo as their first Linux distro? CS: I fell in love with Gentoo the first time I installed it. The ability to customise your Linux system beyond just choosing the packages to install was incredible and for the first time I felt in control of my computer. That's a pretty powerful thing and no other Linux distribution has ever given me that same feeling. Gentoo is great for people who have a desire to learn about Linux and their computer. I believe it is fantastic for 'newbies' so long as they have patience and the motivation to stick through the problems they will encounter. With Gentoo you can build your very own system unique to you and your wants, so along the way you will need to do a LOT of reading and research. The Gentoo forums are one of the best online communities I've ever been involved in and are the best resource to start with. For users who just want a system to work and want to do very little customisation and maintenance, Gentoo is probably not the right choice. Although it can be a high maintenance distribution, it doesn't have to be. When all is said and done though, if the idea of building your own kernel freaks you out then maybe you should stick with a binary distro ;) MS: On to your other initiative. Tell us a little about 'Make The Move'. CS: 'Make The Move' project was born out of my desire to promote Linux and free, open source software. Discussions with other members of the Canberra Linux User Group spurred me into action and the website was born. I launched it on the 1st January this year and since then it has had some 50,000 unique visitors. The website is designed to be a resource to explain what free software is about and how people can 'make the move'. I am using everyday language to convey technical ideas which will hopefully help to get an understanding of free software out into the general community. Over time I intend to build upon the content that is there and improve the quality of the site. This will require updating it as Linux and technology changes so that is relevant to systems of the day. So if you have friends, colleagues and family members who you are trying to get onto free software, point them to the site! It is a great research for those who often find themselves explaining what free software is about and why people should care. Just memorise the URL and forward it to everyone on your contact list, http://makethemove.net :) MS: So how's the FOSS scene in your part of the woods? Do people around you talk about it? Do the local papers mention it often? How's your LUG?CS: Being upside-down does make it tricky using computers at times, but nevertheless overall I think Australia has quite a good base of open source developers and the community here is quite strong. Rarely is FOSS in the news here however and that is something I am hoping to help change through the 'Make The Move' project. Many everyday people here have no idea about what free software is or what it can do for them. Slowly though more and more people are starting to hear about Linux. As this happens I hope that Make The Move can help to steer people in the right direction and not scare them away from what they might not yet understand. Australia also hosts one of the most popular open source conferences in the world, Linux Conference Australia, which attracts many prominent open source figures from all over the globe. MS: Last time I checked, a couple of sections on MTM were still awaiting content. If you have any calls for collaboration, either with MTM or Kororaa, feel free to enlist here. CS: I really desperately need some XHTML/CSS experts to fix issues with the site, so if there are people out there willing to help throw a few ideas around I would be most grateful! I am actually hoping to get a new, updated design happening soon. The site does not scale well and is not great under Internet Explorer (I know, every developer's favourite topic) but unfortunately these need to be fixed as our target market is most likely using Windows and Internet Explorer. We need to save them!! Actually, according to my web statistics, about 75% of people visiting the site are using Windows while only 20% are using Internet Explorer (70% are using Firefox). The other thing I need for the site are more translations! I would like translations into any and every language we can. Currently there are 7 translations active on the site with another 5 or so on the way, but there are many more languages out there. Through translations we can hopefully utilise this central website to expand the knowledge of free software into many more countries around the world. MS: Any upcoming Kororaa developments we should keep an eye out for? Any more projects in the pipeline? CS: At the moment my priority is to fix up the Make The Move website and release a new version as soon as I can. I have many content changes and updates that need to go live but I am holding off on until the new design is complete. Other than that there is not a lot new happening, although I did recently start a new job :) I have also begun writing some reviews for Distrowatch.com and might continue to work on that area as I do enjoy writing. We'll see :) 
Read more
  • 0
  • 0
  • 2630
Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at €18.99/month. Cancel anytime
article-image-alfresco-web-content-management-wcm-20-part-two
Packt
19 Mar 2010
6 min read
Save for later

Alfresco Web Content Management (WCM) 2.0 Part Two

Packt
19 Mar 2010
6 min read
The Web Forms space holds forms that define content templates. For example, we may want press release to be a content type for the web site. A press release may contain a title, an abstract, a location, and several paragraphs in the body. These content elements can be defined in an XML schema file. Alfresco WCM uses the information in the schema file to automatically create a form which can be used for creating XML content for press releases. Once this content is created it can be published to multiple channels –web site, plain text, and wireless devices such as cell phones, for example. The publishing conversion for each channel can be defined using transformations which are specified using XSL, among other options. Content templates can be shared across multiple web sites. The following figure illustrates how a content item for a content type is created and published for multiple channels. Creating Content and Publishing on Multiple Channels for One Content Type Once the space for web site and the web forms (content templates) have been set up, we need to set up users with appropriate content development roles. For example, different users may play roles such as Content Publisher, Content Reviewer, and Content Manager in the content creation process. Further, a Web Developer role may perform the necessary setup needed prior to content creation. Alfresco supports the concepts of change set and sandbox described earlier. Each user gets a separate sandbox, which is an isolated view of the web site. Each user’s sandbox shows only that user’s changes on top of the existing approved content. Similarly, when a user needs to approve a set of changes only those changes need to be visible on top of the approved content. A change set is a set of changes that move together in a workflow. The following screenshot shows user sandboxes and the staging sandbox which contains the currently approved content. The Modified Items link shows the content items the user is currently working on. Staging and User Sandboxes Note how each of the sandboxes allows a separate preview of the website incorporating the changes present in that sandbox. The preview of staging sandbox consists of only the approved content. Alfresco WCM 2.0 includes a virtualization mechanism for supporting in-context web site previews. For example, the following screen shows a preview of the Staging Sandbox web site. Note that there is one approved press release. A Published Press Release in Preview Another, very useful feature of Alfresco WCM 2.0 is snapshots. A snapshot captures the complete state of the web site at a given point in time – it can also be thought of as a version of the web site. Alfresco allows reverting back to an older snapshot with just one click. The figure below shows how easy it is to revert to an older snapshot – version 8 was created by clicking on Revert in the row for version 4.   Reverting to a Prior Web Site Snapshot In version 4, the news story shown earlier had not been approved. Previewing the web site for Staging Sandbox now shows no press release in the screenshot below. Previewing the Staging Sandbox after Reverting to an Old Snapshot Note that security and workflow capabilities are part of the core Alfresco platform and are utilized by WCM 2.0. The features discussed above focus on the core development process where content is created via web forms and goes through the approval process, allowing site preview at every point. However, Alfresco WCM 2.0 architecture is versatile enough to allow content creation through standard interfaces such as WebDAV and CIFS (Common Internet File System). Further, it allows content delivery to multiple sites and supports multiple web application technologies. The following figure illustrates these capabilities of the Alfresco architecture. Source: Alfresco WCM Webinar, March 2007 Note that the terms Dev, Preview and Live in the figure above represent the creation of code, content, and media and their movement through the approval process. The Alfresco server shown in the middle is one production environment. In reality, you would need one or two additional environments for performing configurations and customizations in a separate environment which will not accidentally bring your production system down. For example, you should rehearse the space structure setup, security setup, custom rules and configurations in a development environment. Ideally, you would replicate the setup in a QA environment where the configurations/customizations can be tested before applying to the production environment. The development environment remains the playground for trying out any new configuration or customization. The environment concerns described above are not unique for Alfresco WCM 2.0 – there are fairly similar concerns in other WCM systems. What is really pleasant about Alfresco is that it is lightweight enough to run on a single physical machine for dev and QA purposes. On the other hand, production can be set up in truly sophisticated configurations to handle performance, availability, and disaster recovery requirements. Further, Alfresco’s ability to use various commercial components (database, application servers, etc.) as well as popular robust open-source alternatives liberates customers by giving them back the power and freedom to choose what is best for their technical environment.   Conclusion Web Content Management is one of the most popular applications of Enterprise Content Management. There is a wide range of WCM products available in a spectrum ranging from open-source products to completely proprietary offerings. Alfresco WCM 2.0 is a recent release which makes secure content management in a team environment a breeze. It offers exciting features which enable content managers to review, approve, and roll back business or application-level features. This is a huge improvement over managing content, media, and code at an individual file level. The Alfresco WCM 2.0 architecture takes the pain out of adding content from various sources as well as delivering content to multiple channels. The underlying Alfresco architecture puts the power and freedom of choice back in the customer’s hands by liberating them from vendor lock-in. By building upon robust open-source technologies Alfresco leaves more cash in the customers’ pockets for completing their strategic content management initiatives successfully.   References and Resources   Alfresco 2.0 Web Content Management Product Evaluation Guide Book – Alfresco Enterprise Content Management Implementation Alfresco WCM Webinar, March 2007 Alfresco 2.0.1 and 2.1.0 Update Alfresco.com
Read more
  • 0
  • 0
  • 1720

article-image-best-way-create-round-cornered-boxes-css
Packt
19 Mar 2010
5 min read
Save for later

The Best Way to Create Round Cornered Boxes with CSS

Packt
19 Mar 2010
5 min read
The best way to create round cornered boxes with CSS. Boxes with round corners have become synonymous with WEB 2.0 and the future of website design. Forget AJAX, don’t worry about SEO, put content on the back burner, what really excites people is nice rounded boxes. Why is this so? I’ll tell you why… When website layout was done purely with nested tables, creating a box of content with curved corners was tricky. Not impossible, but perhaps more effort than could be justified (or charged for). Using tables, the curved box would be sliced and diced into many smaller images with a top-left corner image, a top-right corner image and so on until you had a perfectly rectangular space in the middle of the clutter of tiny images where the content would sit. It would be at this point that the client would ask for corners with a larger radius, or in a slightly different shade and the whole image slicing would start again. And don’t even talk about drop shadows. CSS did bring some relief from the slicing of images. With CSS you can assign a whole image as a background to an area of content, and position the content nicely on top of it. The background image could of course be an image of a box with rounded corners. Perfect? Well not quite. If you had fixed size content then a fixed size background image would be fine, but content never stays the same for long. Words are altered, font sizes are changed and before you know it the content exceeds the length of the beautifully rounded box it is sitting on. Yuck. There have been some inspired, yet ridiculous methods of overcoming the problems of changing content size within a rounded box, some of which create the corners with client-side code, adding a new DIV to the DOM for every pixel in a mathematically calculated corner. Clever? Yes. Bloated, slow and somewhat ridiculous? Yes to that too. What is needed is the neatest, fastest, most flexible way of creating rounded boxes that can hold varying amounts of content. And this is where I offer my most elegant of solutions. To achieve such simplicity and elegance there is one small prerequisite, and that is that our box is of fixed width. This is no great trouble because it is very sensible to allow boxes to grow vertically rather than horizontally. Columns and vertical scrolling are good practice. Rows and horizontal scrolling are a big no no. And so to the method of creating the easiest and most efficient rounded boxes. Step 1 In Photoshop or your favourite graphics editing package, create the round cornered box you need making it the exact required width and any average height. You should now have an image that looks like figure (a). Notice the shading and drop shadow too. Figure (a) Step 2 Divide the image into 2 parts, a top and a bottom, making the top part as tall as any title line you way want to add to the box. Your 2 images will look like figure (b). Figure (b) Step 3 Increase the canvas size of the bottom portion of the box to a large value making sure it is tall enough to cope with any content it may need to hold. Don’t worry that the bottom image looks far larger than you will need most of the time. Your 2 images will now look like figure (c). Figure (c) That’s all there is to do on the graphics side, now on to the CSS. On your webpage add this HTML: {literal} <div id=box1> <div class=boxtop> <div class=topcontent>My First Box</div> </div> <div class=boxbottom> <div class=maincontent>With some content</div> </div> </div> And to your CSS file add these definitions, obviously changing style parameters to suit your requirements: .boxtop{ /*make this the same size as the top image*/ display:block; width:267px; height:48px; /*set the image as a background*/ background-position:left top; background-repeat:no-repeat; background-image:url(images/top.gif); } .topcontent{ /*set the font style for the box title*/ font-family:arial; font-size:16pt; color:white; /*shift the title down a bit and center it*/ padding-top:10px; text-align:center; } .boxbottom{ /*make this the same width as the bottom image*/ /*don’t set the height as this needs to be flexible*/ display:block; width:267px; /*set the image as a background*/ background-position:left bottom; background-repeat:no-repeat; background-image:url(images/bottom.gif); } .maincontent{ /*set the font style for the main content*/ color:white; font-family:arial; font-size:12pt; display:block; /*align the main content nicely*/ padding-left:20px; padding-bottom:40px; padding-right:30px; } {/literal} Incredibly, that’s all there is to it. You now have a rounded box with shading and a drop shadow that only uses 2 images and a small amount of CSS, and the whole thing is wonderfully cross-browser compatible. To see the final effect take a look at this page here www.eveshamsolutions.co.uk/cornersdemo.html. Feel free to view the source code and pinch the images to play with. If you use this technique don't forget to mention where you found it, if only in the source code :-)
Read more
  • 0
  • 0
  • 1809

article-image-starting-windows-workflow-foundation
Packt
19 Mar 2010
5 min read
Save for later

Starting with Windows Workflow Foundation

Packt
19 Mar 2010
5 min read
Installing WinFX A successful installation of .NET Framework 2.0 is the first thing we need to use Windows WF. You need to have the latest version, because older ones don't work with the latest bits. On http://msdn.microsoft.com/winfx/, click Get the Beta. You need at least, the WinFX Runtime Components along with the Visual Studio 2005 Extensions for Windows WF. Of course, for the latest item you must have a running Visual Studio installation (Express editions won't work). These extensions to the integrated development environment (IDE) are necessary because, although it is possible to create the workflow in code, it makes easier to manage the XML and code-behing files Windows WF uses for its work.Downloading the entire Windows SDK to check other new technologies such asWindows Presentation or CommunicationFoundations is also suggested (formerly known as Avalon and Indigo, respectively). Why Workflows? Until now, flowcharts and process schemes were done separately from code, just as a way to organize ideas before writing the actual code. But when the task was finished, the scheme remained just as documentation. Also, the capacity of older computers made impossible to retain all the information of a workflow in memory, and it was difficult totranslate from an easy-readable format for human to machine code. Windows WF tries to solve all these problems, making workflow technology available to every single programmer that uses the .NET Framework, and thereby making it general enough to be used in different situations. That seems the natural step from the interoperability concepts in the Framework; if it can execute code written in a bunch of languages, then why not have a tool that translates a conceptual idea of how a work is to be done in real, compliable code? Windows WF can be used for document management (for that special task it will be integrated into Office12), business cycles, or page flow (by making use of ASP.NET). There are lots of reasons as to why a developer would choose writing a workflow instead of writing the code. First of all, for programmers, workflows are easier to understand than code, because workflows provide a visual representation of the process. Consequently, code becomes harder to maintain and adapt to new areas. For example, adding a step in the middle of a scheme because we need to have an additional agreement with the user because of newer laws can be real pain for coders, but an easy step forworkflow users. In addition, Windows WF provides a way to extend existing workflows without need of recompiling, so general frameworks can be developed and then customized to fit in different areas. Basic Concepts Layers in Windows WF: The first one is the code that uses the workflow, because a workflow is not an application, but instead a set of actions that is executed asynchronously by the engine provided by Windows WF. That's the key to being able to use a workflow in such a variety of scenarios. The interface that allows communication between that engine and the executing process is called the Hosting Layer, which provides some extra services apart from Communication (send an receive events and data from and to the workflow), like Persistence (which allows saving the state of the workflow in a storage media to restore it later) or Tracking (so the actual code running the workflow can log the execution of it). Finally, we find the Runtime Layer, which actually executes the workflow and manages the core services. One different with the other two layers is that Runtime Layer is not extensible, while more services can be added to the Hosting Service. Apart from these layers, Windows WF comes with an integrated designer that by default integrates smoothly in Visual Studio 2005, but which can be used outside it, so any developer could add drag-and-drop support to its own application. Activities and the minimal units in Windows WF: Each activity receives some parameters from the developer, executes it actions, and then the flow is transferred to the next activity. Some examples are Code or IfElse activities. As developers, we can create new activities and use it in our own code or create an ActivityLibrary for selling. We can get new activities at no cost on its official website www.windowsworkflow.net. There are two main kinds of workflows: 1.       Sequential: Its actions are executed in some predefined order with a beginning and an end. Examples of sequential workflows may include installations. 2.       State machines: These workflows don't have a path, but it's represented as a set of states and transitions between states. Examples are a web shop: you may need approval for mailing, the user could pay via credit card or with a cheque, and each user is in one state and may go to any order depending on previous questions.
Read more
  • 0
  • 0
  • 2875

article-image-cms-made-simple-16-orders-and-payments-e-commerce-website
Packt
18 Mar 2010
13 min read
Save for later

CMS Made Simple 1.6: Orders and Payments in an E-commerce Website

Packt
18 Mar 2010
13 min read
Module Cart This  module will add simple cart functionality to the Products module. Once installed, the Cart module will be automatically displayed in the detailed view of the product. The visitor of the website will then be able to put one or more products in the basket along with the desired quantity. There are other modules that you can use instead of the Cart module, like GiftBaskets. For our example Shop, it is enough to use the simple functionality of the Cart module. Install the module Cart from the list of available modules in the Module Manager. The admin area of this module will be added to Extensions | Cart in the admin console of CMS Made Simple. Time for action – connecting products and cart If you now look at your Shop page and open a detailed view of any product, you will discover that there is still no cart functionality in it. The reason for it is that the Products module does not know that the Cart module has been installed and is ready for use. Let's connect two modules. Open the admin area of the Products module (Content | Product Manager). Click on the Preferences tab. Select the Cart module from the field Cart Module. Click on Submit and open detailed view of any product. You should see the but on Add to My Cart in the detailed view of the product. If the product has some attributes additionally to the quantity field, then the attributes are displayed in a drop-down field besides it. What just happened? You have told the Products module what module has to be used for cart functionality. Test it and add some products to the cart right now. The products will be added, but there is no possibility to display the content of the cart for the visitor yet. Create a new content page called Cart and add the following Smarty tag as the content of the page: {Cart action="viewcart"} Save the page, then open the admin area for the Cart module (Extensions | Cart) and switch to the Preferences tab. Select the newly created page in the list of pages, so that the visitor is automatically redirected to the page after he has added the product to it. There are four templates that you can customize for the module: Template   Description   AddToCart This template controls how the quantity field, the button Add To My Cart (see the preceding screenshot) and optionally product attributes with price adjustment look like. MyCart This template is used to display the cart status. It is displayed at the place where the Smarty tag {Cart action="mycart"} is placed. It shows the number of items currently saved in the cart and the link to the cart page. Viewcart This template is used for extended display of all products saved in the cart. It shows all products with their quantities and prices and the total order price. Additionally it offers the possibility to start the checkout order process if the module Orders is installed. Product Summary This template is used to format the output used for each product summary in the Viewcart template. It allows customizing the product label based on the attributes, product name, and price. The Smarty tag {Cart action="mycart"} can be added to the navigation of the website, like the link to the Basket in the official shop (http://www.cafepress.co.uk/cmsmadesimple) we are trying to reproduce. It would appear as shown in the following screenshot: There is nothing else you should know about the Cart module. The next step will be to integrate the checkout process. Module Orders This module is designed for processing orders from the cart. This module handles billing and shipping addresses from the customer and either uses an external payment gateway (such as PayPal) to handle the payment process or performs manual e-mail-based invoicing. This module can also optionally collect credit card information and store it in the database for later offline processing. Even if the module offers the possibility, never collect credit card information in a low security shared hosting environment! The Orders module keeps track of all orders, and allows for the specification of items like tracking numbers and confirmation on numbers and sending e-mails to the customers related to a particular order. The functionality of the module can be extended with even more modules that allow configuring different taxes, shipping costs, and promotion actions (like discount or promotion coupons). This module has a lot of dependencies: CGExtensions FrontEndUsers Products CGSimpleSmarty CMSMailer CGPaymentGatewayBase From this list of dependencies, you can learn that it is based on the functionality of the module FrontEndUsers. This means that your website's customers must register before they can start the payment process on your online store. There is no possibility to turn off this registration process and it is required for the checkout step. Install all modules listed in the preceding dependencies list, then install the Orders module. Time for action – adding the checkout step To enable the checkout process provided by the Orders module follow these steps: Create a new content page (Content | Pages | Add New Content) and name it Checkout. Add the following Smarty tag to the Content field of the Checkout page: {Orders} Save and view the page in the browser. This page will display either the billing form if the user is logged in or the warning message if the user is not logged in or does not belong to special user group. To connect the Cart module with the new Checkout page, in the admin console click on Extensions | Cart. Select the tab Viewcart Form Templates and click on the Sample template (or your own template, if you have created one). At the very end of the template in the Template Text field, add the following line of code: {cms_selflink page="checkout"} The parameter page should contain the page alias of the page where the Smarty tag {Orders} has been added to the content. Open your shop and add one or more products to the cart,find a link to the page Checkout at the very bottom of the screen. What just happened? You have connected the module Cart with the module Orders by placing a link from the cart view to the checkout process. To test the link, add some products to the cart and click the Checkout link at the bot  om of the cart view. If you are not logged in, you will see the following message: The user is not logged in (or not a member of the required group) This message can be found in the template of the Orders module. But first, let's see an overview of the templates delivered with this module. In the admin console, click on Content | Order Manager and find the Templates link above the list of orders: Template name Template description Billing Form This template controls the first step in the order processing. It displays the form where the customer can enter billing address and one or more shipping addresses. Payment Form This template controls the second step in the order processing and is used to display the payment form for manual e-mail based checkout process. You will need this template if you do not use any payment services like PayPal, EMoney, EWay, or Authorize.net. Confirm Order This template controls the third step in the order processing and is used to display any information the customer entered in the first and optionally second step, so that the customer can confirm the shipping and invoice addresses or go back and correct them. Invoice This template is used in the admin area of the module Orders to print out the invoice or to send it via e-mail to the customer. Gateway Complete This template is used to display the status message after the payment has been made with any 3rd party service like PayPal, EMoney, EWay, or Authorize.net. User Email This template is used to customize the e-mail with order confirmation sent to the customer when the new order has been submitted. Admin Email This template controls the layout and content of the e-mail that is sent to the authorized administrator of the store when a new order is submitted. Message There is no sample template for the messages. Here you can define your custom e-mail notifications that can be manually sent to the customers from the admin area of the module. An example for such message can be an e-mail notification that is sent when the order is shipped. Now, we know where to start and how to proceed with customizing of the templates according to our requirements and payment configurations. Let's give the customer the possibility to register with or login to the website to be able to complete the checkout process. Integrating the login screen The message that indicates that the customer is not logged in is saved in the template Billing Form (the first step in the checkout process). The user is not logged in (or not a member of the required group). This is not very user friendly. Whether the user is registered or not we should give him a possibility to log in or to register on this page as shown in the following screenshot: The login form for registered customers can be displayed with the module FrontEndUsers. In the admin area of the Orders module, click on the Templates link and create a new template with the name My Shop on the tab. Scroll down to the very bottom of the suggested template text and the last ELSE condition: ... {else} {* user is not logged in, gotta make him *} <h3 style="color: red;">{$Orders >Lang('error_notloggedin')}</h3><br/> {/if} This is the place where the message that the user is not logged in is shown. Replace this section with the login screen of the module FrontEndUsers, as shown in the following code snippet: ... {else} <h1>Already registered?</h1> {FrontEndUsers} {/if} Save the template and do not forget to set it as Default to see changes on the website. Registered customers can now log into start the checkout process. But, what about customers who do not have an account? They should be able to register themselves with our website. As it gets a bit complicated I have created the following flowchart: The billing form checks if the visitor is logged in or not. If yes, he can fill in the billing information; if not, the login form of the FrontEndUsers module (step 3) is displayed. The steps 4 and 5 in the workflow should assist new customers by allowing them to register. These steps can be accomplished with the SelfRegistration module. Read the next section to see how the module can be configured. Before you continue be sure that: The CMSMailer module is configured and is able to send out messages There is a user property of type Email Address in the module FrontEndUsers (Users & Groups | Frontend User Management, tab User Properties). There is a user group that has the above user properties associated as Required (Users & Groups | Frontend User Management, tab Groups). Integrating customer registration This module is designed to allow visitors of the website to register themselves. It optionally sends a confirmation e-mail with an activation link that must be clicked before the registration is complete. Once the registration is complete, a user account is created in the module FrontEndUsers. Install the SelfRegistration module from the list of available modules in the Module Manager. For the registration page, create a new content page Register and add the following Smarty tag into the content of the page: {SelfRegistration group="Customers"} Pay attention to the part in bold in the above code. The value of the parameter group should exactly reflect the name of user group in the module FrontEndUsers (Users & Groups | Frontend User Management, tab Groups). Open the Register page of your website and sign in yourself as a new customer with the SelfRegistration module to see how the module works by default. There are some preferences in the module that can make the registration process user friendly. In the admin area of the Self Registration module (Users & Groups | Self Registration Module), click on the Preferences tab. The SelfRegistration module offers registration with an e-mail verification step or optionally single-step registration without any confirmation. If you do not need the e-mail verificafion, you should deselect the option Require the user to confirm registraion via email on the Preferences tab of the module. The three settings considering the final message work different depending on what registration method you have chosen. Setting With verification Without verification Don't display the final message after registration Prevents the registration form to be replaced by the confirmation message after the form is submitted. Prevents the registration form to be replaced by the final message after the form is submitted. PageID/Alias to redirect to after registration is complete N/A Redirects to the given page, but replaces the whole content of the page with the final message. PageID/Alias to redirect to after verification step is complete Redirects to the given page, but replaces the whole content of the page with the final message. N/A According to the workflow, let's add a link to the registration page for the new customers (step 4). In the billing template of the Orders module, open the template for the Billing Form again, scroll down and add a link to the registration page for the new customers as shown in the following code snippet: ... {else} <h1>Already registered?</h1> {FrontEndUsers} <h1>New Customer?</h1> {cms_selflink page="register"} {/if} Pay attention to the parameter page. It should contain the alias of the page where the registration form is displayed. Customize the Registration Template 1 of the SelfRegistration module that displays the registration form. Generally, there are two templates. The first one is for the registration form and the second one (Post Registration Template) contains the message informing the customer that his registration should be confirmed through a link sent to his e-mail address. Other templates that you can customize are as shown in the following table: Templates   Description   Registration Template 2 This template contains the form where the username, verification code and password will be added to complete registration. Confirmation Email Contains subject of the verification e-mail, the plain text and the HTML version of the e-mail sent out after the customer has registered. Final Message The message is shown to customer after the registration process is completed. To build the workflow suggested above (step 5) add link to the billing form in this template, so that the user can carry on with the checkout process. It is also advisable to tick the option Login user after registration, so that the login step can be skipped after registration. Lost Email This template contains a form for the customers that have registered but did not get verification e-mail. This template is shown at the place where the Smarty tag {SelfRegistration mode="sendmoremail"} is shown.
Read more
  • 0
  • 0
  • 3952
article-image-using-moodle-integrate-foreign-language-course-secondary-school
Guest Contributor
18 Mar 2010
11 min read
Save for later

Using Moodle to integrate a Foreign Language Course in Secondary School

Guest Contributor
18 Mar 2010
11 min read
This article is written by Mariella Proietta. Introduction: technology and the learning process Researchers and practitioners, both agree on the essential role played by technology in the learning process. Yet the discussion on the changes brought about by the adoption of ICT is still controversial. An emerging topic is the importance of technology in motivating students. Academic motivation is a critical need to address, especially in high school education, since motivational features change and can significantly influence the engagement, learning, achievement, and future aspirations and intentions of students (Deci and Ryan 1985; Hardré and Reeve 2003; Pintrich and Schunk 1996). Motivation is a result of interaction between external and internal factors. It depends on individual differences, influence of outside experiences, and from interactions with teachers and peers in school. Different studies have shown the use of technological tools to increase motivation and Computer Assisted Learning (CAL) has been encouraged and developed in every field. The use of Computer Assisted Language Learning (CALL) has produced a great deal of literature from perspectives such as cognitive psychology, constructivism, psycholinguistics and has undertaken different phases from behaviouristic to integrative or integrated. Bax (2003) talks about approaches from restricted CALL, open CALL to integrated CALL. He describes them concluding that teachers’ aim should be to attain a state of 'normalisation' in which the technology is invisible and truly integrated. The expectation that teachers would adopt ICT and change their practices in particular ways has been recently questioned by research which indicates that teachers have not changed in the ways expected and researchers try to understand why. J. Orlando(2009) explores the existing literature on the matter stating that effective practices include frequency of use for knowledge construction, using ICT to enhance teaching efficiency and to extend and transform learning teachers’ practices. She notes that there is a common assumption that teachers move along and complete a determined path of change caused by the ‘techno-centric’ expectation of immediacy of change in their practices as a result of the use of ICT. She proposes a different design considering research as an evolving process, fashioned over the course of the study. This change may produce new data. But the change with ICT is distinctive and complex mainly because ICT resource innovations are continuously and rapidly changing. A new perspective helps to understand how and why changes in teaching practices mediated by ICT occur and contribute to understand the phenomenon of ICT and the impact it is having on teaching practices. Improvement and integration of the learning process in foreign language teaching Recent studies explore the increasing role of educational activities outside the classroom in the teaching and learning of foreign languages by means of hybrid learning arrangements and the integration of e-learning with classical classroom instruction. Bärenfänger (2005) explores the studies on the subject and introduces the elements of resulting pedagogic arrangements such as online references, asynchronous web-based learning, email, online assessment and testing, mentoring and tutoring. The study includes portals, synchronous web-based learning, electronic performance support systems, simulations, knowledge management, self-paced CD-ROM based content, communities of practice, video broadcasts, virtual labs and chat rooms. The author notes that these new tools satisfy the needs of learners, improve the quality of the learning experience, decrease the time a learner needs to achieve a learning goal, improve quality of the learning content and materials, improve re-usability of the learning content and materials. Among the advantages these tools also reduce cost of program delivery, allow a more effective map learning components to objectives and reduce cost of program development. Other studies have shown that distant or blended courses do not interfere with oral proficiency and interaction. According to Blake and others ‘many teachers still harbour deep-seated doubts as to whether or not a hybrid course, much less a completely distance-learning class, could provide L2 learners with a way to reach linguistic proficiency, especially with respect to oral language skills’ (Blake et al., 2008). In their study, they show that classroom, hybrid, and distance L2 learners reach comparable levels of oral proficiency during their first year of study. The Italian context In most Italian secondary schools the language course takes place mainly in the classroom (often three hours a week) with students having the opportunity to practice the four skills in a more conventional way. Some schools offer additional hours in which students are asked to work in the school multimedia laboratory, and integrate their language abilities with ICT. The majority of Italian secondary school students have, at home, a personal computer and an easy access to the web, but most of their time is spent chatting in their mother tongue and using a social network. When they are asked to visit foreign websites, find information in English or other foreign languages, do online language practice or similar activities, only a few of them are capable to accomplish the task, while the remaining students want to do the activities at school under the supervision of the teacher. The result is that most of the time is spent doing, at schools, activities that could be easily done at home. Moreover, very few students write and speak in English to communicate, apart from the simulations during the lesson, and their listening practice is mainly with songs. The procedure planned here tries to solve these problems and aims to improve and integrate the learning process with online activities. Using the platform Moodle to integrate the textbook Second language teachers can find a help to create engaging online language learning activities using the Moodle platform in different web sites, and a recent book has been written by J. Stanford for teachers, trainers, and course planners, with little or no experience of Moodle, who want to create their own language learning activities (Stanford 2009). It offers plenty of suggestions and examples for adapting classroom activities to the virtual learning environment and the author has also created a demo site http://moodleforlanguages.co.uk). What we are trying here is slightly different: we try to use the platform Moodle to support and integrate conventional class language activities. Creating learning tasks with Moodle The tools provided by Moodle can be used to integrate any level course, provide additional work outside the class and experience cooperative learning. According to Brandl ‘as a courseware package and learning System, Moodle has great potential for supporting conventional classroom instruction, for example, to do additional work outside of class, to become the delivery System for blended (or hybrid) course formats, or even to be used as a standalone e-learning platform’ (Brandl, 2005). Moodle and its platform can thus be used to integrate the school course, inviting the students to join the modules and try the new experience. They can be asked by the teacher to attend the platform and receive credits or marks, which will contribute to the end-of-year evaluation. The result of this kind of experience may contribute to support the use of new technologies in secondary schools, and increase foreign language proficiency. Preparing the platform Teachers or instructors should first prepare the platform and its parts before starting the activities, caring that each language skill could be exploited, and then they could invite their students to join the integration course. As regards language learning, among the different features, the quiz-making function has been analysed and used by many instructors and authors. Robb states that Moodle's functions ‘allow you to make different types of quizzes. Quiz types relevant to language teaching are: Multiple choice, True/False, Numerical, Matching, Description, and Cloze. A wide range of options allows you to randomize the questions and multiple-choice items, specify a time frame for availability, choose whether the students receive feedback or not, decide if they are allowed to view the correct answers, and determine how many times they may take the quiz and how it is to be scored (first attempt, highest attempt, average of all attempts or last attempt)’ (Robb, 2004). Planning the procedure Since the intention is not to substitute the textbooks, CDs or CD ROM, but to integrate them with an e-learning environment, the following steps may be followed, to create the module or sections in the platform and provide the interaction needed: The teacher chooses some Units of the textbook (or textbooks) that can be more easily considered as Learning Objects (modular digital resources that are uniquely identified and can be used and reused to support learning. The main idea of 'learning objects' is that educational content is broken down into small chunks that can be reused in various learning environments). Some of the audio material (tracks) on CDs can be saved as audio files in a directory to be used as a resource. Short video sequences can offer dialogues corresponding to the units chosen. Many sites such as the site of the BBC http://www.bbc.co.uk/worldservice/learningenglish and other sites ( e.g. http://www.lingual.net/lingualproductitems/details.php) provide this sort of video material that can be linked or downloaded from the platform. Additional audio material should be prepared, such as listening exercises, whose solutions and answers could be sent via e-mail to the teacher for correction or recorded by the students and put in an area of the platform where other students could access for listening and discussion in a chat room. A particular section of Moodle offers the opportunity to create quizzes of different kinds. Instructors and teachers who are familiar with ‘Macromedia Flash’ or similar programs can also produce interactive web pages with exercises such as drag and drop or true or false. Otherwise, each section could have some links to web sites with plenty of exercises. The teacher has only to take care that there is a great deal of interaction and feedback. Evaluation may be done through different kinds of tests. At the end of each test a mark or score can be given to each student, and added to the general evaluation in the subject. An additional mark may be given to the frequency with which students attend the platform and the areas in which they can swap information. To illustrate the procedure we have created a module choosing some of the contents of Horizons Options pre­intermediate used in Italian secondary schools mostly in the second or third year. The first approach, after the login and the choice of course, may be with a chart similar to figure 1 that can be put in the main frame: The access to each Section can be done either independently or in sequence in the sense that Section 2 can be opened only after having done the main activities in Section 1. The ‘i’ on the right provides general information about the content of the Section. By clicking on one of the titles of the sections, e.g. Clothes and fashion you can open either a frame or a new window similar to the following (figure 2): The exercises provided are mostly interactive and they can be scored independently. A particular area of the platform may be used as a kind of forum where the students write their doubts and the teacher gives explanation. They can also be encouraged to suggest the solution to the questions asked by others. Another area may be used to chat freely in the foreign language. To avoid the unbalance between oral and written skills, particular care should be taken in using tools that allow the recording of the voice and the oral communication. Students could be asked to telephone and record their call or interview a friend and put the recording on the platform. Conclusion The ideas provided in this article are only the starting point for the acquisition of a deeper competence in the use of Moodle for language learning. The choice of the Italian context is influenced by the ongoing experimentation of Moodle in Italian secondary schools, but many suggestions can come only after having used the package and the Learning System for a long time. We should reach what Bax calls normalisation referring ‘to the stage when the technology becomes invisible, embedded in everyday practice and hence ‘normalised’. To take some commonplace examples, a wristwatch, a pen, shoes, and writing - these are all technologies which have become normalised to the extent that we hardly even recognise them as technologies’ (Bax, 2003). What is important, at the moment, is starting to explore new ways of teaching and keeping alive students' interest and motivation using their means of communication.
Read more
  • 0
  • 0
  • 3903

article-image-shipping-taxes-and-processing-orders-wordpress-29-ecommerce
Packt
18 Mar 2010
4 min read
Save for later

Shipping, Taxes, and Processing Orders with WordPress 2.9 eCommerce

Packt
18 Mar 2010
4 min read
  Locations and tax setup There's no doubt that tax law is complicated, but it's a necessity. It's far beyond the scope to discuss tax law in all countries, so be sure to do your own research regarding taxes for your own state, country, and region. For businesses located in the USA, here are a couple of links to get you started: Amazon Sales Tax Info – http://bit.ly/amazon-sales-tax State Tax Info – http://www.business.gov/finance/taxes/state.html Within the USA, most businesses charge state sales tax based on the shipping information that the customer provides. While nine times out of ten a customer's billing and shipping information are the same, the times when the billing and shipping information differ can lead to some interesting scenarios. For example, if your store is based in Kansas, a customer in Kansas who buys a product and ships it to Texas would not have to pay tax on that order at least not to the state of Kansas. On the other hand, a customer in Georgia who buys your product and ships it to Kansas would have to pay tax on the order. Again, tax law is undoubtedly complicated, so be sure to look up any laws specific to your own state. On to business—the first thing to do is to verify that your Base Country/Region is correct. You can find this under the General tab of the WP e-Commerce Plugin Settings, as seen in the following screenshot: Next, verify that the tax percentages are correct for your state or region. This is just underneath the settings for Base Country/Region. Finally, switch to the Checkout tab at the top to consider one more setting. Just, under Checkout Options there is an option to Lock Tax to Billing Country. This is shown in the following screenshot: What this option does, once selected, is lock the billing country to the shipping country. For stores in the USA, it also has the effect of locking the billing state to the shipping state. This certainly simplifies matters, but it doesn't quite solve the tax scenarios outlined earlier in this section. Shipping Options and Calculators Configuring a store's shipping options is potentially one of the most complicated tasks that new store owners face, but it doesn't have to be. Much of it depends on the type of products that you are planning to sell. The absolute simplest scenario involves selling digital downloads only, in which case you don't need to worry about shipping at all. When dealing with tangible goods, one's shipping needs grow increasingly complicated depending on the diversity of the products involved and anticipated location of the customers. For instance, selling books as well as clothing will create different shipping needs than selling only books or clothing. Also, planning to sell to customers worldwide will necessitate more complicated shipping needs than limiting one's customer base to only one or two countries. Unlike creating and modifying a product catalog, configuring shipping settings is a task that only needs to be done once. General Shipping Settings To view and modify your shipping settings, switch to the Shipping tab at the top of the Settings page, as seen in the following screenshot: Under the General Settings, you have the option to globally enable or disable shipping. If your shop is comprised of digital downloads only, then you can safely switch the Use Shipping option to No and rejoice! You no longer have to worry about any shipping confi guration. The following screenshot shows the relevant panel: Those, who do sell tangible items should leave it set to Yes, as shown above. If your store is located in the USA, add the Zipcode for the area from where you will be shipping items. This is really only necessary if you plan to use one of the external shipping calculators (UPS or USPS), but it doesn't hurt to add it anyway. If you subscribe to the third-party Shipwire order fulfillment service (www.shipwire.com), set the Shipwire option to Yes and enter your relevant login information. Shipwire is a service that collects and stores your products for you, shipping them to customers when necessary. While convenient, Shipwire comes with a cost, currently starting at $30 per month. One neat aspect of the e-Commerce plugin is that you can opt to allow for free shipping, provided that the order price is above a certain threshold. At the bottom of the general shipping options is a toggle to Enable Free Shipping Discount, as seen in the following screenshot: Enter a threshold amount of your choice, such as $50, like seen above. Any orders that customers place with a value equal to or higher than that price will automatically qualify for free shipping.
Read more
  • 0
  • 0
  • 4613

article-image-google-earth-google-maps-and-your-photos-tutorial-part-ii
Packt
17 Mar 2010
19 min read
Save for later

Google Earth, Google Maps and Your Photos: a Tutorial Part II

Packt
17 Mar 2010
19 min read
Part 2: Google Maps Section 1: Introduction to Part 2 When approaching any sufficiently high-level computing topic, it is often true that we need to be familiar with a broad range of underlying and related concepts to establish the foundation necessary to learn the new material. Virtually every technology not only borrows from, but also builds on others. Furthermore, it is often the case with programming projects that the bulk of the work comes at the beginning and involves carefully thinking through the problem, devising a solution, and building those parts of the project that we need to write before we can get to the code we want to write. In the first part of the tutorial we wrote a Perl script which allows us to generate valid KML files from collections of geotagged photos. Using our new tool, we generated a number of files containing all of the data (about our photos) that we'll use to populate our Google Maps. We also looked at the structure of KML, and covered a number of other important topics, which are key to understanding the material presented here. If you have not read part 1, do take the time at least to glance through it to confirm for yourself that you won't have trouble following along with this discussion. Now we turn our attention to Google Maps. After this short introduction we'll handle the tutorial in 3 parts. Part 1: This section discusses the document-object-model (DOM), which is a formal methodology for negotiating XML files, like the KML files we created in part 1. Part 2: Next we'll look at XHTML and the XHTML file we'll use to display our Google Map. As you'll see, the file included with the project is no more than a shell, but it does suffice to allow us to present our map. Furthermore, it affords us an opportunity to talk about integrating XHTML, Javacript, and the Google Maps API. There are a few important things we'll need to understand. Working with a simple page will help us avoid complicating the issues unnecessarily and will make it easy for you to relocate the map to a page of your own (maybe as part of a weblog for example) with a minimum amount of fuss. Part 3: Finally, we'll look at Javascript and the Google Maps API. Before we get to all of that, there are a couple of preliminary topics to talk about: XML We've already looked at XML, describing it as an open, extensible markup language. We've said that XML is a metalanguage which allows us to define other languages with specific syntactic structures and vocabularies tailored to discrete problem domains. Furthermore we've said that KML is one such XML-based language, engineered to address the problem of describing geographical data and the positioning of geographical placemarks and other features to display on a map, among other applications. XHTML We haven't yet talked about XHTML which is a reimplementation of HTML as a standard, XML-based format. HTML (Hypertext Markup Language) has served as the preeminent language for authoring documents on the World Wide Web since the web's inception in the late 1980s and early 1990s. HTML is the markup language1; which makes hypertext2; linking between documents on the web possible and defines the set of tags, i.e. elements and attributes, that indicate the structure of a document using plain-text codes included alongside the content itself. Just as the web was not the first hypertext system3, HTML was not the first markup language, though both have become extremely important. Without delving too deeply into the primordial history of markup, HTML is a descendant of SGML (Standard Generalized Markup Language) which is itself an offspring of GML (Generalized Markup Language). The Wikipedia entry for GML offers this description of the language: GML frees document creators from specific document formatting concerns such as font specification, line spacing, and page layout required by Script. SCRIPT was an early text formatting language developed by IBM, and a precursor to modern page description languages like Postscript and LaTeX, that describe the structure and appearance of documents. Not surprisingly the goal of GML is echoed in the intent of HTML, though the two are far removed from each other. Berners-Lee; considered HTML to be an application of SGML from the very beginning, but with a clear emphasis on simplicity and winnowing down much of the overhead that had always characterized formal markup languages. In the early days, the web had to struggle for acceptance. The birth of the web is a story of humble beginnings4. The significance of the web was by no means a forgone conclusion and early adoption required that the markup syntax of the web be as accessible as possible. After all, more stodgy languages already existed. The simplicity of HTML certainly contributed to the success of the web (among many other factors), but it also meant that the standard was lacking in key areas. As the web gained wider appeal there was a tendency to take advantage of the early permissiveness of the standard. Developers of mainstream web browsers exacerbated the problem significantly by tolerating noncompliant documents and encouraging the use of proprietary tags in defiance of efforts on the part of standards organizations to reign in the syntax of the language. In the short term, this was a confusing situation for everyone and led to incompatibilities and erratic behavior among an ever increasing multitude of documents on the web and the various web browsers available, which differed in their support for, and interpretation of, what were in essence emerging 'dialects' of HTML. These web browsers differed not only from one another, but also frequently from one version to the next of the same application. There was a real need to establish stability in the language. Lack of dependable syntax meant that the job of building a parser capable of adequately adhering to the standards, and at the same time accommodating various abuses of the standard, had become an exercise in futility. Unlike HTML, XHTML must strictly adhere to the XML standard, which means that any compliant XML parser can negotiate properly formatted documents with relative ease. This reliability paves the way for a more efficient and sophisticated web, resulting in not only more consistent rendering of content, but the development of software that is able to differentiate and act on content based on context, and relationships among data. This is one of the primary advantages of XML, as has already been discussed, and this is a key advantage of XHTML as well. Long term, Berners-Lee, who currently serves as the director of the World Wide Web Consortium (W3C); and a senior researcher at MIT's Computer Science and Artificial Intelligence Laboratory (CSAIL), continues to actively pursue the vision of a Semantic Web. That is, a web that can be mined as a rich repository of data by intelligent software agents, which not only present information, perform basic pattern matching, and the like, but are capable of analysing information (in a truer sense—keep this or get rid of it?). From the W3C's Semantic Web Roadmap we have this brief introduction to the concept: The Web was designed as an information space, with the goal that it should be useful not only for human-human communication, but also that machines would be able to participate and help. One of the major obstacles to this has been the fact that most information on the Web is designed for human consumption, and even if it was derived from a database with well defined meanings (in at least some terms) for its columns, that the structure of the data is not evident to a robot browsing the web. Leaving aside the artificial intelligence problem of training machines to behave like people, the Semantic Web approach instead develops languages for expressing information in a machine processable form. Whether this vision accurately predicts the future of the web remains to be seen. At the moment the Semantic Web is a veritable stew of protocols, frameworks, concepts, extensions, namespaces, vocabularies, schema, ontologies, and other components. It is the subject of much debate, virtually all of it far beyond the scope of this tutorial. But this 'brave new web' is not purely academic. The increased emphasis on standards-compliant markup has resulted in developers of web browsers and content creation tools steering their apps toward the standards. This in turn motivates authors to produce compliant documents. In fact the Strict variations of XHTML do not allow for deviation from the standards. Two immediate benefits of this work, whether or not it ultimately leads to some future web, are (1) more consistent document rendering across platforms among mainstream web browsers, (2) and the emergence of the Document Object Model (DOM). We'll look at the DOM shortly. Section 2: Object Models and the DOM An object model is a collection of objects and the typically hierarchical, often complex, relationships among them, where the most generic definition of an object is simply a 'thing'. Object models are all around us and are not limited to programming or the broader topic of computing for that matter. If, for example, you were to describe a car in terms of its object model: You might start by talking about the chassis, or base frame, and then go on to describe the body of the car, its wheels, axles, exhaust system, the drivetrain, etc.; everything that is directly attached to the frame. For each of these you could describe various attributes and elements of that object; for e.g. the body material is an attribute of the body object. The elements may in fact be other objects that collectively comprise those objects within which they are contained. The body of the car contains the engine compartment, passenger compartment, and trunk elements. The engine compartment includes the engine which is itself a collection of smaller objects. The passenger compartment can be described as the collection of front and rear compartment objects, where the front compartment object includes at least a driver side compartment with a steering wheel, instrument panel, etc. These objects have their own attributes and elements perhaps consisting of other objects each of which is an object itself, with a more specific function than the objects in which they are contained. If you've ever put together a toy model of a car you may remember seeing an exploded schematic diagram of the completed model which clearly shows all of the objects from the largest container elements to the smallest ties, screws and other fasteners that hold all of the pieces together. This is a nice way to visualize the object model of the toy car. Of course the object model I have described is only an informal example. It may be fair to dispute the model I've sketched here. As long as you have a better general understanding of what an object model is then this example has served its purpose. Object models are very common within the realms of computer technology, information technology, programming languages, and formal notation. The Document Object Model The Document Object Model (DOM); is a standard object model for describing, accessing and manipulating HTML documents and XML-based formats. The often quoted description of the DOM from the W3C's site dedicated to the specification is: The Document Object Model is a platform- and language-neutral interface that will allow programs and scripts to dynamically access and update the content, structure and style of documents. The document can be further processed and the results of that processing can be incorporated back into the presented page. Remember that XHTML is a special case of XML (i.e. it is an XML based format) and essentially no more than a formalization of HTML. Because it is an XML based format the XML DOM applies. Furthermore, because XHTML describes a single format with a number of required structural elements and only a limited collection of allowable elements and attributes, the HTML DOM has a number of unique objects and methods for acting on those objects that are not available in the more generic XML DOM. Having said that, I want to emphasize the the two are more alike than the are different. Technically we will look at the XML DOM here but nearly everything discussed is applicable to the HTML DOM as well. Though there are differences, some of which we'll encounter later in this tutorial, as an introduction it is appropriate to limit ourselves to fundamental concepts, which the two share in common. We need both. We'll rely on the XML DOM to parse the KML files we generated in part one of the tutorial to populate our Google Map, and the HTML DOM to add the map to our webpage. By the time we've completed this part of the tutorial hopefully you will appreciate just how integral the DOM is for modern web design and development, though we'll only have skimmed the surface of it. The concept of the DOM is actually quite easily understood. It will seem intuitive to anyone who has ever dealt with tree structures (from filesystem hierarchies to family trees). Even if you haven't had any experience with this sort of data structure, you should anticipate being able to pick it up quickly. Under the Document Object Model individual components of the structure are referred to as nodes. Elements, attributes and the text contained within elements are all nodes. The DOM represents an XML document as an inverted tree with a root node at the top. As far as the structure of an actual XML document is concerned, the root is the element that contains all others. In every structure all other nodes are contained within a document node. In the KML files we've generated the Document element is the root element. Every other node is a descendent of Document. We can express the reciprocal relationship by stating that Document is an ancestor of every element other than itself. Relationships among nodes of the document are described in familial terms. Direct descendants are called child nodes or simply children of the their immediate ancestor, referred to as a parent. In our KML files, is the only child of . (It would be just as correct to say that is the parent node of .) Note that there could be more than one Folder node. We could use additional folders to group Placemarks (a) by year, with one folder per year, (b) by event, with each folder dedicated to a single event, or (3) by image gallery so that each folder corresponds  to a discrete image gallery, or maybe some combination of these and other criteria. Furthermore, we can have more than one type of child node under a single parent. For example Placemark is the parent node of , , and in our files. These nodes can all be described as siblings, because they all have the same parent. Also, notice that is a child of , and a grandchild (not a child) of Placemark. We can make a couple of other useful observations about this structure: Every node other than the root has exactly one parent. Parents may have any number of children including zero, though a node without any children won't be referred to as a parent. (A node with no children is called a leaf.) Implicitly there are other familial relationships among nodes. For example, elements with parents that are siblings could be thought of as 'cousins' I suppose, but it is unusual to see these relationships named or otherwise acknowledged. There is one important subtlety. Text is always stored in a text node and never directly in some other element node. For example, the description elements in our KML files contain either plain text or html descriptions of associated Placemarks. This text is not contained directly in the description node. Instead the description node contains unseen text node which contains the descriptive text. So the text is a grandchild of the description node, and a child of a text node, which is the direct descendent of description. Make sure that you understand this before continuing. Because of the inherent structure of XML, we can unambiguously navigate a document without knowing anything else about it, except that it validates. We can move around the tree without being able to name the nodes before we begin. Starting at the root document node, we can traverse that node's children, move laterally among siblings, travel more deeply from parent to child, and then work our way back up the tree negotiating parent relationships. We haven't yet described how we move among siblings. The DOM allows us to treat siblings as a list of nodes, and take advantage of the relationships that exist among elements in any list. Specifically, we can refer to the first (firstChild) and last (lastChild) nodes to position ourselves in the list. Once we are at some location in the list, we can refer to the previous (previousSibling) and next (nextSibling) nodes to navigate among siblings. Programmatically we can use the DOM to treat siblings in a XML data structure as we would any other list. For example, we can loop through sibling nodes working on each node in turn. Keep in mind that we are using generic terminology, not referring to specific node names and we are relying only on the structure of XML which we know must be dependable if the document adheres to the standard. This will work well for our KML files, and it is certainly not limited to KML. There are primarily two techniques we can use to find and manipulate elements in our XML structure using the DOM. Node PropertiesFirstly, we can take advantage of relationships among element nodes as we have been discussing.A number of node properties, some of which have already been mentioned, allow us to move between nodes in the structure. These include: firstChild,lastChild,previousSibling,nextSibling,parentNode If we look at a fragment of KML, similar to the KML files generated in part 1 of the tutorial, starting at the Placemark element... <Placemark>     <name>value</name>     <Snippet maxLines="1">         value     </Snippet>     <description><![CDATA[         value         ]]></description>     <Point>         <coordinates>value</coordinates>     </Point> </Placemark> ...we see a number of these properties: is the firstChild of is the lastChild of The nextSibling of is The previousSibling of is is the parentNode of , , , and getElementsByTagName()Secondly, we can use the method getElementsByTagName() to find any element regardless of the document structure.For example, using the syntax... getElementsByTagName("name") ...we can retrieve all elements as a nodeList from the document which are descendants of the element we are using when we call the method. The following Javascript statement returns a list of all elements in the document and stores that list at the variable list_of_nodes. var list_of_nodes = getElementsByTagName("name"); What is a node list? A node list (NodeList) is an object representing an ordered list of nodes, where each node represents an element in the XML document. The order of the NodeList is the same as the order of the elements in the document. Elements at the top of the document appear first in the list, and the first element returned, i.e. the first position in the list, is numbered 0. Keep in mind that the list includes all <name> elements. If you look at the KML files we've generated you may notice that both <folder> and <placemark> elements contain <name&gt. We need to be aware that getElementsByTagName("name") will return all of these if we are starting at the document root. We can differentiate between these <name> elements in a number of different ways. For example we can insist that the node is a child of a Placemark node to exclude <name> elements that are the children of <folder> elements. We need to be able to refer to various properties of these nodes if we are going to act on them in any reasonable way. The XML DOM exposes several useful node properties incl: nodeName, nodeValue, and nodeType. nodeName: is (quite obviously) the name of the node. What might be less obvious is precisely how the DOM defines nodeName. The tag name is always the name of an element, e.g. 'Placemark' is the name of the <Placemark> elements The attribute name is the nodeName of an attribute, e.g. the name of the maxLines attribute of <Snippet> is 'maxLines' The name of any text node is always the string '#text'. e.g., the plain text or html that we're using as our Placemark descriptions are each contained in a text node, as has already been discussed, and the name of this text node is '#text', and not the name of the element which surrounds the value in the XML document The nodeName of the root document node is always the literal string '#document'. nodeValue: is what you might expect. The value of text nodes is text itself. So the text node of one of our Placemark elements is all of the plain-text or html within the description tags. Again, as far as the DOM is concerned the text is actually contained within a text node which is a child of a description node The value of an attribute node is simply the attribute value. e.g. maxLines="1" has a nodeValue of 1 nodeValue is not defined for the document node and all element nodes. nodeType: is certainly not something you could guess. A specific value is assigned to each of the available types (categories) of nodes. The following is an incomplete list of common node types. Element, type 1 Attribute, type 2 Text, type 3 Comment, type 8 Document, type 9 As I have already said, we will take advantage of the DOM to parse our KML files and populate our Google Maps. Many of the ideas we've seen here will seem much more concrete when we put them to use. Still, this has been a very brief look at an interesting topic that is especially important to web developers and designers. I would recommend that you pick up a book that does a good job of describing the document object model if you are planning on doing any significant amount of that kind of work. This need not be an intimidating topic, though I have found that the majority of books and articles do an inadequate job with it. If you are only interested in following along with this tutorial then this brief treatment of the DOM, the comments in the included source files, and the javascript code itself should be sufficient for you to complete the project.
Read more
  • 0
  • 0
  • 6270
article-image-ms-access-queries-oracle-sql-developer-12-tool
Packt
17 Mar 2010
12 min read
Save for later

MS Access Queries with Oracle SQL Developer 1.2 Tool

Packt
17 Mar 2010
12 min read
In my previous article with the Oracle SQL Developer 1.1, I discussed the installation and features of this stand-alone GUI product which can be used to query several database products. Connecting to an Oracle Xe 10G was also described. The many things you do in Oracle 10G XE can also be carried out with the Oracle SQL Developer. It is expected to enhance productivity in your Oracle applications. You can use Oracle SQL Developer to connect, run, and debug SQL, SQL*Plus and PL/SQL. It can run on at least three different operating systems. Using this tool you can connect to Oracle, SQL Server, MySql and MS Access databases. In this article, you will learn how to install the Oracle SQL Developer 1.2 and connect to an MS Access database. The 1.2 version has several features that were not present in version 1.1 especially regarding Migration from other products. Downloading and installing the Oracle SQL Developer Go to the Oracle site (you need to be registered to download) and after accepting the license agreement you will be able to download sqldeveloper-1.2.2998.zip, a 77MB download if you do not have JDK1.5 already installed. You may place this in any directory. From the unzipped contents, double-click on the SQLDeveloper.exe. The User Interface On a Windows machine, you may get a security warning which you may safely override and click on Run. This opens up the splash window shown in the next picture followed by the Oracle SQL Developer interface shown in the picture that follows. Figure 1 The main window The main window of this tool is shown in the next picture. Figure 2 It has a main menu at the very top where you can access File, Edit, View, Navigate, Run, Debug, Source, Migration, Tools and Help menus. The menu item Migration has been added in this new version. Immediately below the main menu on the left, you have a tabbed window with two tabs, Connections, and Reports. This will be the item you have to contend with since most things start only after establishing a connection. The connection brings with it the various related objects in the databases. View Menu The next picture shows the drop-down of the View main menu, where you can see other details such as links to the debugger, reports, connections, and snippets. In this new version, many more items have been added such as Captured Objects, Converted Objects, and Find DB Object. Figure 3 Snippets are often-used SQL statements or clauses that you may want to insert. You may also save your snippets by clicking on the bright green plus sign in the window shown, which opens up the superposed Save Snippet window. Figure 4 In the Run menu item, you can run files as well as look at the Execution Profile. Debug Menu The debug menu item has all the necessary hooks to toggle break points: step into, step over, step out and step to End of Method, etc., including garbage collection and clean up as shown in the next picture. Figure 5 Tools Menu Tools give access to External Tools that can be launched, Exports both DDL and data, schema diff, etc. as shown in the next picture. Figure 6 Help gives you both full-text search and indexed search. This is an important area which you must visit; you can also update the help. Figure 7 About Menu The About drop-down menu item in the above figure opens up the following window where you have complete information about this product that includes version information, properties, and extensions. Figure 8 Migration Menu As mentioned earlier the Migration is a new item in the main menu and its drop-down menu elements are shown in the next picture. It even has a menu item to make a quick migration of all recent versions of MS Access (97, 2000, 2002, and 2003). The Repository Management item is another very useful feature. The MySQL and SQL Server Offline Capture menu item can capture database create scripts from several versions of MySQL and MS SQL Server by locating them on the machine. Figure 9 Connecting to a Microsoft Access Database If you are interested in Oracle 10G XE it will be helpful if you refresh your Oracle 10G XE knowledge or read the several Oracle 10G XE articles whose links are shown on the author’s blog. This is a good place for you to look at new developments, scripts, UI description, etc. This section, however, deals with connecting to an MS Access database. Click on the "Connections" icon with the bright green plus sign as shown in the next figure. Figure 10 This opens up the next window, New/Select Database Connection. This is where you must supply all the information. As you can see it has identified a resident (that is a local Oracle 10G XE server) Oracle 10G XE on the machine. Of course, you need to configure it further. In addition to Oracle, it can connect to MySQL, MS Access, and SQL Server as well. This interface has not changed much from version 1.1; you have the same control elements. Figure 11 On the left-hand side of this window, you will generate the Connection Name and Connection Details once you fill in the appropriate information on the right. Connection name is what you supply; to get connected you need to have a username and password as well. If you want, you can save the password to avoid providing it again and again. At the bottom of the screen, you can save the connection, test it and connect to it. There is also access to online help. In the above window, click on the tab, in the middle of the page, Access. The following window opens in which all you need to do is to use the Browse button to locate the Microsoft Access Database on your machine (windows default for mdb files is My Documents). Figure 12 Hitting the Browse button opens the window, Open with the default location, My Documents—the default directory for MDB files. Figure 13 Choosing a database Charts.mdb and clicking the Open button brings the file pointer to the New / Select Database Connection in the box to the left of the Browse button. When you click on the Test button if the connection is OK you should get an appropriate message. However for the Charts.mdb file you get the following error. Figure 14 The software is complaining about the lack of read access to the system tables. Providing read access to System tables. There are a couple of System tables in MS Access which are usually hidden but can be displayed using Tools option in MS Access. Figure 15 In the View tab if you place a check mark for System objects then you will see the following tables. The System tables are as shown in the red rectangle. Figure 16 If you need to modify the security settings for these tables you can do so as shown in the next figure by following the trail, Tools  Security User and Group permissions. Figure 17 Click on the User and Group Permissions menu item which opens the next window Users and Group Permissions shown here, Figure 18 For the user who is Admin, scroll through each of the system tables and place a check mark for Read Design and Read Data check boxes. Click on the OK button and close the application. Now you again use the Browse button to locate the Charts.mdb file after providing a name for the connection at the top of the New / Select Database Connection page. For this tutorial MyCharts was chosen as the name for the connection. Once this file name appears in the box to the left of the Browse button, click on the Test button. This message screen is very fast (appears and disappears). If there is a problem, it will bring up the message as before. Now click on the Connect button at the bottom of the screen in the New / Select Database Connection page window. This immediately adds the connection MyCharts to the Connections folder shown in the left. The + sign can be clicked to expand all the objects in the Charts.mdb database as shown in the next figure. Figure 19 You can further expand the Table nodes to show the data that the table contains as shown in the next figure for the Portfolio table. Figure 20 The Relationships tab in the above figure shows related and referenced objects as shown. This is just a lone table with no relationships established and therefore none showing. Figure 21 It may be noted that the Oracle SQL Developer can only connect to MDB files. It cannot connect to Microsoft Access projects (ADP files), or the new MS Access 2007 file types. Using the SQL Interface SQL Statements are run from the SQL Worksheet which can be displayed by right clicking the connection and choosing Open SQL Worksheet item from the drop-down list as shown. Figure 22 You will type in the SQL queries in area below Enter SQL Statement label in the above figure (now hidden behind the drop-down menu). Making a new connection with more tables and a relationship In order to run a few simple queries on the connected database, three more tables were imported into Charts.mdb after establishing a relationship between the new tables in the access database as shown in the following figure. Figure 23 Another connection named, NewCharts was created in Oracle SQL Developer. The connection string that SQL Developer will take for NewCharts is of the following format (some white spaces were introduced into the connection string shown to get rid of MS Word warnings). @jdbc:odbc: Driver= {Microsoft Access Driver (*.mdb)}; DBQ=C:Documents and SettingsJayMy DocumentsCharts.mdb; DriverID=22;READONLY=false} This string can be reviewed after a connection is established in the New / Select Database Connection window as shown in the next figure. Figure 24 A simple Query Let us look at a very simple query using the PrincetonTemp table. After entering the query you can execute the statement by clicking on the right pointing green arrowhead as shown. The result of running this query will appear directly below the Enter SQL Statement window as shown. Figure 25 Just above the Enter SQL Statement label is the SQL Toolbar displaying several icons (left to right) which are as follows with the associated key board access: Execute SQL Statement(F9) ->Green arrow head Run Script(F5) Commit(F11) Rollback(F12) Cancel(CTRL+Q) SQL History(F8) Execute Explain Plan(F6) Autotrace(F10) Clear(CTRL+D) It also displays time taken to execute ->0.04255061 seconds. The bottom pane is showing the result of the query in a table format. If you would run the same query with the Run Script (F5) button you would see the result in the Script Output tab of the bottom pane. In addition to SQL you can also use the SQL Worksheet to run SQL *PLUS and PL/SQL statements with some exceptions as long as they are supported by the provider used in making the connection. Viewing relationship between tables in the SQL Developer Three tables Orders, Order Details, and Products were imported into the Charts.mdb after enforcing referential integrity relationships in the Access database as seen earlier. Will the new connection NewCharts be able to see these relationships? This question is answered in the following figure.   Click on any one of these tables and you will see the Data as well as Relationships tabs in the bottom pane as shown. Figure 26 Now if you click on the Relationships tab for Products you will see the display just showing three empty columns as seen in an earlier figure. However if you click on the Order Details which really links the three tables you will see the following displayed. Figure 27 Query joining three tables The Orders, Order Details, and Products tables are related by relational integrity as seen above. The following query which chooses one or two columns from each table can be run in a new SQL worksheet. Select Products.ProductName,Orders.ShipName,Orders.OrderDate,[Order Details].Quantityfrom Products, Orders, [Order Details]where Orders.OrderID=[Order Details].OrderIDandProducts.ProductID=[Order Details] and Orders.OrdersDate >'12-31-1997' The result of running this query (only four rows of data shown) can be seen in the next figure. Figure 28 Note that the syntax must match the syntax required by the Provider ODBC, date has to be #12-31-1997# instead of ’12-21-1997’. Summary The article described the new version of the stand alone Oracle’s GUI SQL Developer tool. It can connect to couple of databases such MS Access, SQL Server, Oracle and MySQL. Its utility could have been far greater had it provided connectivity to ODBC and OLE DB. I am disappointed it did not, in this version as well. The connection to MS Access seems to bring in not only tables but the other objects except Data Access Pages, but the external applications that you can use are limited to Word, Notepad, IE etc but not a Report Viewer. These objects and their utility remains to be explored.  Only a limited number of features were explored in this article and it excluded new features like Migration and Translation Scratch Editor which translates MS ACCESS, SQL Server and My SQL syntaxes to PL / SQL. These will be considered in a future article.
Read more
  • 0
  • 0
  • 16249

article-image-python-data-persistence-using-mysql-part-iii-building-python-data-structures-upon-unde
Packt
17 Mar 2010
8 min read
Save for later

Python Data Persistence using MySQL Part III: Building Python Data Structures Upon the Underlying Database Data

Packt
17 Mar 2010
8 min read
Using Python Built-in Object Types to Hold Structured Data The most common way to hold structured data in Python is to use built-in object types such as lists, list comprehensions, tuples, and dictionaries. In particular, you may find the above Python types useful when dealing with database data. Dictionaries can be of particular interest to you when you need to represent data stored in a database table that has a primary key column. Turning back to the posts table created and populated with data as discussed in the first article of this series, you might create the following dictionary to represent the records stored in this table: posts = {} posts["Layouts in Ext JS"] = {"guid":"http://www.packtpub.com/article/layouts-in-ext- js","pubDate":"Fri, 28 Nov 2008 10:31:03 +0000"} posts["WordPress Plug-in Development (Beginner's Guide)"] = {"guid":"http://www.packtpub.com/ wordpress-plug-in-development","pubDate":"Fri, 28 Nov 2008 00:00:00 +0000"} For clarity, you manually set up the dictionary here. In reality, though, you would most likely populate it with the data obtained from the database or the Web. In the above example, the posts dictionary uses the values of the title column in the posts table as the dictionary’s keys. The dictionary’s values are also dictionaries each of which represents the rest of a record, containing the guid and pubDate fields. Since the keys within a dictionary cannot be repeated, the above approach guarantees uniqueness of the title field in the posts’ records represented in the dictionary. Now to obtain a certain record, you can use its key like this: rec = posts["Layouts in Ext JS"] print rec This should produce the following output: {'guid':'http://www.packtpub.com/article/layouts-in- ext-js','pubDate':'Fri, 28 Nov 2008 10:31:03 +0000'} If you need to get to a certain field in the obtained record, you could use the following syntax: guid = posts["Layouts in Ext JS"]["guid"] print guid The above should give you the following: http://www.packtpub.com/article/layouts-in-ext-js To iterate over all of the records in the posts dictionary, you could use a for loop. Here is how you could iterate over the guid field, for example: for post in posts.items(): print post[1]['guid'] Note that the value of the first index of the post variable representing a key/value pair of the dictionary is set to 1, meaning you’re interested in the value part of the pair. The above should generate the following output: http://www.packtpub.com/article/layouts-in-ext-js http://www.packtpub.com/wordpress-plug-in-development If you want to iterate over the dictionary keys, you could use the following code: for post in posts.items(): print post[0] This should give you the following lines: Layouts in Ext JS WordPress Plug-in Development (Beginner's Guide) Now that you have an idea of how database data can be represented in Python, let’s look at an example of how you might persist it to a database. Here is a quick example that illustrates how you might persist the posts dictionary to the posts database table. import MySQLdb db=MySQLdb.connect(host="localhost",user="usrsample",passwd="pswd",db="dbsample") c=db.cursor() for post in posts.items(): c.execute("""INSERT INTO posts (title, guid, pubDate) VALUES (%s,%s,%s)""", (post[0], post[1]['guid'], post[1]['pubDate'])) db.commit() db.close() Assuming you have populated the posts dictionary with data as discussed at the beginning of the article, the above code should insert two records into the posts table. Fetching Database Records You typically persist data to the database in order to retrieve it from there later. How can you retrieve data from the posts table? The following script answers this question: import MySQLdb db=MySQLdb.connect(host="localhost",user="usrsample",passwd="pswd",db="dbsample") c=db.cursor() c.execute("SELECT * FROM posts") c.fetchall() The cursor’s fetchall method in the above code fetches all the rows retrieved by the query, making them available as a list of tuples. To iterate over this list, you could use the following loop: for row in c: print row db.close() This should produce the following output: ('Layouts in Ext JS','http://www.packtpub.com/article/layouts-in- ext-js','Fri, 28 Nov 2008 10:31:03 +0000') ("WordPress Plug-in Development (Beginner's Guide)",'http://www.packtpub.com/wordpress-plug- in-development','Fri, 28 Nov 2008 00:00:00 +0000') As you can see, each line in the above output represents a tuple rather than a dictionary. To have a dictionary instead, you will need to obtain the column names along with the rows being fetched. You can do this with the help of the cursor’s description read-only attribute, as illustrated in the updated script below: import MySQLdb db=MySQLdb.connect(host="localhost",user="usrsample",passwd="pswd",db="dbsample") c=db.cursor() c.execute("SELECT * FROM posts") heads = [d[0] for d in c.description] c.fetchall() for row in c: print dict(zip(heads,row)) db.close() The output should give you a set of dictionaries each of which represents a record in the posts table. But how can you get the data so that it is structured as it were in the posts dictionary discussed at the beginning of the article? To do this, you could revise the above script as follows: import MySQLdb db=MySQLdb.connect(host="localhost",user="usrsample",passwd="pswd",db="dbsample") c=db.cursor() c.execute("SELECT * FROM posts") heads = [d[0] for index, d in enumerate(c.description) if index > 0] c.fetchall() print heads posts={} for row in c: posts[row[0]]= dict(zip(heads,[r for index, r in enumerate(row) if index > 0])) print posts db.close() Notice the use of comprehension lists in the above code. First time, you use it to exclude the first column head from the heads list. Then, you use a similar technique to exclude the first field from each row when iterating fetched rows in the loop. As a result, you should have the same posts dictionary as you saw at the beginning of the article. Customizing Built-in Types to Simulate Trigger Functionality In the world of relational databases, triggers are programs stored inside the database, which run implicitly in response to a certain event. For example, you can define a BEFORE INSERT trigger on a certain table, so that it fires just before a new record is inserted into that table. It is interesting to note that triggers can be used in MySQL starting with version 5.0. If you have an older MySQL version, you won’t be able to take advantage of triggers. In that case, though, you still can simulate trigger functionality on the Python side of your application. So, you want to define triggers on the data structures implemented in Python, much like you would do that in the underlying database. To achieve this, you could for example subclass the Python’s dict built-in type, overriding the __setitem__ method so that it takes the appropriate action implicitly whenever a new item is added. Next, you could use this customized dict’s subclass instead of dict. Consider the following example. Suppose you want to implement the BEFORE INSERT trigger functionality on the posts dictionary, so that it restricts inserting new items to those that represent an article from the Packt Article Network. To achieve this, you will need to override the dict’s __setitem__ method so that it checks to see whether the value of the item’s guid includes the following fragment: http://www.packtpub.com/article/. Below, you create the dict’s subclass called artdict, and then use this subclass to create the posts dictionary, populating it with the same data you used at the beginning of the article: class artdict(dict): def __setitem__(self, key, value): x = 'http://www.packtpub.com/article/' if (x in value['guid']): super(artdict, self).__setitem__(key, value) posts=artdict() posts["Layouts in Ext JS"] = {"guid":"http://www.packtpub.com/article/layouts-in-ext- js","pubDate":"Fri, 28 Nov 2008 10:31:03 +0000"} posts["WordPress Plug-in Development (Beginner's Guide)"] = {"guid":"http://www.packtpub.com/ wordpress-plug-in-development","pubDate":"Fri, 28 Nov 2008 00:00:00 +0000"} print posts Although you have tried to insert two records into the posts dictionary, only the first insertion should have succeeded. So the print should generate the following output: {"Layouts in Ext JS":{"guid":"http://www.packtpub.com/article/layouts-in- ext-js","pubDate":"Fri, 28 Nov 2008 10:31:03 +0000"}} The second item, whose title is WordPress Plug-in Development (Beginner's Guide), was excluded because its guid does not include substring http://www.packtpub.com/article/. This is because this item is not associated with an article but the book. Summary As you learned in this article, Python language provides a wide variety of useful tools to deal with structured data. You can utilize lists, tuples, list comprehensions, and dictionaries when it comes accessing and manipulating data stored in the underlying database. You can even customize the above built-in types to meet the requirements of your application.
Read more
  • 0
  • 0
  • 2082
Modal Close icon
Modal Close icon