Categories
Programming

Sublime text custom layout tutorial : inside out with examples

SublimeText3 editor is something that I am using on daily basis. I must say that is one of fastest editor that I have ever used. One way if you want to be more productiv is to setup custom layout in diffrent develepment mode (coding, reviewing code, debuging etc).

If you open console and type window.get_layout() you will get something like this :


{
    'cols': [0.0,0.5,1.0],
    'rows': [0.0,0.5,1.0],
    'cells': [
        [0,0,1,1],
        [1,0,2,1],
        [0,1,1,2],
        [1,1,2,2]
    ]
}

So what does it means? How is mapped your layout? It is pretty simple. Lets start 🙂

Categories
Programming

WordPress – add_help_tab – add context help to custom admin plugin page

How to add context help to custom admin plugin page? Some time ago I had to put help content to custom admin plugin page for my project.

context_help

There are pretty good examples at wordpress.org . Here is one of those examples :

<?php 
add_action('admin_menu', 'my_admin_add_page');

function my_admin_add_page() {
    $my_admin_page = add_options_page(__('My Admin Page', 'map'), __('My Admin Page', 'map'), 'manage_options', 'map', 'my_admin_page');

    // Adds my_help_tab when my_admin_page loads
    add_action('load-'.$my_admin_page, 'my_admin_add_help_tab');
}

function my_admin_add_help_tab () {
    $screen = get_current_screen();

    // Add my_help_tab if current screen is My Admin Page
    $screen->add_help_tab( array(
        'id'	=> 'my_help_tab',
        'title'	=> __('My Help Tab'),
        'content'	=> '<p>' . __( 'Descriptive content that will show in My Help Tab-body goes here.' ) . '</p>',
    ) );
}
?>

This is working fine if you want to add context help to your custom option page within settings menu or to your custom post type. But if you have empty admin page then probably will nothing happened like in my case. Why is that?

Categories
Programming

How to add custom filed to customers table in OpenCart – Admin panel

How to add custom filed to customers table in OpenCart?

OpenCart has many flaws, at least in version <2. Unlike WordPress for example there is no easy way to change core functionality with custom plugin without changing the source code. There is no pub/sub architecture for interrupting system events…

But if you need to add custom fields to custumer, here is code simple example for that in five simple steps.

Step 1

Add form html in admin panel :


// admin/view/template/sale/customer_form.tpl
// find <input name="firstname" type="text" value="<?php echo $firstname; ?>" />
// and add before :
<input name="#field_name#" type="text" value="<?php echo #field_name#; ?>" />
Categories
Programming

Testing web app or site automatically on different screen resolutions

There is time when you need to perform testing web app or site automatically on different screen resolutions. Today there are many online solutions that provide easy way of testing you site on different resolutions. It’s simple done using iframe with custom dimensions. But what if you need to test your site on couple of hundred different resolutions 🙂 ?

There is no better way to do that than using a automated test. Framework of choice for that is Selenium . It have numerous combination of programming language for creating tests with Selenium and web drivers.

Categories
Programming

Symfony2 : header won’t change in download controller

Sooner or late you have to add file download option to your symfony2 project. As many times before I have been created controller just for that. But something went wrong, file was interpreted as text by browser instead as file for download.

Categories
Programming

PHP : __FILE__ problem with symbolics links and file path

Some time ago I have organized my wordpress plugins via symbolic links. It’s helped me to keep all plugins inside one repository dir and eases me to deploy plugins in different test wordpress locations on my WAMP server. Example of that organization :


d:\plugins\plugin1 // real loaction
d:\plugins\plugin2 // real location
...
d:\www\wordpress\wp-content\plugins\plugin1 // symbolic link
d:\www\wordpress\wp-content\plugins\plugin2 // symbolic link
...