Full Trust European Hosting

BLOG about Full Trust Hosting and Its Technology - Dedicated to European Windows Hosting Customer

Umbraco 7.2.8 Hosting UK - HostForLIFE.eu :: How to Create a Comment Form using MVC in Umbraco

clock October 7, 2015 13:04 by author Rebecca

In this tutorial, I'll show you how to create a comment form using MVC in Umbraco. Many people had a lot of trouble working out how to create forms in Umbraco because a lot of the documentation around is either for an old version of Umbraco, using a third party library or just not very helpful!

So, we're going to start off with creating a partial view in the 'Partials' folder within the 'Views' folder, we'll then add the basic code needed to render the form and link it to a custom surface controller that we'll create in the 'App_Code' folder.

Step 1: Create the partial

Create a partial view in the 'Partials' folder located under the 'Views' folder and name it 'ContactForm' this will be where the GUI part of the form is located, it'll also be what's called from our view page to render the form.

Step 2: Adding the form

To create forms in MVC you can use a neat way of adding elements instead of writing the HTML, for example we can use 'LabelFor', 'EditorFor' and 'ValidationMessageFor' pretty neat right? All of these are preceded by '@Html.' because they're located under the 'Html' class.

See my example below and paste it into a partial view called 'CommentForm' to get started.

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    @{
        Layout = null;
    }
    
    @using (Html.BeginUmbracoForm("SubmitComment", "CommentFormSurface"))
    {
      @Html.LabelFor(x => Model.Name)
      @Html.EditorFor(x => Model.Name)
      @Html.ValidationMessageFor(x => Model.Name)
    
      @Html.LabelFor(x => Model.Email)
      @Html.EditorFor(x => Model.Email)
      @Html.ValidationMessageFor(x => Model.Email)
    
      @Html.LabelFor(x => Model.Comment)
      @Html.EditorFor(x => Model.Comment)
      @Html.ValidationMessageFor(x => Model.Comment)

This is esseintially the form that people will see and use on our website, it is linked to a model and controller which we will create in step three by means of an inherits statement in the first line which calls the 'CommentFormModel'.

Step 3: Setting up the model and controller

To create the model and controller, you need to create a new class file in the 'App_Code' folder and call it 'CommentController', within this file, you'll add the model and surface controller for your form, copy and paste the below code into the class file to get started.

    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Net.Mail;
    using System.Text;
    using System.Web;
    using System.Web.Mvc;
    using Umbraco.Web.Mvc;
    using umbraco.BusinessLogic;
    using umbraco.cms.businesslogic.web;
    
    namespace LukeAlderton
    {
        ///
        /// Comment form controller deals with all comment systems
        ///
        public class CommentFormSurfaceController : SurfaceController
        {
            [HttpPost]
            public ActionResult SubmitComment(CommentFormModel model)
            {
                //model not valid, do not save, but return current umbraco page
                if (!ModelState.IsValid)
                {       
                    return CurrentUmbracoPage();
                }
    
                // Create the comment and add then data then publish it
                User author = new User(0);
                Document comment = Document.MakeNew(model.Name, DocumentType.GetByAlias("uBlogsyComment"), author, CurrentPage.Children.First().Id);
                comment.getProperty("uBlogsyCommentName").Value = model.Name;
                comment.getProperty("uBlogsyCommentEmail").Value = model.Email;
                comment.getProperty("uBlogsyCommentWebsite").Value = model.Website;
                comment.getProperty("uBlogsyCommentMessage").Value = model.Comment;
                comment.Publish(author);
                umbraco.library.UpdateDocumentCache(comment.Id);
    
                // Add date to the page
                //TempData.Add("SubmissionMessage", "Your comment was successfully submitted");
    
                // Redirect to current page to clear the form
                return RedirectToCurrentUmbracoPage();
    
                // Redirect to specific page
                //return RedirectToUmbracoPage(2525);
            }
        }
    
        public class CommentFormModel
        {
            [Required]
            [Display(Name = "Name")]
            public string Name { get; set; }
    
            [Required]
            [RegularExpression(@"^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$", ErrorMessage = "Invalid Email Address")]
            public string Email { get; set; }
    
            [DataType(DataType.Url)]
            public string Website { get; set; }
    
            [Required]
            [DataType(DataType.MultilineText)]
            public string Comment { get; set; }
        }
    }


This controller is designed to replace the comment function of the uBlogsy comment system which adds a node under the post, within the comments node.

The top class called 'CommentFormSurfaceController' is the surface controller and it handles everything that happens after the form has been submitted, in our case we call the method 'SubmitComment' to add a comment to the post via it.

The lower class called 'CommentFormModel' is our view model and it handles the variables available to us and what they should be displayed as, this model has four variables which can all be accessed via 'model.variablename'.
Step Four: Using the form

To Use the form you simply add the following line into any view in your website:

    @Html.Partial("CommentForm",new LukeAlderton.CommentFormModel())

It's as simple as that!

HostForLIFE.eu Umbraco 7.2.8 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.



European Drupal 7.39 Hosting - HostForLIFE.eu :: How to Use Rules to Send HTML Emails

clock August 24, 2015 10:45 by author Rebecca

In this tutorial, you'll learn how to use Mime Mail to configure Drupal to send HTML emails. We'll also look at how to send them using Rules.

Let's begin by downloading a few modules. Go ahead and download Rules, Entity API, Mime Mail and Mail System. If you prefer Drush, run the following command:

drush dl rules entity mimemail mailsystem

Once everything has been downloaded, enable Mail System, Mime Mail, Rules and Rules UI.

Step 1 - Configure Mail System

Go to Configuration, "Mail System" and make sure that MimeMailSystem has been selected in the "Site-wide default MailSystemInterface class" and "Mime Mail module class" drop-down list.

Step 2 - Configure Mime Mail

Now, head over to Configuration and click on "Mime Mail". From this page you can change a few of the module's configuration options. The one we're interested in, for now, is the "E-mail format".

Change it from "Plain text" to "Filter HTML". This means that when emails are sent they'll be filtered by the "Filter HTML" text format.

At this point, you should be able to send HTML emails. If certain tags are being filtered out, make sure that the text format selected in "E-mail format" allows the tags.

How to Send HTML Emails using Rules

Mime Mail integrates beautifully with Rules. The module implements two custom actions: "Send HTML e-mail" and "Send HTML mail to all users of a role". As you may have guessed, both actions allow you to send emails as HTML.

I won't go through the process of creating a basic rule. I'll assume you've already created one. So go and edit a rule that will send an email. Click on "Add action" and select "Send HTML e-mail" or "Send HTML mail to all users of a role" from the drop-down list.

As you can see, sending HTML emails from Drupal is not that hard. However, if you're emails are still being sent as plain text and you have a lot of modules installed start reviewing your existing setup. Occasionally, a module might change some mail setting that prevents an email from being sent as HTML.

HostForLIFE.eu Drupal 7.39 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.



Umbraco 7.2.8 Hosting France - HostForLIFE.eu :: How to Use Standard Conventions to Create Simple Costum Tree

clock August 21, 2015 07:22 by author Rebecca

This article will explain how to create a simple custom tree an angular editor & dialog using standard conventions. This article doesn't go into detail about how to persist data in your editors, it is a simple tutorial defining how routing interacts with your views and where your views need to be stored.

So all the steps we will go through:

  •     Creating a tree with a menu item
  •     Create an editor
  •     Create a dialog for the menu item

Create a Tree

Step 1

First you need to define a tree class that inherits from Umbraco.Web.Trees.TreeController:

public class MyCustomTreeController : TreeController
{
}

The name of your tree must be suffixed with the term 'Controller'.

Step 2

Next we need to add some attributes to the tree. The first one defines the section it belongs to, the tree alias and it's name. Ensure your tree alias is unique, tree aliases cannot overlap.

[Tree("settings", "myTree", "My Tree")]

The 2nd attribute does 2 things - Tells Umbraco how to route the tree and tells Umbraco where to find the view files. This attribute is not required but if you do not specify it then the view location conventions will not work.

[PluginController("MyPackage")]

There are 2 methods that need to be overriden from the TreeController class: GetTreeNodes & GetMenuForNode. This example will create 3 nodes underneath the root node:

protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
{
    //check if we're rendering the root node's children
    if (id == Constants.System.Root.ToInvariantString())
    {
        var tree = new TreeNodeCollection
            {
                CreateTreeNode("1", queryStrings, "My Node 1"),
                CreateTreeNode("2", queryStrings, "My Node 2"),
                CreateTreeNode("3", queryStrings, "My Node 3")
            };               
        return tree;
    }
    //this tree doesn't suport rendering more than 1 level
    throw new NotSupportedException();
}

Step 3

Next we'll create a menu item for each node, in this case its a 'Create' menu item

protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
{
    var menu = new MenuItemCollection();
    menu.AddMenuItem(new MenuItem("create", "Create"));
    return menu;
}


That's it, the whole tree looks like this:

[Tree("settings", "myTree", "My Tree")]
[PluginController("MyPackage")]
public class MyCustomTreeController : TreeController
{
    protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
    {
        //check if we're rendering the root node's children
        if (id == Constants.System.Root.ToInvariantString())
        {
            var tree = new TreeNodeCollection
            {
                CreateTreeNode("1", queryStrings, "My Node 1"),
                CreateTreeNode("2", queryStrings, "My Node 2"),
                CreateTreeNode("3", queryStrings, "My Node 3")
            };
            return tree;
        }
        //this tree doesn't suport rendering more than 1 level
        throw new NotSupportedException();
    }
    protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
    {
        var menu = new MenuItemCollection();
        menu.AddMenuItem(new MenuItem("create", "Create"));
        return menu;
    }
}

Create an Editor

An editor is simply an angular view (html file) so you can really do whatever you'd like! This tutorial will simply create a hello world editor showing the id of the item being edited.

Create a controller

First thing we'll do is create an angular controller for the editor, this controller will be contained in a file found beside the view - the file naming conventions are based on the controller file naming conventions in the Umbraco core.

/App_Plugins/MyPackage/BackOffice/MyTree/mypackage.mytree.edit.controller.js

The controller is super simple, at it is going to do is assign a property to the $scope which shows the current item id being edited:

'use strict';
(function () {
    //create the controller
    function myTreeEditController($scope, $routeParams) {
        //set a property on the scope equal to the current route id
        $scope.id = $routeParams.id;
    };
    //register the controller
    angular.module("umbraco").controller('MyPackage.MyTree.EditController', myTreeEditController);
})();

Create a view

As per the conventions above our editor view will need to be located at:

/App_Plugins/MyPackage/BackOffice/MyTree/edit.html

The view is simple, it is just going to show the current id being edited

<div ng-controller="MyPackage.MyTree.EditController">
    <h1>Hello world!</h1>
    <p>
        You are current editing an item with id {{id}}
    </p>
</div>

Create a Dialog

This is the same principle as an editor, you just need to follow conventions. Based on the above conventions the 'create' dialog view will be located here:

/App_Plugins/MyPackage/BackOffice/MyTree/create.html


HostForLIFE.eu Umbraco 7.2.8 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.

 



Joomla 3.4 Hosting France - HostForLIFE.eu :: How to Use SP Page Builder to to Build One Page Layout

clock August 18, 2015 07:09 by author Rebecca

In this tutorial, I will tell you how to build one page layout in Joomla using SP Page Builder. Many templates customized can be used as One Page layout, not only those which were created expressly for this purpose. In general what may be surprising for you don't even need any module position expect maybe top menu, all new positions you can create using only SP Page Builder and each Joomla subpage can use different layout. This Joomla! extension designed for you to help you create your own one subpage masterpiece with many modern trendy features in-build. One of them is an intelligent responsive design that changes it's display depending on the size of the screen your visitor is viewing your site with.

Step 1

First step is almost this same, you have to install SP Page Builder component (Basic or Pro version), you can go to http://www.joomshaper.com/page-builder/

Step 2

Inside PB component click "New" button to create a new page view. Input name, for example "onepage". Now for example you can install template layout called "Full Width Layout" which can show you how it works.

While building PB we kept in mind User Experience and customizability. As a result it is easy to navigate and to customize appearance of used elements.

Step 3

Each row has under "gear" icon settings also there you will find "Section ID" field - where you can set the ID attribute for the specific element. An ID should be unique within a page if you want use it later for OnePage purposes. Knowing this you can easily add new rows with selected addons and use unique ID name for each of them, for example: company-features, our-services, our-clients, address-map.

More generally, design requires making many choices, including colors, fonts, and images; we leave selecting these variables to future work.

Step 4

After it will allows you to use #company-features menu links in Menu Manager for your sub-menu module. Right now focus on adding different add-ons to your layout with real content if you have it.

Step 5

Save new page layout, and go to Menu Manager -> New Menu Item -> Menu Item Type -> SP Page Builder -> Page and choose your created before layout, in my case it was "one-page".

It means that under this menu item you will have page which you created in SP Page Builder few moments ago.

Step 6

Now using # before ID name you can add menu lub sub-menu links. Don't forget that they are only local links in single page view.

Remember, the component offers here only basic styles - so if you need more polished and beautiful final result you have to use your own css styles and class'es in rows. Happy designing!

HostForLIFE.eu Joomla 3.4 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.



Magento Hosting UK - HostForLIFE.eu :: 3 Ways to Create Promo Coupons Code in Magento

clock August 10, 2015 06:46 by author Rebecca

In this tutorial, I will show you how to create discount coupons code in Magento via 3 examples of different shopping cart rules that will help you set up rules for your own eCommerce store and let your customers take advantage of these great offers.

Step 1: Setup Free Shipping

To setup free shipping, you may follow these steps:

  1.     Log in to Magento Admin.
  2.     Click on Promotions –> Shopping Cart Price Rule.
  3.     Fill in the fields; be sure to give the rule a Name and Description and decide whether or not you are choosing ALL Customer groups or not.
  4.     In the General Information page in the coupon menu, select the Specific Coupon option.
  5.     Enter a code in the coupon code field (can be letters or numbers).
  6.     In the Uses Per Coupon field, specify the number of times a customer can use this coupon code if you would like to provide a limit. If not, leave blank.
  7.     In the Uses Per Customer field, specify the number of times a customer can use this promotion if you would like to provide a limit. If not, leave blank.
  8.     In the From/To Date menu, select a time frame for your coupon if you would like to provide one. If not, leave blank.

Make sure these conditions are met [none for this case]:

Make sure these actions are met:

And if you want something more specific, such as Free shipping on only a certain item, follow these actions:

Remember to click Save Rule to save all changes.

Step 2:  Create Buy 1, Get One for Free Coupon

Follow steps a-h from previous example first

Then ensure these Actions are met:

  •     Set the Discount amount to 1. This is the quantity that is discounted (the Y value, the quantity received for free).
  •     [Optional] If you want to set the number needed higher than 1, e.g., to 5, set the discount Qty Step (Buy X) to 5. This is the quantity the customer must purchase in order to qualify for the free item.
  •     [Optional] If you want to set it to a specific product SKU, you can enter these in the Conditions on the Actions tab.
  •     Click Save Rule to save all changes.

Step 3: Creating a Coupon Code for a Specific Product

There’re some cases that you just want to create coupon code for a specific product, it’s fine, you can do that:
Follow steps a-h from #1. Then, set the Conditions:

  1.     On left sidebar, click conditions tab.
  2.     Click the + button.
  3.     Select Product Attribute Combination.
  4.     Click + button.
  5.     Select SKU.
  6.     Now you will see the SKU.
  7.     Place your product SKU here.

Note: If you are not seeing SKU in the dropdown, go to: Catalog –> Attributes –> Manage Attributes. Search for SKU attribute and set the drop down “Use for Promo Rule Conditions” to “YES.”

Then, set the Actions:

  1.     Under Actions tab, choose how much you’d like to discount.
  2.     Click Save Rule to save all changes.

Well done! You are now successful to create coupons for your Magento store!

HostForLIFE.eu Magento Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.

 



European Drupal 7.37 Hosting - HostForLIFE.eu :: How to Manage Comments in Drupal

clock June 27, 2015 09:02 by author Rebecca

Comment is an important function that is included in almost every CMS and Drupal is not an exception. In Drupal, you can add more fields to comment sections, configure display, permission for comments of a content type. In tihs tutorial, I'm going to explain to you how to manage comments in Drupal 7.

Changing Comment Permission

Step 1

By default, anonymous user’s not allowed to comment. To enable comment for anonymous users, go to People > Permission tab as below:

Now, find Comment section, in Post comment select Anonymous user > Save.

Step 3

Next, use another browser to open node you created and view comment form. To configure comment form, go to Structure content type > article > comment field as follows:

Remove Subject of Comment

To remove subject of comment, set content type as follows:

Uncheck Allow comment title and save.

Add New Fields for Comment

To add new field for comment, at add new field section insert field label, select field type and widget:

Now, in front-end, you will see the fields you just added:

Now, you can try adding some new comments, you will see that comments need to be approved before showing on post. To manage submitted comments, go to Content > Comment > Unapproved comments:

Select the comments you wants, choose publish the selected comments to let them showed on frontend. “Delete selected comments” will remove the selected comments.

Change Comment Display

To change how comments are displayed, go to Structure > content type > article > comment display:

HostForLIFE.eu Drupal 7.37 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.



Drupal 7 with Free ASP.NET Hosting - HostForLIFE.eu :: How to Create Your Own Drupal 7 Theme

clock June 1, 2015 07:09 by author Rebecca

Like other CMS platforms, Drupal allows us to create custom themes and templates. In this tutorial, you’re going to learn how to create a new theme and defining or configuring a theme in Drupal 7.

Theme Structure

To define a new theme in Drupal 7, you need to create folders and files according to Drupal’s rule.

So, we start by create the following folders:

Go to root folder of Drupal > Sites > All > Theme and create theme folders as below:

  • mytheme is the folder that contains themes and can be renamed to your theme’s name.
  • mytheme.info is file used to define theme name, version, core ,css, javascript.
  • screenshot.png is thumbnail of theme, which is showed in theme management section.

Defining theme using .info file

The .info file is a static text file for defining and configuring a theme. Each line in the .info file is a key-value pair with the key on the left and the value on the right, with an “equals sign” between them (eg:   name = my_theme ).

Now, open mytheme.info and start defining:

Theme name (required):

name = mytheme

Description:

description = tutorialdrupal.com how to create and define drupal theme

Theme version

version = 0.1

Core drupal

core = 7.x

Engine

engine = phptemplate

Screenshot

screenshot = screenshot.png

After finishing, we will have a new .info  file like this:
name = mytheme
description = tutorialdrupal.com how to create and define drupal theme
version = 0.1
core = 7.x
engine = phptemplate
screenshot = screenshot.png

Now save the file, go to theme management section, you will see the new theme you’ve just created:

Defining Drupal website’s regions

Region is section for showing Drupal website’s blocks. Regions are defined as follows:

regions[header] = Header
regions[highlighted] = Highlighted
regions[help] = Help
regions[content] = Content
regions[sidebar_first] = Left sidebar
regions[sidebar_second] = Right sidebar
regions[footer] = Footer

After you’re done, save the file and click on “enable and set default” to set this theme as default theme. Now go to Structure -> Block, you will see the new defined regions:

1. Include css file

stylesheets[all][] = style.css
stylesheets[print][] = print.css

2. Include javascript file

scripts[] = myscript.js

So, you’ve just created a new theme in Drupal 7. It's not a difficult task, right?

Drupal CMS with Free ASP.NET Hosting
Try our Drupal CMS with Free ASP.NET Hosting today and your account will be setup soon! You can also take advantage of our Windows & ASP.NET Hosting support with Unlimited Domain, Unlimited Bandwidth, Unlimited Disk Space, etc. You will not be charged a cent for trying our service for the next 3 days. Once your trial period is complete, you decide whether you'd like to continue.



Magento with Free ASP.NET Hosting - HostForLIFE.eu :: How to Manage and Improve Top Links in Magento

clock May 13, 2015 07:15 by author Rebecca

Top Links navigation is one of the basic blocks in Magento. Top links block allows you to create a personal area for the customer within your online store. Top Links includes: Login/Logout, My Account, My Wishlist, My Cart and Checkout links. By default «Top links» are located in the header, but they can be moved wherever you want if it’s needed. In this tutorial, we will go through how to manage and improve Top Links in Magento.

One of the most important differences between top links and regular static links is that when you add products to the cart or to your wishlist, top links automatically records products which were added.

Example of Top links in the default  Magento theme in the header:

Usage of Top links in Magento

At first we have to call the block.
php echo this->getChildHtml(‘topLinks’) ?>

You may not create in template: template/page/html/header.phtml, but creates in page.xml
<block type=”page/html_header” name=”header” as=”header”>
<block type=”page/template_links” name=”top.links” as=”topLinks”/>
<block type=”core/text_list” name=”top.menu” as=”topMenu”/>
</ block>


Now we need to add links to this block by using the command:

<action method=”addLink” translate=”label title” >…</action>

We gotta make it in the following XML files:

  •     Login/Logout, My Account – customer.xml
  •     My Cart and Checkout – checkout.xml
  •     My Wishlist – wishlist.xml

It should be noted that link to  My Cart calls by the command:
<action method=”addCartLink”></action>
and
<action method=”addCheckoutLink”></action>

for Checkout link.

How to edit Top Links in Magento

All top links are based on a template which is located here: page/template/links.phtml. Here you can add additional classes or commit needed changes.

Often people want to use separate links. For example Login/Logout and My Account should be on the left side and My Wishlist, My Cart and Checkout on the right side.

Something like on the example below:

We can make this in a few simple steps as below:

Open page.xml and create another block there, almost identical to “topLinks” but with name  “topLinksLeft”;

<block type=”page/html_header” name=”header” as=”header”>
<block type=”page/switch” name=”store_language” as=”store_language” template=”page/switch/languages.phtml”/>
<block type=”core/text_list” name=”top.menu” as=”topMenu”/>
<block type=”page/template_links” name=”top.links” as=”topLinks”/>
topLinksLeft”/>
</ block>

In template template/page/html/header.phtml with help of the command:

php echo this->getChildHtml(‘topLinksLeft’) ?>

We can call our block in the proper place:

<div>
<h1 id=”logo” title=”<?php echo $this->getLogoAlt() ?>” style=”background-image:url(<?php echo $this->getLogoSrc() ?>);”><a href=”<?php echo $this->getUrl(”) ?>”><?php echo $this->getLogoAlt() ?></a></h1>
<div><?php echo $this->getChildHtml(‘topLinksLeft’) ?></div>
<?php echo $this->getChildHtml(‘topLinks’) ?>
<?php echo $this->getChildHtml(‘topMenu’) ?>
</div>

When you’ve done, open customer.xml  where we have to change the name of the block which is responsible for Login/Logout, My Account. We are changing its name from “top.links” on “top.links.left” as in example:

customer_logged_in>
<reference name=”top.links.left”>
<action method=”addLink” translate=”label title” module=”customer”><label>My Account</label><url helper=”customer/getAccountUrl”/><title>My Account</title><prepare/><urlParams/><position>10</position></action>
</reference>
<reference name=”top.links.left”>
<action method=”addLink” translate=”label title” module=”customer”><label>Log Out</label><url helper=”customer/getLogoutUrl”/><title>Log Out</title><prepare/><urlParams/><position>100</position></action>
</reference>
</customer_logged_in>

We also can assign other template to the links on the left ( rather useful in some cases) For that we just have to duplicate  template “page/template/links.phtml” and call it links_left.phtml. So now we have 2 templates “links.phtml” for the right side and “links_left.phtml” for the left side. Now all we need to do is just connect it. For connection we use block «topLinksLeft» page.xml and change it to links_left.phtml.

<block type=”page/html_header” name=”header” as=”header”>
<block type=”page/template_links” name=”top.links” as=”topLinks”/>
<block type=”page/template_links” name=”top.links.left” as=”topLinksLeft” template=”page/template/links_left.phtml” />
</ block>

Now you can apply different styles and HTML for the left and the right side.

Wow, almost forgot about “Register” button which is usually located near the “Login/Logout” button. No worries about that as well. As you can already guess we start from customer. xml file where we do next, if we want to add “Register” button to the top links:

<customer_logged_out>
<reference name=”top.links”>
<action method=”addLink” translate=”label title” module=”customer”> <label> Log In </ label> <url helper=”customer/getLoginUrl”/> <title> Log In </ title> <prepare /> <urlParams/> <position> 100 </ position> </ action>
<action method=”addLink” translate=”label title” module=”customer”> <label> register </ label> <url helper=”customer/getRegisterUrl”/><title>register</title><prepare/><urlParams/><position>10</position></action>
</ reference>
</ customer_logged_out>

Happy Coding! Hope it works for you.

Magento with Free ASP.NET Hosting
Try our Magento with Free ASP.NET Hosting today and your account will be setup soon! You can also take advantage of our Windows & ASP.NET Hosting support with Unlimited Domain, Unlimited Bandwidth, Unlimited Disk Space, etc.



Umbraco 7 with Free ASP.NET Hosting - HostForLIFE.eu :: How to Create Costum Sections in Umbraco

clock May 6, 2015 07:16 by author Rebecca

In this post, I will tell you how to create costum section in Umbraco 7. Every section in Umbraco is called an application, so sections and applications is basically the same thing.The first thing you’ll need to do is to create the application. In this examples I will not fiddle with the xml-files or the database. So, I’ll use class annotations to create my section.

The first step that you’ll need to do is to create a class that implements the IApplication-interface so that Umbraco will initialize this class on start up.

[Application("CustomSection", "CustomSection","icon-car", 15)]
public class CustomSectionApplication : IApplication {}


This is not something new for Version 7, The "Application"attribute basically tells Umbraco to create a new application:
Name: CustomSection
Alias: CustomSection

Icon: icon-car (the css class for the icon that will be displayed in the left side bar of the backoffice)
Sort order: 15

Next, Umbraco runs and will add an XML-element to the /config/applications.config-file that will add your new section/application to the Umbraco backoffice.

Creating The Tree

Umbraco will not care about your new application before creating the tree. An application without a tree is not worth anything. Let's start with creating a new class that inherits from Umbraco.Web.Trees.TreeController, make sure to suffix the class name with “Controller” ie. CustomSectionTreeController.

public class CustomSectionTreeController : TreeController
{
}

Now we need to give Umbraco some extra information about our tree. Let's add two attributes on the class, the Tree and the PluginController-attributes.
[PluginController("CustomSection")]
[Umbraco.Web.Trees.Tree("CustomSection", "CustomSectionTree", "My custom section", iconClosed: "icon-doc")]
public class CustomSectionTreeController : TreeController
{
}

PluginController
This attribute tells Umbraco that this class is part of a plugin, and it also tells Umbraco the name of that plugin. This will make Umbraco look for views inside the /app_plugin/{NameOfApplication}/-folder and not in the folder of the core-views which is the default.

Tree
This attribute is “older” and has been around since somewhere around 4.7 I think. It tells Umbraco that this is a tree-class and Umbraco will add this to the /config/trees.config-file. In V7 this attribute is mandatory for a tree that inherits from the TreeController-class as some underlying logic is looking at the attribute values to determine the name of the tree.

The properties are:
Application: CustomSection (must match the name of the application we added before)
Alias: CustomSectionTree (the name/alias of the tree)
Title: The title of the tree (used as the name of the root node)
Icon: The icon (or class) used as the tree icon.

Alright. Almost there. Now we need to add some code to show items in the tree.
[PluginController("CustomSection")]
[Umbraco.Web.Trees.Tree("CustomSection", "CustomSectionTree","My custom section", iconClosed: "icon-doc")]
public class CustomSectionTreeController : TreeController
{
    protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
    {
        var nodes = new TreeNodeCollection();
        var item = this.CreateTreeNode("dashboard", id, queryStrings, "My item", "icon-truck", true);
        nodes.Add(item);
        return nodes;
    }
 
    protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
    {
       var menu = new MenuItemCollection();
       menu.DefaultMenuAlias = ActionNew.Instance.Alias;
        menu.Items.Add<ActionNew>("Create");
        return menu;
    }

}

This will give us something like this:

This code has two methods that are the least we need to do to create a new section.

GetTreeNodes (TreeNodeCollection)
This returns a collection of tree items, in our case we just return one item but we could of curse add more items to the collection. We use the CreateTreeNode-method from the base class to create a new node called “My item” with the id “dashboard”. Umbraco will append the id of the node to the URL later on so that we can handle the routing from our AngularJS-controllers.

GetMenuForNode (MenuItemCollection)
This method handles the “right click alternatives”. The “DefaultMenuAlias” configures which action that should be fired when we click the “touch dots”.

There's a lot of actions that you can use and you can also build your own ones:

Displaying Your New Section

To display your new section you need to give the current user access to it. Go to the users-section and open the edit-view for the current logged on user. In the bottom, check the checkbox for [CustomSection] and hit save. Now you’ll probably need to refresh the page using F5 to show the new section in the left side bar.

Umbraco 7 with Free ASP.NET Hosting
Try our Umbraco 7.2.2 with Free ASP.NET Hosting today and your account will be setup soon! You can also take advantage of our Windows & ASP.NET Hosting support with Unlimited Domain, Unlimited Bandwidth, Unlimited Disk Space, etc.



Joomla 3.4 Hosting UK - HostForLIFE.eu :: How to Add Javascript Code to Articles and Custom HTML Modules in Joomla

clock April 29, 2015 07:54 by author Rebecca

By default, text editors in Joomla administrator interface work in visual (WYSIWYG) mode. WYSIWYG editors allow editing the HTML markup when you just need to publish some text and throw bolds and headers here and there, but when you try to publish a Javascript code through it, it will do its best to reformat it in the way that it shows up as a readable text, not as an actual working code. Moreover, there are security settings in Joomla that can prohibit using of Javascript codes within an HTML, in such cases the text editor just strips all <script> blocks.

Therefore, adding some custom Javascript in your article or custom HTML module, you might find out that it doesn't work in the front end or even disappears from HTML sources. Please follow these instructions in order to solve such problems:

Step 1: Set up general text filtering options for being able to use Javascript safely inside HTML source editor

  •     Open Content → Article Manager in your Joomla administrator panel and click on the 'Options' button in top right corner
  •     In the new popup window with Article Manager Options, open the 'Text Filters' tab and select 'No Filtering' under your user group (it is usually 'Super Users')
  •     Click 'Save'

Step 2: Configure your text editor so that it allows you to have <script> elements in your code

The text editor that you use in Joomla may set its own security settings, which can affect code formatting. By default, the 'TinyMCE' is used in Joomla administrator interface. Here is how to configure it properly:

  •     In your administrator panel, go to Extensions → Plug-in Manager, find the 'Editors - TinyMCE' line and click it
  •     In TinyMCE options on right, find 'Prohibited elements' section and remove a mention of 'script' from it
  •     Click 'Save'

There can be different filtering settings in different text editors plugins though. For example, if you are using JCE editor, you don't need to change any of its settings, it doesn't strip scripts by default. Please refer to the documentation of the plugin you use.

Step 3: Use the 'HTML' mode when pasting the javascript codes into HTML

No matter what editor you're using, when trying to insert a javascript code you need to switch the editor into the HTML mode first - look for HTML button or tab somewhere around the editor area. With that mode the codes that you enter into editor are to be treated as exactly the codes and should work. Joomla administrator interface sometimes also features a button reading 'Toggle editor' below the actual editor - you can switch from WYSIWYG into the code editor by hitting that button:

By using the above recomendations, you'll be able to make Javascript codes work inside your HTML sources in Joomla.

HostForLIFE.eu Joomla 3.4 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.



About HostForLIFE

HostForLIFE is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

We have offered the latest Windows 2019 Hosting, ASP.NET 5 Hosting, ASP.NET MVC 6 Hosting and SQL 2019 Hosting.


Tag cloud

Sign in