December 13, 2015

Magento - How to add static page link to main menu?

- Hello friends finally I find the solution for add static page link to main menu in magento CMS,

- First find the top.phtml file from this page: app/design/frontend/default/YourThemeName/template/catalog/navigation/top.phtml

- Before do any changes on this file please take copy of orignal top.phtml file,

- Below is default code of top.phtml file:


<?php $_menu = $this->renderCategoriesMenuHtml(0,'level-top') ?>
<?php if($_menu): ?>
<div class="nav-container">
    <ul id="nav">
       <?php echo $_menu ?>
    </ul>
</div>
<?php endif ?>

- You shoud modified as per below example where I add Home link:

<?php $_menu = $this->renderCategoriesMenuHtml(0,'level-top') ?>
<?php if($_menu): ?>
<div class="nav-container">
    <ul id="nav">
     <li><a href="/">Home</a><li>
     <?php echo $_menu ?>
    </ul>
</div>
<?php endif ?>

- Or you should also add and magento block shord code (In block you define static menu link in <ul><li> format):

<?php $_menu = $this->renderCategoriesMenuHtml(0,'level-top') ?>
<?php if($_menu): ?>
<div class="nav-container">
    <ul id="nav">
     <li><a href="/">Home</a><li>
     <?php echo $_menu ?>
     <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('navbar_links')->toHtml() ?>  
   </ul>
</div>
<?php endif ?>

- In above example 'navbar_links' is block identifier name.


Enjoy!

December 11, 2015

Ajax concat FormData form + parameters


For Ajax FormData add extra parameters to pass data in PHP file,

See below example for that,

var fd = new FormData(document.getElementById("form"));
fd.append("CustomField", "This is some extra data");
$.ajax({
  url: "stash.php",
  type: "POST",
  data: fd,
  processData: false,  // tell jQuery not to process the data
  contentType: false   // tell jQuery not to set contentType
});

Enjoy!

Multiple ckeditor used on one page with AngularJS.



Yes, its possible to used multiple ckeditor on one page with AngularJs, please see below example OR see here

app.directive('ckEditor', [function () {
    return {
        require: '?ngModel',
        link: function ($scope, elm, attr, ngModel) {

            var ck = CKEDITOR.replace(elm[0]);

            ck.on('pasteState', function () {
                $scope.$apply(function () {
                    ngModel.$setViewValue(ck.getData());
                });
            });

            ngModel.$render = function (value) {
                ck.setData(ngModel.$modelValue);
            };
        }
    };
}])

Enjoy!

November 24, 2015

jQuery validation for price field.

Please follow example for set jquery validation for price field.

HTML
<input id="price" maxlength="7" type="text" />

Javascript
$("#price").on("keyup", function(){
    var valid = /^\d{0,4}(\.\d{0,2})?$/.test(this.value),
        val = this.value;
   
    if(!valid){
        console.log("Invalid input!");
        this.value = val.substring(0, val.length - 1);
    }
});

Enjoy!

OpenCart how to add new menu?



Follow the below step:

Log into your OpenCart administration panel like: domainname.com/admin.

Navigate to Catalog -> Information.

Click the Insert button to add a new content page.

And you can enter page name, description and all others fields.


Select the Data tab. Here you can define page keywords, set Sort Order...etc

Save it.

You need to edit the code of the header.tpl

The file is located in the /catalog/view/theme/yourtheme/template/common/header.tpl folder.

Enjoy!

The Future of Technology: Emerging Trends to Watch in 2025

Introduction As we navigate through 2025, the technological landscape continues to evolve at an unprecedented pace. Innovations that once se...