Ezy Win

May 6, 2009

Check Out How Drag and drop category management with CakePHP

Filed under: Programming — tkwriter @ 12:42 pm

View full article here: Drag and drop category management with CakePHP and Jquery our visit our blog today at EndYourIf.com

Today’s article is going to walk you through creating a slick drag and drop with AJAX category management system.
CakePHP offers a really nice built-in tree management. In fact, at a bare minimum you simply need to create a table with 2 extra columns, tell your model to act like a “tree” and rather than doing a find(’all’) you do a generatetreelist() or a find(’threaded’) and CakePHP takes care of the rest.

After doing a quick test, I was quite impressed with what CakePHP did for me, but I was not satisified. I wanted to create a really slick category management system that I can re-use and show off. Well, in this tutorial I go about 90% of the way. The only thing I didn’t have time to finish was, rather than redrawing my tree through AJAX, use DHTML and dynamically update my tree after dragging and dropping. Don’t worry, I plan to finish this with a part two soon.

I know it’s not the most beautiful system in the word. But, I hope it drives the point home of how much potential there is with this system. To create all of the code below and do a bit of testing, it took about 3 hours total! A normal category management system of unlimited sub categories would probably take me a couple of days AND there is no way it could match the “coolness” factor of this application.

Also, in case the screen shots are not quite clear. To create a new category, type the name in the text box and drag the red rectangle above to where you want to place it. The category it will be placed in will be highlighted in yellow. If you wish to move a category or entire branch, simply drag it and move it to the new category.

Ok, let’s move on to the actual code. The first thing to do is create our categories table:

