Calcetines Extreme

Calcetines Extreme
Take care of you using the best socks

Monday, December 8, 2014

Change banner rotation each day

Problem:   
Our customer need to change the banner exposition to a different one each day, we only have 2 banner options soo, we only need to show a different banner each day.

 Solution:    

To do that, i think on read the day of current date, divide by 2 it and get the rest part of the division. If the rest part is nan then show banner A, else show banner B.

Steps:
' Reading current date
$date = date("ymd");

' Get current day number
$day_number = date('n', strtotime($date));

' divide it by 2
$res = substr($date, 4, 2) %2 ;

' final condition
if ($res==0){ 'show banner a }else{ 'show banner b }

Monday, September 22, 2014

Add own #php code in #magento cms

Problem:   
You are working in a magento Site, and you need to add a own php page with a custom code to make something different that magento do. For example, to add an own file download manager.

 Solution:    

Magento don't allow to use warpeed as jomla do in a ease way, magento could be more powerfull thant other cms, but it required more development skill than cms like joomla, drupal, etc...
To add you php file in magento follow that steps:
1.- Open template path hints to see where you need to put your php file.
2.- we will put it on: frontend/base/default/template/contacts and upload your file.
3.-  Our file will be named: customerfilemanager.phtml (take care on phtml extension), you can use php code inside as well as on php one.
4.-  Create a new Magento CMS page and add that line:
{{ block type="core/template" name="contact" form_action="/contacts/index/post" template="contacts/customerfilemanager.phtml" }}
5.- that's all, now develop your php code in customerfilemanager.phtml and your visitor will see it on magento CMS page.
Source:   http://sarathlal.com/add-custom-php-code-in-magento-cms-page/ 
  
 

Monday, June 9, 2014

plex - can't change file permisions

Problem:   

You are working trough ftp client and you can change the file permission from specific file due to a user file creation owner. its usually to see that the file owner/group is different.

Solution:    

Access to Plex server trough SSH client and change the file permission using chmod command.

how to access httpdocs when you are logged in the server trough SSH ?

on the first ls -la you will see something like that:

  • master
  • parallels
  • parallels_installer
  • plex-installer

to open httpdocs folder you have to open:   /var/www/vhosts from the home folder

source:
http://support.hostgator.com/articles/plesk/plesk-administration/using-ssh-in-plesk

Tuesday, April 29, 2014

#magento change Magento Store base URL

Problem
You need to move your magento site from one hosting to a new one with a diferent domain / url.

Solution
You can use that method to change the store base url, you can do it from the backoffice but oviously if you move the site you will not be able to acces magento backoffice so you need to use mysql method trough that tutorial:



Sunday, March 23, 2014

#magento How to detect language from php code

Problem:
Yo need to change some content at low level in a phtml file on a multi language site using Magento, when you use multilingual you have to create content in a each language that you need, so, how you can call content choosing the correct language ?

Solution:
That's simple process using a sentence to read the loaded language on the site using the next sentence:

Mage::app()->getLocale()->getLocaleCode();

That sentence return that string for Spanish one:   en_EN

To load a Static Block you only need to use something like that:
$locale = Mage::app()->getLocale()->getLocaleCode();
$locale = substr($locale, 0, 2);
switch ($locale) {
case "es":
  echo $this->getLayout()->createBlock('cms/block')->setBlockId(CopyRight)->toHtml();
  break;
case "en":
  echo $this->getLayout()->createBlock('cms/block')->setBlockId(CopyRight_en)->toHtml();

  break;
...

Sunday, January 12, 2014

#magento | Call Statics Bllock in a .phtml file

Problem:
You would like to add a Static Block, that you can define inside "CMS" -> "Static Block" on another page or section that are not included in your template. 

Solution:
There are various ways to call your static blocks to your Magento fronted but that is one of the best ways to add it in the .phtml and xml files. just follow the nest steps:

1.- Create a CMS Static Block at "CMS"->"Statick Block"->"Add new block"

2.- Add the next sentence inside -phtml
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId(cms_test_block)->toHtml() ?>

for example, if you need to add some Statick block inside the Copyright, you have to edit the next .phtml like this:

Path:
/httpdocs/p/app/design/frontend/base/default/template/page/html

Edit:
<div class="footer-container">
    <div class="footer">
        <?php echo $this->getChildHtml() ?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId(CopyRight)->toHtml() ?>
    </div>
</div>


Sunday, January 5, 2014

#magento - System Configuration -> Save Config Button dosen't work

Problem:
You found that on Magento Backoffice, the "Save Config" button´dose't work and you can't save any modification that you do on each group on magento configuration. If you use browser inspector you can see that there is some errors on inspector console, like "Uncaught SyntaxError: Unexpected token ILLEGAL", and when you try to click on the button you can see a lot of prototype.js error messages.

Solution:
That is because prototype.js used by Magento core is not friendly with jquery library, to solve that you have to add a title modification on your jquery library as indicated on the next steps:

Path:  /httpdocs/p/skin/frontend/base/default/rokmage-main-js/
File:    jquery.min.js

Open that file and add that statement at the end:   "jQuery.noConflict();"
You will have that file like that:
-----------------------
/*! jQuery v1.8.3 jquery.com | jquery.org/license */
(function(e,t){function _(e){var t=M[e]={};return v.each(e.split(y),function(e,n){t[n]=!0}),t}function H(e,n,r){if(r===t&&e.nodeType===1){var i="data-"+n.replace(P,"-
...
define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return v})})(window);jQuery.noConflict();
-----------------------

Sources: