ZenCart – New Products Sort Order Descending Latest

Standard

To set the descending order in zencart for new products showing latest products on the top, in descending order, here is the code you have to change, to set your latest products to display on top as New Products.

New Products Sort Order Descending

To show latest products in descending order in zencart, please open up the new_products.php file, existing in the following path:

includes/modules/new_products.php

or if you are using a zencart theme, then it should be appearing in your theme path as:

includes/modules/your_theme_folder/new_products.php

After opening the new_products.php file, add the following line of code:

$new_products_query .= ” ORDER BY products_date_added DESC
LIMIT ” . MAX_DISPLAY_NEW_PRODUCTS;

right before the following line:

if ($new_products_query != ”) $new_products = $db->ExecuteRandomMulti($new_products_query, MAX_DISPLAY_NEW_PRODUCTS);

Once you’re done, save the file and check out your new products, displaying in the homepage. Now you will be able to display your latest products in descending sort order in your homepage.

If you have any comments, or you have any other solution, please post your comment and let us know.

Mysql – Auto Increment Custom Start Value

Standard

If you want to have an auto increment field in your MySQL table, and you want the custom starting value as an auto increment, for example, you want your auto increment value to start from 500 or 1000, instead of the default value i.e. 1, then here you go.

Auto Increment Custom Value

If you have a table, say student, and you want your auto increment value to start from value 500, then here is the alter query:

ALTER TABLE student AUTO_INCREMENT=500;

Hope this will help you in start your custom value for auto increment.

PHP – Replace Multiple Characters

Standard

To replace multiple characters in PHP, here is a simple solution:

Replace Multiple Characters PHP

If you want to replace more than once characters in a string or an array, like you have an array of phone number or address, where you want to remove more than one values from that array, for example, dashes ( – ) and slashes (/), then you can use the still use the str_replace function, where the first parameter will be an array for removing of the defined characters, with the second argument as array, from where you want to remove those characters. Here is an example

<?php
$arr = array(“M/U/L/T/I/P/L/E”, “Charac-ters RE-PLACE/D”);

$arr_remove = array(“-“,”/”);

$new_arr = str_replace($arr_remove, “”, $arr);

print_r($new_arr);
?>

The $new_arr array will now look like below:

Array

(

[0] => MULTIPLE

[1] => Characters REPLACED

)

Remove Duplicate Values – OpenOffice.org Spreadsheet Calc

Standard

If you have like huge amount of data, like non unique ids, phone numbers or any other type of data like name etc., in Openoffice columns, and you want to remove duplicate values from that column, then here is an easy solution:

OpenOffice – Remove Duplicate Values

  • Select the whole column, or the cells containing data, from top to bottom or bottom to top.
  • Goto Data -> Filter -> Standard Filter
  • There you have to choose none in Field Name drop down. Plese note that by default, you may be seeing the Field Name as Column A or any other column name, where your data is stored, please change it to none.
  • Now click on the More Options button below, and you will see some extra options below.
  • Check the No duplication and click OK button

Now the duplicate columns are hidden, and you will only be viewing the non duplicate values. Please note that, duplicate values still exist in the hidden rows, so if you dont want them in the sheet, then simply copy the column again, and paste it in some other sheet or the next blank column, and paste the selected copied column in that new column, to remove the hidden fields completely.

Hope this solution will help you removing redundant / duplicate values in Openoffice.org Spreadsheet / Calc.

FATAL ERROR: register_globals is disabled in php.ini, please enable it Ubuntu

Standard

Are you facing the following error in Linux /Ubuntu:

FATAL ERROR: register_globals is disabled in php.ini, please enable it

If this is the case then here is a problem solution:

Solution – register_globals is disabled in php.ini

While installing zencart in Ubuntu, I got the error of register_globals is disabled in php.ini, so here is a simple solution:

  • Open up the Terminal: Applications -> Accessories -> Terminal
  • Now open the file php.ini in any editor, existing in your php’s apache folder, in my case its php5:
    sudo gedit /etc/php5/apache2/php.ini
    or
    gedit /etc/php5/apache2/php.ini
  • Find the text in the php.ini file as register_globals, where you will find the text as:
    register_globals = Off
    and change this line to
    register_globals = On

Now save and close the file, and restart apache server. In my case, it is:

sudo /etc/init.d/apache2 restart

All done.

Now you will be able to get rid of this error and enjoy coding.

If you have any suggestion, or can advise something better than the solution above, please share.

PHP Error Reporting Code

Standard

To display PHP error reporting within the code, following post may be helpful.

Enable PHP Display Error

To enable errors, usually errors and warnings, simply add following lines of code in your file, within PHP tags:

error_reporting(E_ALL ^ E_NOTICE);
ini_set('display_errors','On');

Please note that the above code displays errors and warnings, and not the notices.

To display all the errors in the file, remove the E_NOTICE as below:

error_reporting(E_ALL);
ini_set('display_errors','On');

If you are still unable to see the PHP errors, following post may be helpful:

PHP Errors Display ON and OFF for Windows and Linux (Ubuntu)

Ubuntu – Incompatible License

Standard

After installation of Ubuntu’s latest release, following error starts appearing in the startup:

Incompatible License

How To Resolve – Incompatible License

To resolve this issue, all you need to do is, to open your Ubuntu, through Live CD, and reinstall Grub2.
For more details on how to install Grub2 through Live CD, check out the following post:

Install Grub2 From Live CD

Ubuntu 10.10 – Your Ubuntu Release Is Not supported Anymore

Standard

Are you receiving the message of Ubuntu not supported anymore.

Your Ubuntu Release Is Not supported Anymore

While using Ubuntu 10.10, following message appears while you want to update your Ubuntu 10.10 OS:

Your Ubuntu release is not supported anymore

You will not get any further security fixes or critical updates. Please Upgrade to a later version of Ubuntu Linux.

If this is the case, then it is advisable to move on to the latest version of Ubuntu, (currently 11.10 LTS), though its a great experience of using Ubuntu 10.10 for a long time period, but as it is no more supported, there might be cases where upgrades will be necessary for the software we’re using.

Long live UBUNTU!

Google Plus Facebook Like Twitter Tweet Buttons Code

Standard

Finding out some wordpress plugins of Google Plus, Facebook Like and Twitter’s Tweet buttons, some performance and other issues were faced, due to which I thought to find out direct code & scripts of all, and make them self embedded in the theme. If you looking for how to add buttons for Google Plus, Facebook Like and Twitter Tweet in a blog or website, there here are the simple >scripts / code you can add in your site:

Google Plus Button Code

Following is the script, and the div, which you can add anywhere in your code, for adding the Google Plus button in your website. Preferable is to add the script in the header tag, and then the div, where you want the Google Plus button to be shown, but you can also use the script and div together, like below:

<script type=”text/javascript” src=”https://apis.google.com/js/plusone.js”></script>
<div class=”g-plusone”></div>

 

Twitter Tweet Button Code

Following is the script, which you can add anywhere in your code, for adding the Twitter Tweet button in your website:

<a href=”https://twitter.com/share” class=”twitter-share-button”>Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=”//platform.twitter.com/widgets.js”;fjs.parentNode.insertBefore(js,fjs);}}(document,”script”,”twitter-wjs”);</script>

 

Facebook Like Button Code

Following is the script, which you can add anywhere in your code, for adding the Facebook Like button in your website:

<script src=”http://connect.facebook.net/en_US/all.js#xfbml=1″></script>
<script type=”text/javascript”>
document.write(‘<fb:like layout=”button_count” show_faces=”false” width=”100″></fb:like>’);
</script>

 

If you have any other easy solution for any of all of these mentioned above, please share or comment.