Code
CREATE TABLE `categories` ( `id` int(10) unsigned NOT NULL auto_increment, `name` varchar(255) NOT NULL, `parent_id` int(10) unsigned NOT NULL, `lft` int(10) unsigned NOT NULL, `rght` int(10) unsigned NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;If you’ve ever built a category system, the first three columns should look familiar. The key columns here though are the fourth and fifth columns, the lft and rght. CakePHP automatically deals with these columns for us whenever we save or delete data. For a detailed explaination, view this document from Mysql: http://dev.mysql.com/tech-resources/articles/hierarchical-data.html

Now that our table is created, the next thing I did was bake my model, controller, and views. After I baked all three, I had to update and remove a few things. First off our model, the simplest part of the process:

Code
<?phpclass Category extends AppModel var $name = ‘Category’; var $actsAs = array(‘Tree’);?>As I mentioned before, the only thing special to note here is the “actAs” is set to “tree”. Next up is our controller, it’s also quite basic:

Code
<?phpclass CategoriesController extends AppController var $name = ‘Categories’; var $helpers = array(‘Html’, ‘Form’, ‘Javascript’); function index() // if it’s ajax, set ajax layout if (!empty($this->params['named']['isAjax'])) $this->layout = ‘ajax’; $categories = $this->Category->find(‘threaded’); $this->set(compact(‘categories’)); function add() if (!empty($this->data)) $this->Category->create(); if ($this->Category->save($this->data)) $this->Session->setFlash(__(‘The Category has been saved’, true)); //$this->redirect(array(‘action’=>’index’)); else $this->Session->setFlash(__(‘The Category could not be saved. Please, try again.’, true)); $this->render(false); function edit($id = null) if (!$id && empty($this->data)) $this->Session->setFlash(__(‘Invalid Category’, true)); $this->redirect(array(‘action’=>’index’)); if (!empty($this->data)) if ($this->Category->save($this->data)) $this->Session->setFlash(__(‘The Category has been saved’, true)); //$this->redirect(array(‘action’=>’index’)); else $this->Session->setFlash(__(‘The Category could not be saved. Please, try again.’, true)); if (empty($this->data)) $this->data = $this->Category->read(null, $id); $this->render(false); function delete($id = null) if (!$id) $this->Session->setFlash(__(‘Invalid id for Category’, true)); $this->redirect(array(‘action’=>’index’)); if ($this->Category->del($id)) $this->Session->setFlash(__(‘Category deleted’, true)); $this->redirect(array(‘action’=>’index’));?>As you will see, nothing to special is going on inside of our controller. I’ve removed the redirects on successful save for the add and edit. I didn’t include deleting in this example, but it certainly would not be a lot of work to add it in. I’ve done two other things. The first is, if I pass in an isAjax parameter, I set the layout to ajax. This prevents the entire layout from re-drawing with each Ajax call. The second thing I did, was change my find(’all’) to find(’threaded’). If we used the generatetreelist() instead, it creates a flat array with an identifier for each child level, this is why we use threaded because it creates a recursive array that makes it easier in code to navigate through.

Next up is our appviewscategoriesindex.ctp file:

Code
<?php$javascript->link(array(‘jquery’, ‘jquery-ui’), false);?><script> $(document).ready(function()//set up the droppable list elements $(“ul li”).droppable(accept: “.ui-draggable”, hoverClass: ‘droppable-hover’, greedy: true, tolerance: ‘pointer’, drop: function(ev, ui) var dropEl = this; var dragEl = $(ui.draggable); // get category id var parent_id = this.id.substring(9); // get category name var category_name = $(dragEl.find(“span”).get(0)).html(); if (!isNaN(parent_id) && category_name.length > 0) var data; var url = “categories/”; // see if we are adding or editing if (dragEl.attr(“id”).substring(0, 9) == “category_”) // get the current id var id = dragEl.attr(“id”).substring(9); data = ‘data[Category][id]‘: id, ‘data[Category][name]‘: category_name, ‘data[Category][parent_id]‘:parent_id; url += “edit”; else data = ‘data[Category][name]‘: category_name, ‘data[Category][parent_id]‘: parent_id; url += “add”; // post to our page to save our category $.post(url, data, function() $.get(“categories/index/isAjax:1″, function (data) destroyDraggable(); $(“#content”).html(data);setupDraggable();););); setupDraggable();); function updateDragBox() $($(“#ui-draggable”).find(“span”).get(0)).html($(“#CategoryName”).val()); function setupDraggable() $(“#ui-draggable”).draggable(containment: ‘#categories’, stop: function(e,ui) $(this).animate(left: 0, top:0, 500); $(this).html(“);); $(“#category_0″).find(“li”).draggable(containment: ‘#categories’,); function destroyDraggable() $(“#ui-draggable”).draggable(‘destroy’); $(“#category_0″).find(“li”).draggable(‘destroy’);</script><style>#categories padding: 1em 0.5em; width: 90%;ul li background-color: #FFFFFF; border: 1px solid #000000; list-style: none; margin: 1em 0; padding: 1em;ul li.droppable-hover background-color: #FFF000;#category border: 1px solid #000000; margin-top: 1em; padding: 1em; width: 97%;#ui-draggable background: #FF0000; padding: 1em; position: relative; width: 300px;</style><h2><?php __(‘Categories’);?></h2><ul id=”categories”> <li id=”category_0″> <?php echo $this->element(‘draw_category’, array(‘data’ => $categories)); ?> </li> <div id=”category”> <p>Enter a category name in the text box below, then drag the object below into the category you wish it to be a part of.</p> <div id=”ui-draggable”><span></span></div> <?php echo $form->input(‘Category.name’, array(‘onkeyup’ => ‘updateDragBox()’)); ?> </div></ul>For simplicities sake during the creation of this article, I have placed the CSS and Javascript all in one file. I would normally segregate these items.

So what’s happening? First up, when the document is done loading, we create our droppable elements. We also call our function to create our draggable elements – both our single draggable element for new categories and all of our current categories in case we would like to re-position them in our tree.

Inside our droppable code, in the drop function we do a couple of important things. One, get the parent_id of where we dropped it. Two, get the text value of our category to save as our new name. Three, determine if we are adding or editing. If we are adding, we post to the add page with just those two pieces of data. If we are editing, we also need to parse out our current id and post all three pieces of data to our edit page.

Finally, when our post is done, we re-draw our tree through AJAX. We also destroy and re-initialize our draggable elements. In part two I plan to not re-draw our tree in AJAX and instead dynamically move or create the elements.

The last file that you need to see is our recursive element to draw our categories. This file goes in app/views/elements/draw_category.ctp:

Code
<?php if ($data): ?><ul> <?php foreach ($data as $category): ?><li id=”category_<?php echo $category['Category']['id']; ?>”><span><?php echo $category['Category']['name']; ?></span> <?php echo $this->element(‘draw_category’, array(‘data’ => $category['children'])); ?> </li><?php endforeach; ?></ul><?php endif; ?>It’s job is quite simple. It loops through all categories, writes it to the screen and calls itself with the child elements. That’s it for today, I hope you have found this article as much fun as I had writing it!

Learn more about how to website traffic.

February 14, 2009

Editing Head Elements With Adobe Dreamweaver Cs4

Filed under: Programming — tkwriter @ 7:07 am

Web pages are not actually the visually rich documents they appear to be; underlying each web page is HTML code. HTML pages consist of a hierarchy of elements: the html element is at the top of the hierarchy and contains two sub elements : the head and the body. The body contains all of the elements which will be displayed in the browser window and the majority of which will be visible to the user. The head element, by contrast, contains information about the web page; meta information as it is sometimes called. In this article, we will look at the different ways in which Dreamweaver allows you to modify elements within the head of a web page, beginning with the title.

The title element should contain a broad description of the content of the page. It is extremely important that each page should have a title and that the title be pertinent to the page that contains it. Dreamweaver automatically adds a title element to every new page containing the text “Untitled Document”. Perhaps the easiest way of modifying the default title in Dreamweaver is simply to enter a title in the Document Title box of the Document toolbar which is normally displayed at the top of the page. An alternative is the choose Modify – Page Properties and then click on the Title/Encoding category on the left of the screen.

The title element is the only element which is syntactically required to be placed within the head element. In addition a number of optional meta elements may be placed which the head element to provide further information about the current page. One such meta element is created automatically by Dreamweaver along with the title: the content-type. This declares the character encoding to the browser and is particularly important if you have a site with an international audience. To specify the character encoding, choose Modify – Page Properties, click on the Title/Encoding category on the left of the screen and then choose an option from the Encoding drop-down menu.

The meta description element is one of the most important since, along with the page title, it is often displayed when your page shows up in the search engine results. The description should consist of a couple of sentences summarising the content of the page. To set the description in Dreamweaver, choose Insert – HTML – Head Tags – Description then enter your description in the dialogue box which appears.

Let’s just mention one final meta element: keywords. The keywords meta element should contain a list of the important words and phrases to be found on the current page. Only text that actually appears on the page should be listed. To create the meta keywords element in Dreamweaver, choose Insert – HTML – Head Tags – Keywords.

If you want to have some video fun – to get distracted a little from the programming stuff – get yourself cheap PlayStation 3 and taste the virtual life of the 21st century.

February 3, 2009

Free Important Advice – Computer Programming Language

Filed under: Programming — tkwriter @ 4:23 am

The digital world constantly changes. New technologies are introduced and new developments in the industry are being made known to the public. There will always be changes in technology. And technology will constantly improve to help create a better world.

Computer Programming Language Evolution
And one of the primary movers of technology and the digital world is a computer programming language. This is the language spoken and understood by the computer. The computer language is machine language. Basically, what the computer can understand and process are just a bunch of one’s and zero’s. It is really upon the expertise of the programmer to create special software that could be understood by the computer and the human user.

Computer Programming Course
Computer programming software follows a certain language that computers follow. Examples of these languages are the Assembly language, C++, FoxPro, Visual Basic, Visual FoxPro and several others. These types of software can mediate between the computer and the programmer. All the programmer has to do is to input the commands he would like the computer to do. He’ll write the commands in the syntax that the computer programming language understands. The commands are then processed and converted into the machine language the computer processor understands. This is how the many applications and programs downloadable from the internet are created.

Computer Programming Language Evolution
Different computer programming languages can provide different levels of functionality. Some software can give crisp graphical images. These programming languages are usually used in making games. Games are really what make computers half popular. And this is all because of the computer programming language created for making games that people from all over the world love. Games are complex individual programs that are interlinked together by the main game application.

Computer Programming Career
Aside from computer games, programming languages allows for the development of functional software such as word processing programs, database programs, web-based applications, and several others. The software is made possible with the creation of the programming languages that are most fitting to the design and interface of the program being created. There are many times that a single application can be created multiple language platforms.

But then again, all of these programs won’t be possible without the creation of an operating system. The operating system is the software by which a computer system runs. Popular examples of such software are the Windows platform, Linux, Unix, and Mac OS. There are a lot of old operating systems being used before and the most popular of which is DOS. The operating system serves as a good median for the computer and the processor’s language. Its main job is to translate every single program created for the operating system and allow the machine to process them accordingly, so that people can run and use the program.

For some fun – get your mind lost about video games for a while – with cheap PlayStation 3 everything is possible.

January 3, 2009

Unbiased Road Map to Online Corporate Publishing

Filed under: Programming — tkwriter @ 8:18 pm

Online Corporate publishing is getting to be more and more popular. This will save many trees from being cut down to process into paper for printing. And it helps the environment. A variety of electronic versions of your report and accounts ranging from PDFs to fully interactive html versions can be produced. PDFs or Portable Document Format is very neat, and it is not editable making it very safe from competitor checking on your Quark Xpress document and the names of previous clients. PDFs are very popularly used in legal firms in USA because the nature is such that you cannot pry into the history details of the source file and check on the company’s clients. They are also very compact, making the file loads faster than a .doc file for the same file size.

Read about Online Company Report and Interactive HTML

Some web sites are well designed with high technical knowledge implemented to produce well written code or Hyper Text Markup Language, the basic structure of web sites. As you progress from page to page, it can produce a detailed Online Report,or financial report, etc in this online document publishing. All that is required is an internet connection to your computer and you are ready to read online documents that are on the go. Being interactive, helps make it more customizable and targeted for the readers.

Statistics from Graphs and Charts

Pictures can be added, graphs and charts can be produced immediately based on the data keyed in. This will give the readers a visual enhancement to tabulate and forecast future results that can be used in shared Online reports and other financial reports. The statistics derived from the graphs and charts can help a finance personal make wiser decisions as he checks the online published document. As a picture is worth a thousand words, allowing the HTML report to produce graphs and bar charts on the go will make it very popular with clients and visitors as they are easy to comprehend and understand. It will save you from typing too many words just to explain one idea.

Greener Environment

HTML Annual Report publishing makes the environment greener and safer. Fewer trees are cut down to produce paper for printing material and this will make it more environmentally friendlier. Instead of paying more for the delivery of share reports that come in heavy report sent in envelopes, you can save money by reading the Online Report. And it saves time to send the share reports to your home through snail mail.

Sophisticated software

Sophisticated software needs to be installed and put in place to convert your text into PDFs so that they can be read using the computer. You will need to install PDF converter on the server so that it can do the job for you. Whenever a client comes or a visitor visits, by pressing a few buttons, he can quickly publish online documents on the go. This will make the whole process of printing more efficient besides saving some trees. All it requires is the necessary knowledge to implement it.

For expert advice on Online Corporate Publishing please visit our website today!

For the tips about getting free traffic – visit this site.

November 21, 2008

Learning how to program

Filed under: Programming — tkwriter @ 4:27 pm

These days, programming is a very useful skill to have, especially if you are an internet marketer or you work with computers a lot. So where do you learn how to program, and what language should you start off with? Well, it depends on whether you want to learn server side languages (such as PHP) or desktop languages such as C++ (or both). There are tons of good books on programming that are worth reading. If you don’t want to get any books, there are also several excellent tutorials online going through every major programming language, such as the one at w3 schools.

November 20, 2008

Learning how to be a programmer

Filed under: Programming — tkwriter @ 9:57 am

Learning how to program software in any language takes a lot of work. If you have never learnt programming before, then it will take you longer to learn a new language than it would if you had learnt some other programming language before. Fortunately, there are a lot of good books and online tutorials that can teach you HTML, PHP, MySQL, C++ and more. W3 schools is the most well recognised website that has tutorials on programming. You also need to think about why you want to be a programmer, since you can always outsource software creatiion to people.

October 27, 2008

Java Coding: Facts

Filed under: Programming — tkwriter @ 9:22 pm

At Long Last, they have announced the answers of an individual review on the state of important scale|corporate[/spin] MS .NET applications programme programs|practical applications[/spin]. java api

CA, an individual IT management computer software company, pronounced in the review, conducted by Evans Data Corp. (EDC)java tutorials , that important scale|corporate[/spin] MS .NET investing maturation is outpacing SUN Java investing maturation. The CA- sponsored review, which targeted corporations with 1,000-plus employees and questioned 350 software architects and directors involved in making and/or managing business-critical MS .NET practical applications, also observed that a deep market exists for structured practical application operation management (APM) solutions that assistance the increased use of both development architectures in the same organization.

“These review answers confirm that MS .NET practical applications are diffusing in significant corporations and their acceptance and dependability is continuing to increase,” said Mike Allen, director of product management for CA Wily Technology, a division of CA. “This begs the question of how to effectively manage environments that use both MS .NET and SUN Java. CA Wily advocates a comprehensive practical application operation management solution that addresses both with a single solution and helps key Web applications to meet business, customer experience and operation goals.”

The review observed that most corporations have highly heterogeneous practical application environments and that MS .NET assistance teams are similar to SUN Java assistance teams in terms of size, structure, problem types and times to isolate problems. A vast majority of respondents said their MS .NET and SUN Java groups are structured within their assistance organizations, highlighting the industry requirement for a comprehensive approach to practical application operation management. As with SUN Java, management responsibility is spread across departments (development, operations, quality assurance, etc.), and equally required in both environments.

Highlights of the review include:

- Nearly 60 per centum responded that their MS .NET investing is growing, while 50 per centum said they are adding new MS .NET personnel; – 57 per centum of respondents indicated that MS .NET expenditures comprise more than a quarter of their overall business-critical practical application investing; nearly 20 per centum of respondents put that figure between 75 and 100 per centum.

“An increasing number of corporations are realizing the benefits of deploying applications built on both MS .NET and SUN Java. However, with those benefits come the challenges of managing a heterogeneous environment coupled with the unique issues of both development architectures,” said Jasmine Noel, founder and partner, Ptak, Noel & Associates. “To help maximize ROI, IT organizations should use a single tool to manage the operation and availability of MS .NET and SUN Java applications in the same environment.”

Additional findings on the state of corporate MS .NET applications include the following data points on problem causes and slowdowns:java programming software

- 54 per centum of respondents said that development is the division responsible for MS .NET assistance, compared to 69 per centum for SUN Java;

October 11, 2008

Competent Guidelines – Database Management Stuff

Filed under: Programming — tkwriter @ 12:52 am

Important database management questions and definitions.

The database manager is responsible for the creation and maintenance effective software that meets predefined data storage norms. Accurate data storage and retrieval must be identified, researched and refined. Database management software is the working base for a database manager. These robust computer applications are specifically built for support of data warehousing. And, each database manager is held responsible by his organization for getting the best value for database investments. A database manager must be aware and prepared for the quick changes that occur in a complex business environment.

Database management is a field which is evolving at a rapid pace. Ever so often, the database manager needs to execute application and platform changes in view of changing data needs. If this is a free database management software, this means it can lack support and the database manager needs to take care of it. As such, database management software should be built with modularity to allow for transition to accommodate such changes.

The best type of database management software will allow the individual administrating the database to create applications that allow for the best level of performance and functioning. It must also be tuned for automatic data tuning to allow for the best performance, as well as be easy to use.

Effective database management software programs help you to identify problems in the provided information before users and customer service personnel can be adversely affected by them. The programs must also be able to analyze the information so as to pinpoint the actual causes and hangups.

A properly written database package will work well regardless of how much data is present. It needs to be able to adapt to rapid change via innovation, and cover everything from a local shop to an international enterprise. Ideally, changes in the software will result in administrators become more efficient, while not limiting the application code.

Innovations in suites of database management products has allowed firms to deliver on its data needs in periods of both planned and unplanned change. Special software in these suites that contain advanced diagnostic capabilities that are needed for resolution of database issues. A console is also included in the suite that will monitor all levels of complex technological stocks including process schedulers and application servers.

The manager of a database is in charge of developing a software infrastructure that effectively enables the storage of data according to the organization’s needs. This person must be able to uncover, identify, and develop new ways to improve data accuracy and availability. This person uses database management software, a type of computer application designed to enable data warehousing. No matter the scale of innovation, software for database management must allow seamless data transfer and storage.

Learn extra tips about how to capture video on screen and how it can help you.

October 5, 2008

Basic: A Computer Programming Language

Filed under: Programming — tkwriter @ 3:14 am

Computer programming has its own language, and that’s just the beginning of the software adventure. There are many different languages in computer programming, and all of them have their own purposes. In order to understand the importance of computer programming languages, knowing them, and tweaking them, one has to understand the importance of computer programming. Computer programming produces software packages, among other things, to meet our needs. We may need software for accounting, making photos bigger or smaller, or editing our home videos. Behind all these software packages are the computer programmers who use their individual languages in order to create the software.

BASIC: A Computer Programming Language
One such computer programming language is the Beginner’s All-Purpose Symbolic Instruction Code, or BASIC. BASIC is actually composed of many different kinds of programming languages that are actually higher level than most other languages. This BASIC family of computer programming languages was first designed in the 1960’s, and was originally made for non-science people to gain better access to computers. During that time, using a computer required that a person write customized software, a task that only mathematicians and scientists were equipped to do. The BASIC language was therefore a bridge for people of other professions to take advantage of the power of computers.

When the 1970’s came, the BASIC language, whether in its original form or a variant of it, spread onto microcomputers; and by the 1980’s, even home computers could be run in BASIC. Today, BASIC remains popular, as it serves as the basis for many of the more modern programming languages that have been developed in the wake of advanced operating systems and the Internet.

When it was originally conceived, BASIC was meant for beginners: it was a language that people could use easily, whether or not they were educated in mathematics and the sciences. The language also had to be a general purpose one, in that it had to serve many different needs, and not only those that mathematicians and scientists required. The root language of BASIC also had to allow for advanced features to be plugged on as experts grew more and more adept in it, and as the language found further use in many other fields. BASIC was also meant to be interactive, and was designed to show error messages that were clear and friendly; that is, these error messages had to completely explain what the problem was, which would hopefully allow the user to fix it faster and easier. More on Computer Programming Language.

Powered by WordPress