Showing posts with label note to self. Show all posts
Showing posts with label note to self. Show all posts

Thursday, June 24, 2010

Popups

In the picture in my last post there is one thing that may need extra explanation:
The texts "About the rank suggestion" and "About the book sizes" underneath the Data Sheet Tab.
They are links to pop-up windows, like this


















This is accomplished in a pretty crude way IMHO, in [themes folder]/css/global.css I added
/* pop up */
#layer1 {
position: relative;
visibility: hidden;
width: 250px;
height: 110px;
left: 0px;
top: 0px;
background-color: #fff;
border: 1px solid #000;
padding: 10px;
}
#layer2 {
position: relative;
visibility: hidden;
width: 250px;
height: 110px;
left: 0px;
top: 0px;
background-color: #fff;
border: 1px solid #000;
padding: 10px;
}
#close {
float: right;
}
/* /pop up */
then in [themes folder]/product.tpl beneath the code to display the features
<table border="0">
<tr>
<p>
<th style="text-align: left">
<a href="javascript:setVisible('layer1',true)">{l s='About the rank suggestion'}</a>
</th></p>
<th style="text-align: left">
<a href="javascript:setVisible('layer2',true)">{l s='About the book sizes'}</a>
</th>
</tr>
<tr>
<td>
<div id="layer1">
<span id="close"><a href="javascript:setVisible('layer1')" style="text-decoration: none"><strong>{l s='Hide'}</strong></a></span>
<p><br />{l s='Rank suggestions are taken from various websites and are sometimes also based on my personal ideas.'}<br />
{l s='If you have different opinions about what rank the reader should be when reading the book, please contact me!'}
<br /></p>
</div>
</td>
<td>
<div id="layer2">
<span id="close"><a href="javascript:setVisible('layer2')" style="text-decoration: none"><strong>{l s='Hide'}</strong></a></span>
<p><br />{l s='The book sizes are approximate.'}<br />
{l s='L = close to A4, about 26-28 cm high'}</br>
{l s='M = close to A5, about 19-22 cm high'}</br>
{l s='S = In-between A5 and A6, about 17-18 cm high'}</br>
{l s='XS = close to A6, about 14 cm high'}
<br /></p>
</div>
</td>
</tr>
</table>
and in [themes folder]/header.tpl
<script type="text/javascript" src="{$content_dir}/../../pop-up/popupDiv.js"></script>
And finaly in the folder directed to in header.tpl I created the file popupDic.js with the following content
/* -----------------------------------------------
Floating layer - v.1
(c) 2006 www.haan.net
contact: jeroen@haan.net
You may use this script but please leave the credits on top intact.
Please inform us of any improvements made.
When usefull we will add your credits.
------------------------------------------------ */
x = 20;
y = 70;
function setVisible(obj)
{
obj = document.getElementById(obj);
obj.style.visibility = (obj.style.visibility == 'visible') ? 'hidden' : 'visible';
}
function placeIt(obj)
{
obj = document.getElementById(obj);
if (document.documentElement)
{
theLeft = document.documentElement.scrollLeft;
theTop = document.documentElement.scrollTop;
}
else if (document.body)
{
theLeft = document.body.scrollLeft;
theTop = document.body.scrollTop;
}
theLeft += x;
theTop += y;
obj.style.left = theLeft + 'px' ;
obj.style.top = theTop + 'px' ;
setTimeout("placeIt('layer1')",500);
}
window.onscroll = setTimeout("placeIt('layer1')",500);

This solution was taken from http://javascript.internet.com/miscellaneous/popup-div.html

Wednesday, June 2, 2010

Default Country - Bug in IE 6-8

It seems I never wrote about this strange bug before, so here goes...

Problem description
If a customer use the Swedish Internet Explorer 6, 7, or 8 PrestaShop thinks they are located in El Salvador.

This is because of a bug in IE. IE sends the Language Code (SV for Sweden) intead of the Country Code (SE for Sweden, SV for El Salvador) to the server.
Since the bug appeared as early as in ver 6 of IE, one would think that the bug would be solved by now, but I guess it's not regarded severe enough.

Client side workaround
One workaround would be to add .se as suffix in IE (Verktyg, Internetalternativ, Språk), but since that only fix the problem for that single client it's not really a solution.

Solution
The way I solved it was to hardcode it in the PrestaShop code, like this:
In themes/prestashop (or whatever your themes folder is called)/authentication.tpl change $sl_country to the number that represents Sweden in your installation of PrestaShop (in mine it's 18 but could be something else for you)

I.e. change

{foreach from=$countries item=v}
<option value="{$v.id_country}" {if ($sl_country == $v.id_country)} selected="selected"{/if}>{$v.name|escape:'htmlall':'UTF-8'}</option>
{/foreach}

to

{foreach from=$countries item=v}
<option value="{$v.id_country}" {if (18 == $v.id_country)} selected="selected"{/if}>{$v.name|escape:'htmlall':'UTF-8'}</option>
{/foreach}


PS Note to self: use this to include code in blog posts