Tutorials

Tutorials about HTML, CSS, PHP, Javascript, and Photoshop

  • Home
    Home This is where you can find all the blog posts throughout the site.
  • Categories
    Categories Displays a list of categories from this blog.
  • Tags
    Tags Displays a list of tags that has been used in the blog.
  • Archives
    Archives Contains a list of blog posts that were created previously.
  • Login
3153

Developing software is usually a two step process that involves developing the user interface and the business logic of the application.  Windows Phone is no exception to this paradigm. When developing for Windows Phone,  XAMLIs used for the implementation of the user interface of Windows Phone applications

1. What is XAML?

XAMLOrExtensible Application Markup Language is a declarative language developed by Microsoft and used in Windows Phone to create graphical user interface objects. If you're familiar withXMLThen a code snippet of XAML will look very familiar.  XAML is to aC#Developer whatHTMLIs to a web developer. It is the basis of user interface design for Windows Phone

Such as Buttons, Text Blocks, etc, The Windows Phone platform has a lot of building blocks at its disposal, Text Boxes. It is impractical and cumbersome, Even though it's possible to develop a Windows Phone 8 application using only C#

XAML makes creating user interfaces much easier. You are presented with two views, After creating a new Windows Phone 8 project or page in Visual Studio. One view displays the XAML code while the other view shows the developer its visual design representation

Let's revisit the project we created in the, To better understand thisprevious tutorialIn which we created our first Windows Phone 8 application

<Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid. RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid. RowDefinitions>

        <. --TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
            <TextBlock Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <. --ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">

        </Grid>
    </Grid>

You immediately notice the same hierarchical structure you find in XML and HTML. Which we will be discussing later on in this series, Each element in the XAML code represents a Windows Phone control. You'll notice that each element has an opening and closing tag, just like in XML or HTML. Taking the following structure:, You can also see that some elements have additional attributes

<ElementName Property1="Value" Property2="Value". >
  <ChildElementName Property="Value">
  </ChildElementName>
</ElementName>

I will refer to each element in the XAML file as a control as they represent Windows Phone controls, which are objects that are a part of the framework. Each of these controls can have properties attached to them. Such as the , Some of these controlsGrid and StackPanel controls, can even contain other controls within them. For example, look how the StackPanel control with the Name property of TitlePanel contains two TextBlock controls

This hierarchical arrangement of elements enables developers to design the user interface of Windows Phone applications with much more ease and also provides structure between controls that make up the user interface of a Windows Phone application

2. XAML versus Code

It is possible to create the entire user interface of a Windows Phone application in C#, without using XAML, As I said earlier in this article. However, this is not very practical, In reality. This isn't recommended, because it makes designing the application's user interface untidy and a bit all over the place

Strictly using C# to create the application's user interface will significantly limit the possibility of using the , In additionMVVMDesign pattern that is baked into Windows Phone development. This means advanced techniques, such asData bindingWill be more difficult to implement

Let's take a close look at the two techniques, to building an application's user interface, XAML and C#. For this comparison, I'll first show how aTextBlockAnd a ButtonControl are declared within aStackPanel control using XAML. I will then show you the equivalent in C#

XAML

<StackPanel>
    <TextBlock Margin="20">A Simple TextBlock</TextBlock>
    <Button Margin="10" HorizontalAlignment="Right" Content="Simple Button">
    </Button>
</StackPanel>

You can see how declarative the above XAML snippet is. It's easy to understand the hierarchy of the controls. There's another benefit when using XAML. We can directly see the result of our changes in Visual Studio through the design preview pane, which is usually positioned on the left in Visual Studio

C#

Let's see how we can implement the same user interface using C# instead of XAML

//Create Our StackPanel
StackPanel stackPanel = new StackPanel();
this. Content = stackPanel;

//Create Our TextBlock
TextBlock textBlock = new TextBlock();
textBlock. Margin = new Thickness(10);
textBlock. Text = "A Simple TextBlock";
stackPanel. Children. Add(textBlock);

//Create Our Button
Button button = new Button();
button. Margin= new Thickness(20);
button. Content = "Simple Button";
stackPanel. Children. Add(button);

As you can see, it's a bit clunkier in comparison to XAML and we're unable to see the result of our changes on the fly. You may also have noticed that the code block in C# is almost double the lines of code and it isn't as readable as the XAML snippet we saw earlier

For Windows Phone development, XAML is the recommended way to create user interfaces. For example, when the control needs to be dynamic to some extent, there may be times that we need to implement more complicated controls that are difficult to create using XAML, However. Even though these situations are less common, it's good to know that we can fall back on C#

