Calcetines Extreme

Calcetines Extreme
Take care of you using the best socks

Thursday, October 17, 2013

[magento] Remove title from one cms page

Problem:
We need to remove the title that is above the cms content for a specific page, and not for the rest.

Solution:
Go to yout CMS page in backoffice and on "design" -> "custom design" -> "Custom Layout Update XML"
add the folowing code:

<remove name="page_content_heading"/>

Monday, October 7, 2013

How to activate "Maintenance Mode" in #Magento

Problem:

You need to hide or block the access to your Magento web site, but that block need to be conditional for only some IP address.

Solution:

Since the version 1.4 is possible to activate a Maintenance Mode just creating a file called maintenance.flag in your root directory but that is not really useful at all.

You need a workaround, to allow the access to some IP adress:
1. Open index.php in the root .
2. Look for that line:
    if (file_exists($maintenanceFile)) {
3. Replace it with that one:
    if (file_exists($maintenanceFile) && !in_array($ip, $allowed)) {
4. Paste next code just above the line before:
    $ip = $_SERVER['REMOTE_ADDR'];
    $allowed = array('0.0.0.0','9.9.9.9');
5. In the $allowed array you have to included the IP allowed to access to your website.

Tuesday, September 24, 2013

Remove “ Help Us to Keep Magento Healthy “ from the footer ?

Problem:
On the default template after magento installation you can see a dammed text like this "Help Us to Keep Magento Healthy – Report All Bugs (...", and you can't find the custom option to remove it from configuration and disable or delete that copyright magento default text.

Solution:

First: remove copyright
- Goto Admin > System > Configuration
- Under Configuration > Design

- Expand the Footer & Changes Copy Right Info

Second: remove help us
- Open file "footer.phtml" fronm path "\app\design\frontend\base\default\template\page\html\footer.phtml"

- Then remove copy rights from source code

<div class="footer-container">
    <div class="footer">
        <?php echo $this->getChildHtml() ?>
        <p class="bugs"><?php echo $this->__('Help Us to Keep Magento Healthy') ?> - <a href="http://www.magentocommerce.com/bug-tracking" onclick="this.target='_blank'"><strong><?php echo $this->__('Report All Bugs') ?></strong></a> <?php echo $this->__('(ver. %s)', Mage::getVersion()) ?></p>
        <address><?php echo $this->getCopyright() ?></address>
    </div>

</div>

And refresh Cache Storage Management

Sunday, July 14, 2013

Create an Alphabetical Index on Prestashop CustomCode

Problem:
We need to add a filter in a prestashop view (.tpl file), to allow visitors to filter displayed data; i found that solution while trying to update "manufacturer" view as a customer need.

Solution:
Without buy any module we can get that functionality with a little and easy custom php code only updating 2 files:
/themes/<template>/manufacturer-list.tpl
/controllers/front/ManufacturerController.php

Lets go to see the process:
1.- Create filter criteria.
Open manufacturer-list.tpl and add HTML code for display the filter options, like that:
      A-B-C-D-E-F....
      each letter need to load the view layout adding a filter parameter, like that
      http://yoursite/index.php?controller=manufacturer&filter=M

2.- Filter Prestashop Controller Data displayed in layout
Open Controller and add that piece of code in "assignAll() function":

SearchString:
...
...
protected function assignAll()
{
if (Configuration::get('PS_DISPLAY_SUPPLIERS'))
{
$data = Manufacturer::getManufacturers(true, $this->context->language->id, true, false, false, false);
$nbProducts = count($data);
$this->pagination($nbProducts);
>>>>> HERE <<<<
foreach ($data as &$item)
$item['image'] = (!file_exists(_PS_MANU_IMG_DIR_.'/'.$item['id_manufacturer'].'-'.ImageType::getFormatedName('medium').'.jpg')) ? $this->context->language->iso_code.'-default' : $item['id_manufacturer'];

$this->context->smarty->assign(array(
...
...

Code:

$filtro = $_GET["filtro"];          //get url parameter
$indic = 0;                            
if ($filtro<>""){
foreach ($data as &$item){
if ( (substr($item['name'],0,1))<>$filtro){ //compare initial with filter option
unset($data[$indic]); //delete item
}
$indic = $indic + 1;
}
}
$data = array_values($data); //reindex array

3.- Finish
That's all, now when something click on a "letter Char" (with that example), the manufactures list will be filtered as you own need.

Hope that can help someone ;)

Sunday, June 16, 2013

Change / Customize Magento Toolbar for list page

Problem:

We found that inside list product views on Magento, usually on categoryview.phtml we found something like that: $this->getToolbarHtml() but we need to change the default toolbal value for our own customized one.

Solution:

As sure that all of you know, the toolbar is located inside path catalog/product/list/toolbar, ok, just copy default toolbar and create an customize with your needs, once you have your own toolbar foolow the next steps:

Search on top of bottom for:  

<?php echo $this->getToolbarHtml() ?>

and replace it with:

<?php  
//echo $this->getToolbarHtml()
echo $this->getToolbarBlock()->setTemplate('catalog/product/list/toolbar_yourbar.phtml')->toHtml(); 
?> 

Hope this hep you!

Friday, May 10, 2013

Prestashop - website redirect to another domain


Problem:
When you acces to your store you show how the web page is redirect to another domain, that is due because maybe you have migrate the website from one server to another.

Solution:
Access your database.Most database is on phpmyadmin.
Go to table named ps_shop_url and edit the entries for domain, domian_ssl and physical_uri accordingly.
Let's say your domain name is mysample.net
Fill in the the box with your domain name and a forward slash according as shown below. Replace the domain name to yours

   Domain :        mysample.net
   Domian_ss:    
mysample.net
   Physical_uri:    /

Prestashop - Directory Permissinons

Problem:  
you wanna to know the correct permissions for critical directoris on prestashop directory estructure:

Solution:
just acces trough ftp clinet and change to 777 with recursive that directories and thir files:

          config folder

          cache folder
          img folder and subfolders
          mails folder and subfolders
          modules folder and subfolders
          themes folder and themes/lang folder

Monday, April 22, 2013

how to export all notes to a excel from a power point ?

Problem
we need to export all notes from a powerpoint to a text file.

Solution:
create a macro calling code editor with ALT+F11 and insert the next code:

Option Explicit

Sub ExportNotesText()

    Dim oSlides As Slides
    Dim oSl As Slide
    Dim oSh As Shape
    Dim strNotesText As String
    Dim strFileName As String
    Dim intFileNum As Integer
    Dim lngReturn As Long

    ' Get a filename to store the collected text
    strFileName = InputBox("Enter the full path and name of file to extract notes text to", "Output file?")

    ' did user cancel?
    If strFileName = "" Then
        Exit Sub
    End If

    ' is the path valid?  crude but effective test:  try to create the file.
    intFileNum = FreeFile()
    On Error Resume Next
    Open strFileName For Output As intFileNum
    If Err.Number <> 0 Then     ' we have a problem
        MsgBox "Couldn't create the file: " & strFileName & vbCrLf _
            & "Please try again."
        Exit Sub
    End If
    Close #intFileNum  ' temporarily

    ' Get the notes text
    Set oSlides = ActivePresentation.Slides
    For Each oSl In oSlides
        strNotesText = strNotesText & "======================================" & vbCrLf
        strNotesText = strNotesText & SlideTitle(oSl) & vbCrLf
        strNotesText = strNotesText & NotesText(oSl) & vbCrLf
    Next oSl

    ' now write the text to file
    Open strFileName For Output As intFileNum
    Print #intFileNum, strNotesText
    Close #intFileNum

    ' show what we've done
    lngReturn = Shell("NOTEPAD.EXE " & strFileName, vbNormalFocus)

End Sub
Function SlideTitle(oSl As Slide) As String
    Dim oSh As Shape
    For Each oSh In oSl.Shapes
        If oSh.Type = msoPlaceholder Then
            If oSh.PlaceholderFormat.Type = ppPlaceholderTitle _
                Or oSh.PlaceholderFormat.Type = ppPlaceholderCenterTitle Then
                If Len(oSh.TextFrame.TextRange.Text) > 0 Then
                    SlideTitle = oSh.TextFrame.TextRange.Text
                Else
                    SlideTitle = "Slide " & CStr(oSl.SlideIndex)
                End If
                Exit Function
            End If
        End If
    Next
End Function

Function NotesText(oSl As Slide) As String
    Dim oSh As Shape

    For Each oSh In oSl.NotesPage.Shapes
        If oSh.PlaceholderFormat.Type = ppPlaceholderBody Then
            If oSh.HasTextFrame Then
                If oSh.TextFrame.HasText Then
                    NotesText = oSh.TextFrame.TextRange.Text
                End If
            End If
        End If
    Next oSh
End Function

Saturday, April 13, 2013

Translate back office tab texts like "Manufacturers"


Problem:
You need to change some back office labels or text on admin menu, like Catalog, Orders, etc...

Solution:
you will are not able to do that trough translation files, the only possibility is to change directly inside database, you have to search for "ps_tab_lang" and change all texts that you need here.

How to debug prestashop errors like error "product()"



Problem:   
i get a problem while trying to duplicate an exiting item, the error message is not clear i only can see "product()", for that i have to search something to debug that problem.

Solution:
search defines.inc.php located in the /config directory and change a parameter 
define('PS_MODE_DEV', false);
by
define('PS_MODE_DEV', true);
now you will able to see the error on sentence like thins:
"....Unknown column 'redirect_type' in 'field list'INSERT INTO `ps_product` (`id_shop_default`, `id_manufacturer`, `id_supplier`, `reference`, `...."

Thursday, April 4, 2013

avoid to send any mail on user registration

Problem:

When any user is registred on joomla, beside you disable email registration, the system is sending an e-mail to administrator for new user details; we need to avoid that send mail function.

Solution:

Acces to file "controller.php" on path "components/com_user" and edit the next line:

Replace:
UserController::_sendMail($user, $password);


With:
// UserController::_sendMail($user, $password);



Tuesday, February 5, 2013

How-to hide joomla plugin conditional on some pages


Problem:     We need to hide joomla plugin like sharethis social buttons only on some pages, we don't need to show that plugin on simple layout article only on blog types

Solution:

1. Download plugin file from folder: plugins/content/sharethis.php
2. Add a function to read the base url where the plugin is loaded on the start of the file, just after ?php line.

----------
...

function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return $pageURL;
}
...

----------
3.- Now we need to create a condition for only display the plugin where the url contain string "layout=blog", see url sample:
index.php?option=com_content&view=category&layout=blog&id=19&Itemid=12

4.- We end our piece of code adding the condition if we found a substring "layout-blog" inside the base url, see the code in green with our modiifcation on sharethis.php plugin.
----------
...

$url = curPageURL();
if (strpos($url,'layout=blog')) {
/* Return whole button style code with article title and article url values. */
$url = JURI::root().ContentHelperRoute::getArticleRoute($article->id, $article->catid);
return "<DIV style='text-align:".$this->_alignment.";padding-bottom:30px;padding-top:10px'>".$this->showWidget().$this->getWidgetStyle($url,$article->title)."</DIV>";
}
else
{
/* that the code to return to function when the condition is tru on lyout=blog
return "<DIV id='hidden'></DIV>";
}  
... 
----------


That's all folks ;-)

Saturday, January 12, 2013

Add custom field on joomla user registration


Problem:     
you need to add a new field on joomla user registration process, like a flag to confirm newsletter subscription

Solution:

This is actually really simple.

open your joomla database in your db manager. I generally do this in "PHPMYADMIN". 
From there open the table "jos_users" and then add your additional fields that you require.

Then you go into libraries/joomla/database/table/user.php and declare you variables. So if you added a country field then you declair the varible like so:

var $Country = null;

The next step in the process is editing the actual registration form. This is done by going to components/com_user/views/register/tmpl/default.php.

On some joomla reales there is important to edit diferent files, here is a list of the folder where you can find layouts to edits.



  • administrator/components/com_user/views/user/tmpl/ 
  • component/com_user/views/user/tmpl 
  • components/com_user/views/register/tmpl/ libraries/joomla/database/table/ 
  • template/xxx/html/com_user/register/ 
  • template/xxx/html/com_user/user

More information: