Archive

Posts Tagged ‘Open-source’

How Multiple Websites & Stores Work

October 15, 2013 Leave a comment

One of Magento’s advanced features allows for management of multiple websites and stores within one installation, and we have an amazing system to support this:  GWS – aka “Global, Website, Store.”

  • Global: This refers to the entire installation.
  • Website: Websites are ‘parents’ of stores.  A website consists of one or more stores. Websites can be set up to share customer data, or not to share any data
  • Store (or store view group): Stores are ‘children’ of websites.  Products and Categories are managed on the store level.  A root category is configured for each store view group, allowing multiple stores under the same website to have totally different catalog structures.
  • Store View: A store needs one or more store views to be browse-able in the front-end.  The catalog structure per store view will always be the same, it simply allows for multiple presentations of the data in the front.  90% of implementations will likely use store views to allow customers to switch between 2 or more languages.
  • multiple_websites_diagram
  • Example scenario

    Let’s say you want to sell appliances, consumer electronics, and DVD’s and CD’s.  For the purpose of this example we’ll separate the catalog into two stores and three websites.  The appliance line will be sold on its own website, and the remaining items on another website.  You bought appliances.com and coolstuff.com for this purpose.  You don’t want customer data and order data to be shared between the two websites, so data sharing will be turn off in the configuration between them.

    Under coolstuff.com you create two stores – Electronics, and Media.  Consumer electronics will be sold through the electronics store, and the media items through the Media store.  Since each line of items is very extensive, it makes sense to create a separate category structure for the Media store and the Electronics store… otherwise the category tree would be large and cumbersome.  When the stores are created, you simply assign a different root category to each store.

    In addition, you want to feature your catalog for both websites in English and Spanish.  To do this, you will create an English and Spanish store view for each of the three stores.  When entering catalog data you can switch store views in the admin to create the additional product titles, descriptions etc…

    Configuration

    The configuration of Magento uses GWS as a kind of tree when setting up the stores.  When it is initially installed, all configuration settings point to “default”, meaning the global installation.  A check box next to each configurable item can be un-checked in a particular website or store view, to indicate that this item will be specific to this website or store view.  For example, you will offer authorize.net as a payment module on both websites, but you only want to offer google checkout on coolstuff.com.  In the configuration, you’d select coolstuff.com in the store view drop-down, find the google API settings, and un-check “use default” in the google checkout tab.  For this specific website you can now enable or disable google checkout.

    All modules in the configuration function the same way.

    Moving on to store views – after a store view has been created, you can configure the layout and visual settings of the store view however you’d like – a drop-down allows customers to switch between store views.  This will reload the current page with the alternate view.  This can be used for multiple languages, but can also be a way to easily do A-B testing between several design packages to see if one yields more conversions.  The possibilities are endless!

    The above is meant as a basic overview of this functionality – the best way to learn how to set it all up is to install Magento and get in there and start playing around.

10 More Useful WordPress Code Snippets For Your Blog

July 6, 2012 1 comment

WordPress is the best open source sofware which is completely free to use.The advantage of being open source for a software is that developers can see its codes an write plugins to make it more functional.And also developers add or change small piece of codes especially in functions.php file to unleash the power of your favorite blogging engine.

In today’s post we are again sharing wordpress code snippets.I think you will find a useful wordpress code snippet for your wordpress blog.

You may also take a look at our past wordpress theme collections;

htaccess Gzip Compression

Add the following code in your .htaccess file.Gzip will drastically reduce HTTP response time.

# BEGIN GZIP

AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript

# END GZIP

Instructions:
Just add this to your .htaccess file. Gzip will drastically reduce HTTP response time.

How to Remove the Width and Height Attributes From WP Image Uploader

add_filter( ‘post_thumbnail_html’, ‘remove_width_attribute’, 10 );
add_filter( ‘image_send_to_editor’, ‘remove_width_attribute’, 10 );

function remove_width_attribute( $html ) {
$html = preg_replace( ‘/(width|height)=\”\d*\”\s/’, “”, $html );
return $html;
}

If you upload images via the WordPress image uploader and insert it into your post, it will include the image width and height attribute in the html tag. Here’s what it will look like.

In most cases, this is absolutely alright. However, if you are using a responsive theme or are dealing with responsive web design, the “width” and “height” attribute will be a major roadblock that you need to get rid of.

Here’s how you can do it.

1. Open your theme’s functions.php file.

2. Copy and paste the following code:
add_filter( ‘post_thumbnail_html’, ‘remove_width_attribute’, 10 );
add_filter( ‘image_send_to_editor’, ‘remove_width_attribute’, 10 );

function remove_width_attribute( $html ) {
$html = preg_replace( ‘/(width|height)=\”\d*\”\s/’, “”, $html );
return $html;
}

3. Save the changes.

That’s it. Next time when you insert image into the post via the WP image uploader, the width and height attribute will no longer be there.

How to Change the Font in HTML Editor In WordPress 3.3

add_action( ‘admin_head-post.php’, ‘wpdb_fix_html_editor_font’ );
add_action( ‘admin_head-post-new.php’, ‘wpdb_fix_html_editor_font’ );

function wpdb_fix_html_editor_font() { ?>

<!–?php }

Add/remove Contact Info Fields

To add or remove fields from this section, just add the following to your functions.php.

Login with Username or Email Address

Adding this snippet to the functions.php of your wordpress theme will let users login using an email address or a username. The second snippet will change the text on the login page from “username” to “username / email” but feel free to change the login text to anything you would like.

function login_with_email_address($username) {
$user = get_user_by(’email’,$username);
if(!empty($user->user_login))
$username = $user->user_login;
return $username;
}
add_action(‘wp_authenticate’,’login_with_email_address’);
function change_username_wps_text($text){
if(in_array($GLOBALS[‘pagenow’], array(‘wp-login.php’))){
if ($text == ‘Username’){$text = ‘Username / Email’;}
}
return $text;
}
add_filter( ‘gettext’, ‘change_username_wps_text’ );

Add PayPal Donate Button

Add this snippet to the functions.php to add ‘Donate’ Button on your WordPress Website

// paypal donate button
function cwc_donate_shortcode( $atts ) {
extract(shortcode_atts(array(
‘text’ => ‘Make a donation’,
‘account’ => ‘REPLACE ME’,
‘for’ => ”,
), $atts));
global $post;
if (!$for) $for = str_replace(” “,”+”,$post->post_title);
return ‘‘.$text.’‘;
}
add_shortcode(‘donate’, ‘cwc_donate_shortcode’);

Ringmark is Now Open Source

At Mobile World Congresswe announced Ringmark, a browser test suite for building apps on the mobile web. We’ve received overwhelming feedback and interest in helping us build Ringmark in order to make the mobile web better.

Today, we’re excited to announce that we are open sourcing Ringmark so that anyone can contribute tests.

Very soon, we will also contribute Ringmark tests to the Core Mobile Web Platform Community Group in the W3C. Our hope is that that Ringmark becomes the canonical test suite for the group, with tests for the specs the specs and feedback of the group baked into Ringmark itself.

You can view the code immediately by going to the GitHub repo at https://github.com/coremob/ and the tests athttps://github.com/facebook/coremob-tests. Start to contribute by joining the Group discussions around the specifications.

It’s important to note that this is just a starting point. We fully expect the rings to evolve as the group makes progress.

This is the beginning of a process, starting with open sourcing the tests. As we continue to build, we’ll continue to open source even more of this work.

Why we Built Ringmark

Before we dive into the details of Ringmark, we’d like to share some perspective on why this is important for us at Facebook – and more importantly to our developers.

Ultimately, we believe that web technologies are important to the future of mobile and that we can help to make HTML5 a well-supported platform for mobile developers to build upon. For those that are building with the web today, it’s a major hurdle to learn native technologies like Objective-C and Java: and we hope that an improved mobile web can unlock a large contingency of developers that could, and will, be developing for mobile.

At Facebook, we work with hundreds of mobile developers, including all of our Platform launch partners and we know the web remains a vital target for many of you.

We learned a lot from these discussions. Most importantly, we learned that the mobile web has great potential, but still needs a lot of work. One of the most frustrating problems was that of fragmentation in mobile browser capabilities and of understanding what’s possible on any given mobile browser.

Ringmark and the Core Mobile Web Platform Community Group are designed to address this problem head-on.

The W3C Community Group includes the perspectives of app developers, browser vendors, OEMs, and carriers — all of the necessary ingredients to help make the mobile web better and raise awareness of our challenges.

Ringmark is designed to be the canonical testing suite for those mobile web browser capabilities. It will help developers know, in a glimpse, whether their app can or cannot run on any given mobile browser. It will help mobile browser vendors build browsers that better serve developer needs and bring better apps and games to consumers.

For example, when a developer hears of a new device running a Ring 1 browser, they’ll immediately understand that 2D games, audio, video, and camera apps can be built on that device.

We believe that Ringmark and the ring methodology bring an empirical tangibility to what HTML5 means on mobile devices.

Keep Focused

The W3C Community Group will now be selecting, augmenting and prioritizing the tests received via Ringmark. As those decisions are made, Ringmark will evolve to reflect the latest recommendations of the Community Group. In the spirit of making progress quickly, this initial version of Ringmark reflects our best attempt at this prioritization.

The test suite is focused on enabling the mobile web to be a viable platform for mobile web apps. It’s also important to outline what this initial version of Ringmark is not focused on. Operating system utility functionality, telephony, and niche apps like flashlight apps or battery monitoring apps are examples which are currently out of scope.

Let’s Move the Mobile Web Forward

We want the mobile web to be a viable platform for app developers to build upon. So let’s move fast, keep our focus, and deliver on that mission.

Get involved by contributing to the GitHub Ringmark repository and by joining the W3C Community Group. Have you runRingmark in a mobile web browser? Spread the word about rng.io and post a photo to the Ringmark Facebook Page or tweet using the hashtag #ringmark.

Tomorrow, in a follow up post, we’ll be posting detailed information about the methodology and rings.

WANTED – URGENTLY 5 PHP DEVELOPERS

February 4, 2011 Leave a comment
The PHP logo displaying the Handel Gothic font.

SecureNext Software

We plan to recruit 5 PHP developers with 2-3 years  experience in our Chennai branch.  The candidate should have a minimum 1.5 years experience as a PHP developer. A quick learner and a team player is an added advantage. The referred candidate must commit to serve the company for at least 2 years. If you know anybody who is meeting all the above requirements and is looking for a change, please refer them and ask them to send their resumes to murugan@securenext.net. & raman@securenext.com.

We want to close this recruitment in a week’s time and hence would appreciate a quick response !.. If the candidate referred by you is selected, then, you will get the referral bonus per selected profile as per the company rules and guidelines.

Job Description:-

For PHP openings, We need the following skill set :.

 

Edu.Qlfn: BE ( CSE / IT / EEE), MCA, MS (CS)

 

1)  Should have minimum 1 year 6 month experience in PHP development

2)  Good & hands-on knowledge in PHP, MYSQL, Jquery and CSS
3)  A Fair knowledge in Joomla, wordpress and drupal will be an added advantage

 

We need the following details

Current CTC / Nett take home p.m.

Expected CTC / Nett take home p.m.

Referred By

Number of days required to Join

Reason for changing Job

Web Development at SecureNext Software Brings Single Platform for Comprehensive Web Solutions

April 20, 2010 1 comment

World-Wide Beginners & Proficient Online Businessmen can avail Comprehensive IT services and Hire Developers for different Web Development services and save up to 60% of Development cost.

Surfing web for appropriate IT services is common practice after the economic outsourcing trends adopted by the business companies. A large number of offline businesses from different industries are regularly coming on the web to globalize their business for the last many years. Web is the source of global exposure for business companies as well as source of IT services.

for economic web development. The search for appropriate and customized business website development has increased rapidly on the web. Securenext software is the professional web development company announces Comprehensive IT services & PHP Web Development with Hire Dedicated Developer Program. Securenext Company is well-organized with professionals like expert web developers, designers, and SEO professionals.

Securenext offer a series of IT services like Ecommerce Solutions, Open Source Customization, Software Development, Website Development, Application Migration, Rich Application Development, Website Designing and eMarketing / Internet Marketing. Company provides a single platform for short & medium sized companies as well as large companies and offers economic & customized web development services. Web developers & designers are proficient & talented to utilize various technologies, programming languages and web development tools.

“We are committed to provide high quality & customized web development services to novice and established businessmen, Company also provides “Hire dedicated web developers” proficient in different technologies and programming languages to meet specific requirements of clients. Clients can save up to 60% of development cost by hiring specific programmer. For providing robust web development services, company professionals use a wide range of core & latest IT technologies, frameworks, programming languages, databases and other web development tools.

To learn more about Securenext and its services, visit www.securenext.com/ for details.

About Securenext:
Securenext is a leading service provider of web development. The company specializes in complete web development solutions that meet business and web consumer needs. The company’s web development services have been used by millions of people in various countries.

Securenext Software – An Offshore Software & Web Development, PHP/ASP.Net/AJAX/RoR Programming, WordPress, joomla, Ecommerce Solutions and Rich Web 2.0 Application Development Company from India.
Securenext Software is a Offshore Software development, Application Development and PHP, ASP.Net, Web Application Development Company in India, offering IT outsourcing software development services. Expertise in PHP (hypertext preprocessor) and Microsoft .Net Framework and have expertise in XML, AJAX, Open Source, CakePHP, LAMP(Linux,Apache,Mysql,PHP), Ruby on Rails (RoR), ColdFusion, WordPress, joomla, community web portal development, Custom WordPress CMS theme design customization and integration services, Pligg E-commerce Etc…

Open Source and usability: Joomla vs. WordPress

September 5, 2009 1 comment

“If Joomla! is Linux, then WordPress is Mac OS X. WordPress might offer only 90% of the features of Joomla!, but in most cases WordPress is both easier to use and faster to get up and running.”

Over the course of the last few years, I’ve been in charge of putting up a number of websites for various companies, often as favors for friends. In most cases, I’ve ended up using one out of two solutions: Joomla! andWordPress. While both of these projects have evolved greatly over the last few years, they are vastly different. Joomla! has always been intended as a ‘fit-all-your-possible-needs’-kind of CMS solution, while WordPress was developed as a blog with CMS capabilities. Recently WordPress has opened up to allow its users to set up a site with static-only material (with the option of a blog-page), without having to hack the code. Hence it’s one step closer to being a direct competitor to Joomla!.

Joomla Control Panel

Joomla Control Panel

Wordpress DashBoard

Wordpress DashBoard

I will probably step on a few peoples feelings here, but I will argue that Joomla! is an example of a poorly managed open source project and that WordPress is a very successfully managed one. Certainly I don’t mean that Joomla! is a useless piece of junk, but that the lead developers have quite a bit to learn from WordPress. The main thing that Joomla! is vastly behind on is usability. While it is true that Joomla! 1.5 is a step in the right direction, it is still light years behind WordPress. Let me illustrate with two examples of common tasks.

Example 1: Create a blog-post with an image

Joomla!

From the ‘Control Panel,’ click ‘Add New Article.’

  1. There are two image buttons. If you use the wrong one, you won’t be able to upload an image (as you will only browse the existing images). You must use the one below the text field.
  2. Select a ‘Title,’ the right ‘Section’, and then the right ‘Category.’
  3. Write the content and save.

WordPress

  1. Select QuickPress in the Dashboard.
  2. Click on the image icon and upload the image.
  3. Select title, write your content and press publish.
'Add New Article' in Joomla!

'Add New Article' in Joomla!

'Add New Page in WordPress

'Add New Page in WordPress

Example 2: Create a static page accessible from the menu

Joomla!

  1. From the ‘Control Panel,’ click ‘Add New Article.’
  2. Select a ‘Title,’ the right ‘Section’, and then the right ‘Category.’
  3. Write the content and save it.
  4. From the top-menu, select ‘Menu’ and ‘Main Menu’ (assuming you want to add it to the main menu.)
  5. Click ‘New.’
  6. Select ‘Internal link,’ and ‘Articles,’ and then finally ‘Article Layout.’
  7. Fill in the title of the object as well as the parent item.
  8. In the column to the right, you now need to browse your list of articles and select the desired article.
  9. Press ‘Save.’

WordPress

  1. From the Dashboard, click ‘Pages.’
  2. Select ‘Add New.’
  3. Fill in the title and contents.
  4. Select the parent item (if other than root.)
  5. Click ‘Publish.’
'Add New Article'in Joomla!

'Add New Article'in Joomla!

'Add New Page' in WordPress

'Add New Page' in WordPress

Let’s step back for a minute and imagine the following scenario: you’re in charge of putting up a website for a company. They might want to put up about 10 or so pages with various information. According to my experience this is a pretty common situation. You can do this with either Joomla! or WordPress – both are fully capable of delivering this. Assuming you’re going to buy a template to solve the design issue, it will probably take you about an hour with either of the software to get to the first draft (assuming you’ve been working with them in the past.) So far so good. This is where they start to differ. With WordPress you’re pretty much done by now. However, with Joomla!, you’ll probably have to spend another hour or two just trying to re-organize the different modules to fit the template you bought (in many cases, just to get the basics to work.) Next you will end up spending even more time trying to figure out how to re-organize the different menus. You need to link up a particular document to a particular menu-entry (as illustrated above.) If you want a blog-feed, you need to set up a dedicated section or category (I still don’t really know the difference between the two.) Moreover, you need to select the ‘style’ of blog you want.

'New menu item' in Joomla!

'New menu item' in Joomla!

'Modules' in Joomla!

'Modules' in Joomla!

Let’s say you managed to figure all of that out and that you got the site ready. Now it’s time to hand over the site to the customer. There will obviously be some training involved, and here’s another crucial difference between Joomla! and WordPress. Training someone to learn WordPress takes (in my experience) less than 30 minutes, and they truly understand it. Training someone to use Joomla! takes at least an hour, and they still don’t really understand it.

Again, I’m not saying that Joomla! is useless, it’s that WordPress is a more intuitive piece of software. Let me throw an analogy out there that will probably help you better understand my point. If Joomla! is Linux, then WordPress is Mac OS X. WordPress might offer only 90% of the features of Joomla!, but in most cases WordPress is both easier to use and faster to get up and running. I use and love Linux, it just doesn’t have that elegant touch to Mac OS X does.

To Joomla!’s defense, there are at least two scenarios I can think of where Joomla! is a better fit than WordPress. The first one would be eCommerce. If you install VirtueMart on Joomla! you can be up running with an eCommerce site pretty quickly. However, the problem is that it does not feel like it is a part of Joomla!, but rather as a 3rd party module that works in Joomla! (which is pretty much what it is.) The second one would be a site where you need to have multiple levels of permissions (ie. an extranet). WordPress only offers three levels of permission (public, private, and password protected), while Joomla! is much more flexible.

'Global Configuration'in Joomla!

'Global Configuration'in Joomla!

'General Settings' in WordPress

'General Settings' in WordPress

Joomla! is not doomed. It just has a long way to go when it comes to usability. WordPress has really been developed by the KISS-principle, while Joomla! appears to have been developed to solve every problem on Earth (by engineers, for engineers). Going back to the two problems I mentioned above, where Joomla! beats WordPress. I think it would actually be less of a challenge to add support for eCommerce and more permission levels to WordPress, than it would be to improve the usability in Joomla! to reach WordPress’ level.

Just as a side note, a quick line-count on the latest versions of both software reveals that Joomla 1.5.9 has 350,975 lines of codes, while WordPress 2.7.1 has a mere 159,682 (might not be completely accurate, but that’s what ‘wc -l’ said). Hence, even if WordPress only offers 70% of the features of Joomla!, which I am pretty sure it does, their code is written much more efficiently.

Geo Proximity Search with PHP, Python and SQL

February 10, 2009 Leave a comment

Federico takes a look at finding geo-proximity to a find a location on a map and plot it and find the distance to another point – all with the help of PHP, Python and SQL.

Basically, what I’m doing is plotting a radius around a point on a map, which is defined by the distance between two points on the map given their latitudes and longitudes. To achieve this I’m using the Haversine formula (spherical trigonometry). This equation is important in navigation, it gives great-circle distances between two points on a sphere from their longitudes and latitudes.

Included in the post is the code for three different implementations – PHP, Python and SQL, all using that same formula. I’m working on a project that requires Geo proximity search. Basically, what I’m doing is plotting a radius around a point on a map, which is defined by the distance between two points on the map given their latitudes and longitudes. To achieve this I’m using the Haversine formula (spherical trigonometry). This equation is important in navigation, it gives great-circle distances between two points on a sphere from their longitudes and latitudes. You can see it in action here:

This has already been covered in some PHP blogs, however, I found most of the information to be inaccurate and, in some cases, incorrect.

Of course, there are always exceptions.In this post, Kevin uses the Haversine equation to develop a postcode radius facility for his website, like the one on freemaptools.com.

He assumes you have the following values:

$lon = (float) -2.708077;
$lat = (float) 53.754842;
$radius = 20; // in miles

And calculates the latitude (min/max) and longitude (min/max) based on that:

(float)$dpmLAT = 1 / 69.1703234283616;

// Latitude calculation
(float)$usrRLAT = $dpmLAT * $radius;
(float)$latMIN = $lat – $usrRLAT;
(float)$latMAX = $lat + $usrRLAT;

// Longitude calculation
(float)$mpdLON = 69.1703234283616 * cos($userLat * (pi/180));

// degrees per mile longintude
(float)$dpmLON = 1 / $mpdLON;
$usrRLON = $dpmLON * $radius;
$lonMIN = $lon – $usrRLON;
$lonMAX = $lon + $usrRLON;

The variable names are a bit confusing, but you can tell straight away he knows what he’s doing. Unfortunately, the script doesn’t work, $userLat is not defined. If you change $userLat to $lat, it works. Also, you can use the deg2rad() function to convert the $lat number to the radian equivalent.

Here is Kevin’s implementation refactored

// Degrees per mile latitude
$dpm_lat = (float) 1 / 69;

// Latitude calculation
$rlat = (float) $dpm_lat * $radius;
$lat_min = (float) $latitude – $rlat;
$lat_max = (float) $latitude + $rlat;

// Longitude calculation
$mpd_lng = (float) abs(cos(deg2rad($latitude)) * 69);
$dpm_lng = (float) 1 / $mpd_lng;

$rlng = $dpm_lng * $radius;
$lng_min = $longitude – $rlng;
$lng_max = $longitude + $rlng;

echo ‘lng (min/max): ‘ . $lng_min . ‘/’ . $lng_max;
echo ‘lat (min/max): ‘ . $lat_min . ‘/’ . $lat_max;

Outputs:

lng (min/max): -3.1983251898421/-2.2178288101579
lat (min/max): 53.464986927536/54.044697072464

Cool, it works. Now, for the sake of James Inman, lets refactor the script again and simplify the hole thing. The Haversine equation is very straight forward, so there’s no need to complicate things.

I’ve implemented the solution in PHP, Python and SQL. Use the one that suits you best.

$longitude = (float) -2.708077;
$latitude = (float) 53.754842;
$radius = 20; // in miles

$lng_min = $longitude – $radius / abs(cos(deg2rad($latitude)) * 69);
$lng_max = $longitude + $radius / abs(cos(deg2rad($latitude)) * 69);
$lat_min = $latitude – ($radius / 69);
$lat_max = $latitude + ($radius / 69);

echo ‘lng (min/max): ‘ . $lng_min . ‘/’ . $lng_max . PHP_EOL;
echo ‘lat (min/max): ‘ . $lat_min . ‘/’ . $lat_max;

It outputs the same result:

lng (min/max): -3.1983251898421/-2.2178288101579
lat (min/max): 53.464986927536/54.044697072464

SQL implementation

set @latitude=53.754842;
set @longitude=-2.708077;
set @radius=20;

set @lng_min = @longitude – @radius/abs(cos(radians(@latitude))*69);
set @lng_max = @longitude + @radius/abs(cos(radians(@latitude))*69);
set @lat_min = @latitude – (@radius/69);
set @lat_max = @latitude + (@radius/69);

SELECT * FROM postcode
WHERE (longitude BETWEEN @lng_min AND @lng_max)
AND (latitude BETWEEN @lat_min and @lat_max);

Python implementation

from __future__ import division
import math

longitude = float(-2.708077)
latitude = float(53.754842)
radius = 20

lng_min = longitude – radius / abs(math.cos(math.radians(latitude)) * 69)
lng_max = longitude + radius / abs(math.cos(math.radians(latitude)) * 69)
lat_min = latitude – (radius / 69)
lat_max = latitude + (radius / 69)

print ‘lng (min/max): %f %f’ % (lng_min, lng_max)
print ‘lat (min/max): %f %f’ % (lat_min, lat_max)

That’s it. Happy Geolocating!