Conclusion

XAML is an integral part of Windows Phone development and a firm understanding is therefore essential. I encourage you to take a look at theofficial XAML documentationFrom Microsoft on the Windows Phone Dev Center. It contains in-depth information about the use of XAML for Windows Phone development

We've taken a look at the role of XAML in Windows Phone development and how it compares to C# to create user interfaces, In this tutorial. And how to implement them in a Windows Phone 8 application, we'll continue to work with XAML and come to grips with some of the more common Windows Phone controls, their use,  In the next tutorial

Continue reading
0
3100

But before we dive into the specifics, let's make sure that we have a clear understanding of the design patterns that are in play in the Magento application, Magento has a pretty well implemented Event/Observer system

How it works and what it is, lets' talk about the concept of the event system, Specifically. Though we've covered certain design patterns in other articles on Tuts+, we haven't done so within the context of Magento.  

Let's take a look at the pattern in order to gain a clear understanding of how it is, how it works, and how it's beneficial, To that end

Design Patterns as a Whole

Over the years a wide array of design patterns have been dveloped. But whatIsA design pattern exactly

To quote Wikpedia:

A design pattern is a general reusable solution to a commonly occurring problem within a given context in software design, “In software engineering. ”

If we reduce that a little we're left with: a design pattern is a reusable solution to a common problem. That is as perfect a description.  

The design pattern is a template that can be used to create a solution that will fit problems of the same nature. The pattern itself is not the actual solution, it defines the way the solution can be implemented as a guideline.  

Your actual solution, even if adhering to the defined pattern can be different from mine as long as they both follow the guidelines set out by the design pattern

The Observer Pattern

Now that we know what a design pattern really is, lets take a look at the Observer Pattern

The Observer Pattern has turned out to be a very valuable addition to the architecture, First implemented in the MVC architecture. In part because of this an enormous amount of libraries have implemented the pattern over time and if you've been programming for a while it's not unlikely you've already used it

Let's take a look at how it works, Enough history now though

To observe something is to look at it, to observe its state, or. In a technical context, this is no different. Events, Observers by definition are watching something and in our case. The observers that are observing this event get executed, The idea here is that if an event gets dispatched.  

The subject that is being observed will be passed along by reference in order for the observer to be able to update or check it for changes, Generally

Check out this example put together from the Magento code:

Array('product' => $this));
        return $this;, array('product' => $this));
        $this->_getResource()->validate($this);
        Mage::dispatchEvent('catalog_product_validate_after', class Mage_Catalog_Model_Product
    extends Mage_Catalog_Model_Abstract
{
    public function validate()
    {
        Mage::dispatchEvent('catalog_product_validate_before'
    }
}

So this is the validate method as its available in your run of the mill Magento installation, Alright. For clarity I replaced two variables with their actual values. You can see two events are dispatched hereCatalog_product_validate_beforeAndCatalog_product_validate_afterEach of these gives the product object along with the dispatch so that the observer might do something with it

Class Enterprise_AdminGws_Model_Models
    extends Enterprise_AdminGws_Model_Observer_Abstract
{
    public function catalogProductValidateAfter(Varien_Event_Observer $observer)
    {
        if ($this->_role->getIsAll()) {
            return;
        }$product = $observer->getEvent()->getProduct();
        $this->_forceAssignToWebsite($product->getWebsiteIds());
    }
}

And here's an observer class and its method. This class and method are hooked into the system using Magento's configuration system. The event itself is handed to the observer class and the product is reachable from the event

I'll cover the actual creating and hooking of observers as well as reaching the subjects with more detail in the next post

Why Use This Pattern?

Or its close relatives like the Pub/Sub Pattern is the modularity it provides, One of the primary arguments to use the Observer Pattern

Because anything can hook into an event that is being dispatched, you never have a strong reference to it. This is exceptionally useful in a setting where you're always working with modules that may or may not provide services to a specific element that may or may not be available.  

To use Magento again, I can build a module that will observe product changes as well as a module I built that fires off its own custom events. But using a Pub/Sub or the Observer Pattern I can make that dependency optional and only apply whatever it is my current module to it when it's available, Now, in a regular system this module would be dependent on the earlier module

What's Next?

How you can start using it in your own modules and provide them in your own modules as well to hook into from different ones, in the next post I'll explain how it's used in Magento, or for others to hook into, After this quick refresher on what exactly design patterns are as well as the more in depth look at the Observer Pattern

Continue reading
0
3779

What You'll Learn

Ourlatest course on Mastering Male Vector PortraitsUsing Adobe Illustrator,  will teach you how to create two portraits of men in different styles.  

Tuts+ Design & Illustration Editor Sharon MilneWill walk you through the whole project from start to finish. You'll learn about the unique challenges of creating male portraits,  Along the way, and see Sharon's tips and tricks for vector drawing.  The course will teach you:

  • The important differences between male and female portraits
  • How to create a simple line art portrait, to get started with the concept
  • Detailed illustration, creating a portrait with depth, How to move on to a more advanced, colour, and detail

Watch the Introduction

Subscribe or Buy Now

Take a look at our monthly or yearlysubscription optionsAnd more, subscriber benefits,  to access everything at Tuts+ — all our courses, eBooks. If you're just interested in this course, Or, you canbuy it individually for $15

Continue reading
0
4390

WordPress is an amazing CMS when it comes to setting up a website for a personal blog, or even an eCommerce site, corporate website.  Building an eCommerce website using WordPress is really easy, with a variety of plugins and development options available, but there are a number of  challenges that you have to face before launching your online shop

I intend to cover in detail some of the problems and challenges that you will most likely face and some of the solutions that are available to help you overcome the hurdles, In this two-part series

Choosing the Right eCommerce Theme

Depending on your store design concept and what you intend to sell, choosing the right eCommerce theme for your site can be a difficult choice to make.  

Not every WordPress theme can be suitable for an eCommerce site: You have to take into consideration how the various different pages will be, to the shopping cart and finally the checkout, After all, from the catalogue page.  

Regardless of whether they are visiting the site for the first time or not, The whole process has to be simple and easy for any client coming to the site.  

One Plugin Solution That’s Fits All

Despite that are available on the market, it's really difficult finding a single one that offers almost all of the solutions that you may need. Each of the available plugins tends to cover some of the basic features, which come at an extra cost, so to leverage the best out of it, you will probably be required to purchase add-ons.  

Particular WordPress plugins are best suited for a certain type of eCommerce site as compared to general site for example a digital good’s site will best work with easy downloads as compared to a site that takes full advantage of all the functionalities of a WooCommerce plugin, looking at the type of product that you will be selling, Also

Website Scaling and Growth

The number of concurrent scripts that a simple WordPress blog executes can sometimes overwhelm servers. Imagine in the case of a busy eCommerce site, From there. Especially as the store gains popularity when even more and more products and services are added to the site, Processing a large volume of orders can really prove to be a pain in the neck.  

The whole management of products requires sufficient knowledge and organization to ensure the smooth operation. This is not say that none of the plugins can manage this, and we'll look at the next post in the series. We will be covering some of the best plugins that can address this particular problem, Specifically

Website Security and Passwords

Most of the eCommerce sites using the WordPress platform tend to use other third party payment methods and merchants to handle the cash transaction, this is much easier and it will take a lot of paperwork and procedures to be allowed to store customers debit and credit card details on your database.  

Customers are still required to login to the store either to do simple and easy checkout and also take advantage of the discounts that come with returning customer, Despite this, in this scenario, this poses a serious security threat, some customers use the same passwords associated with the cards they are using on the site.  

Requiring customers to come up with a stronger password can be start to dealing with this issue. I also intend to cover on how to implement such security measures and protecting the site against brute force attack, In the next part

WordPress Core, Theme and Plugin Updates

One of the best things about WordPress is the frequency of updates that are released. This update addresses some of the most recent problems facing the CMS. Some themes tend not be compatible with the updates thereby causing the website to either break or not behave the way that it should, Although this is really a good thing

Especially when you are not sure about your theme’s compatibility with future WordPress updates, Pushing updates manually on your site can really be helpful.  You can always check with the plugin developer or theme developer to ascertain the themes compatibility

Theme and Plugin Support From the Developer

As much as this may seem like a big deal, during the development or the theme customization process, you need to have all the necessary support.  

Choosing the right plugin or theme from the right developer may be prove to be a lifesaver. They can at least offer solutions to some of the problems you may be facing, or even offer custom development services to address your specific need

Summary

The right plugin to some of the security concerns for example user passwords, In this post we have covered the basic problems and challenges that you may face when developing a WordPress eCommerce site, from choosing the right theme for your website.  

What's Up Next?

The ways of how best to secure your site, analysis of some of the plugins you can use to manage big stores and some of the qualities you should look for in an eCommerce theme, Join me in the next part of this series where will deal, in-depth

In the meantime feel free to leave any comments or questions below

Continue reading
0
3614

I am going to explain how you can build a custom theme with the popular open source e-commerce framework, In this seriesOpenCartI'll explain basic structure of the OpenCart theme, In this first part

Before proceeding further, I assume that you have working OpenCart installation on your local workstation. If that's not the case, check the OpenCart online documentation and set it up (as doing so is outside the scope of this tutorial). Once you have a working OpenCart installation you are ready to dive in

A Quick Look at the OpenCart Structure

Basic OpenCart Structure

OpenCart is built using MVC design pattern which allows separation of concerns between the data and the presentation. You don't need to worry about tweaking the files all the time which contains the application logic and template code together, As a theme developer

OpenCart provides really clean directory structure when it comes to organization of the framework. All the files related to the back-end interface are placed in theAdminDirectory. Files dealing with front-end interface are placed in theCatalogDirectory. But what we are really interested in is the Catalog directory as eventually we will end up with the custom front-end theme at the end of this tutorial series

The OpenCart Design Pattern: MVC-L

Catalog Structure

Or MVC, Model View Controller, is a very popular design pattern in the field of software development. OpenCart just adds an another element to it: , LanguageWhich is why we refer to it as MVC-L.  

The, In our caseViewPart is where we will place all the theme related code. In a quick overview of theCatalogWe will see how OpenCart does its magic, structure

Elements Overview

  1. Controller It's responsible for handling the application logic
  2. Language It's useful for separating language specific information for multilingual sites
  3. Model It's responsible for fetching the data from back-end database
  4. View This is where we will spend most of our time. It's responsible for rendering the front-end layout

Getting Familiar With the Presentation Layer

View Structure

A default OpenCart theme is available inViewDirectory. This is the part which we will explore in this section. There are two more directories:, At the deeper levelJavascriptAndTheme 

Let's just assume that all of the required JavaScript files are placed in the, For nowJavascriptDirectory. As well, Sometimes there is an exception to this in which case we can also place stylesheets and related image files under this directory. OpenCart provides the colorbox library which contains more than just JavaScript, For example

What we are really interested in is theThemeDirectory. Looking further, there is a directory namedDefaultWhich is the only built-in theme provided by OpenCart. Don't get just overwhelmed by the deeper theme structure as we'll explore that in more detail soon. See what a theme's structure looks like, For now

Default Theme Structure

  1. ImageAs you've likely guessed,  all the image files related to the theme go here
  2. StylesheetWhich is likely to be stylesheets,  Skinning related code, will go here
  3. TemplateYou can find all the front-end template files here,  As the name suggests. All the template files are organized in a modular way to keep things neat and clean.  

If you give a quick look at the, For exampleAccountDirectory under template you will see most of the files are related to user screens in the front-end. We'll look at this in more detail in the next article

The World of Templates

Template Structure

As I mentioned earlier OpenCart provides a nice way to organize template files. In this article, I'll try explain what it looks like within theTemplateDirectory. You can develop your own modules as well for your custom requirements, Before moving ahead, it's worth noting that although OpenCart comes with a bunch of built-in modules that provide the features required by a basic shopping cart.  

With that said, let's have a closer look at the template categorization

Template Categorization

  1. Common Template files for the common elements across different pages are placed in this directory. And sidebar related templates, footer, Examples include header. You should also place your template files here if you plan to use that across different pages which makes it easier toMaintainIn the long run. Of course it's not mandatory to do so, but it's nice to do the things the way itShouldBe done
  2. ErrorIt's just the error template which resides here,  At the moment
  3. InformationSitemap Page and Static informational page,  You can find here templates related to Contact Page
  4. Module It's an important directory in terms of the kind of templates it keeps. As I said earlier in OpenCart we can create our own custom module to fulfill our custom requirements so this is the place where you would like to put your template files related to your custom module

Apart from the template structure explained above, there are still other template directories that contain page-specific template files. In terms of OpenCart, we can say that they are RouteSpecific template files.  

The template associated with that should be found under , For example, when you visit the "My Account" page in the front-endCatalog/view/theme/default/template/accountLater in the series, we'll see how to find a specific template file looking at the url path of that page

Summary

That's the end of the first part of this series. You should be familiar with the basic theme structure of the OpenCart

In the next part, we'll learn how to create a custom theme in the OpenCart. Feel free to leave your comment, If you have any questions or feedback




Continue reading
0

Testimonial

Thank you so much! We are very happy with our new website. It is easy to use and all of our customers tell us, they love it.

Contact Us

  • 13245 Atlantic Blvd. #4352
    Jacksonville, FL 32225
  • 904-240-5823