duplicate content in prestashop for items in different languages - internationalization

Good day all.
I have a Prestashop site, with different languages AND different countries, some of these countries uses the same language, but different currencies, or have small differences such as options available or colors for the product, but the main product is the same.
this has caused some warnings on the webmaster tools on google, mainly caused by duplicate title, or duplicate descriptions or similar.
the problem is that the Australian items is an english speaking item, but has different currencies and a different URL from the UK one.
searching on the web I have seen that a good practice is to insert the hreflang link with rel="alternate" so basically, I would like to obtain something like this in the head of the page:
<link rel="alternate" hreflang="en-us" href="http://www.example.com/en/page.html" />
<link rel="alternate" hreflang="en" href="http://www.example.com/en/page.html" />
<link rel="alternate" hreflang="en-au" href="http://www.example.com/au/page.html" />
<link rel="alternate" hreflang="de" href="http://www.example.com/de/seite.html" />
In a perfct world, all the combinations should be taken from the database, but I could live also with a "more" static solution as well. Does someone knows:
1) is this a solution for the problem i've noticed in webmaster tools?
2) which could be the best way to handle the warnings for duplicate content in this case (if answer 1 is "no")
3) Is there a clean way to handle the "en-us" (or any other combination) part?
4) Is there a clean way to handle the "/de/seite.html" (or else) part?

I have developed a module to final handle it:
http://www.matteobononi.it/prestashop_module_hreflang.php
feel free to use it if you need.
The module works on Prestashop from 1.5 to 1.6, it adds the hreflang meta links in the head section of several page types.

{PRESTA-1.6.x.x}
Who have problem with hreflang can use this article https://rubendivall.com/anadir-canonical-y-hreflang-en-prestashop-16x-en/
or add this code in header.tpl in:
< head>{code}< head/>
{if $page_name == 'category'}
<link rel="canonical" href="{$link->getCategoryLink($smarty.get.id_category, null, $id_lang,null,null )}" />
{if $languages|#count > 1}{foreach $languages as $lang}<link rel="alternate" hreflang="{$lang.iso_code}" href="{$link->getCategoryLink($smarty.get.id_category, null, $lang.id_lang,null,null )}" />{/foreach}{/if}
{if $start!=$stop}{if $p != 1 && $p_previous != 1}{assign var='p_previous' value=$p-1}
<link rel="prev" href="{$link->getCategoryLink($smarty.get.id_category, null, $id_lang,null,null )}{$link->goPage($requestPage, $p_previous)}" />{/if}
{if $pages_nb > 1 AND $p != $pages_nb}{assign var='p_next' value=$p+1}
<link rel="next" href="{$link->getCategoryLink($smarty.get.id_category, null, $id_lang,null,null )}{$link->goPage($requestPage, $p_next)}" />{/if}{/if}
{/if}
{if $page_name == 'product'}
<link rel="canonical" href="{$link->getProductLink($smarty.get.id_product, null, null, null, $id_lang, null, 0, false)}" />
{if $languages|#count > 1}{foreach $languages as $lang}<link rel="alternate" hreflang="{$lang.iso_code}" href="{$link->getProductLink($smarty.get.id_product, null, null, null, $lang.id_lang, null, 0, false)}" />{/foreach}{/if}
{/if}
{if $page_name == 'cms' && $smarty.get.id_cms > 0}
<link rel="canonical" href="{$link->getCMSLink($smarty.get.id_cms, null, false, $id_lang)}" />
{if $languages|#count > 1}{foreach $languages as $lang}<link rel="alternate" hreflang="{$lang.iso_code}" href="{$link->getCMSLink($smarty.get.id_cms, null, false, $lang.id_lang)}" />{/foreach}{/if}
{/if}
{if $page_name == 'manufacturer' && $smarty.get.id_manufacturer > 0}
<link rel="canonical" href="{$link->getManufacturerLink($smarty.get.id_manufacturer, null, $id_lang)}" />
{if $languages|#count > 1}{foreach $languages as $lang}<link rel="alternate" hreflang="{$lang.iso_code}" href="{$link->getManufacturerLink($smarty.get.id_manufacturer, null, $lang.id_lang)}" />{/foreach}{/if}
{/if}
{if $page_name == 'manufacturer' && !isset($smarty.get.id_manufacturer)}
<link rel="canonical" href="{$link->getPageLink('manufacturer', 'true', $id_lang)}" />
{if $languages|#count > 1}{foreach $languages as $lang}<link rel="alternate" hreflang="{$lang.iso_code}" href="{$link->getPageLink('manufacturer', 'true', $lang.id_lang)}" />{/foreach}{/if}
{/if}
{if $page_name == 'index'}
<link rel="canonical" href="{$link->getPageLink('index', 'true', $id_lang)}" />
{if $languages|#count > 1}{foreach $languages as $lang}<link rel="alternate" hreflang="{$lang.iso_code}" href="{$link->getPageLink('index', 'true', $lang.id_lang)}" />{/foreach}{/if}
{/if}

I wrote this solution. Insert it between <head></head> and change the languages /en/ && /es/ etc.
{if mb_strstr($smarty.server.REQUEST_URI, '/en/')}
<link rel="alternate" hreflang="es" href=http://{$smarty.server.SERVER_NAME}/es{substr($smarty.server.REQUEST_URI, 3)} />
<link rel="alternate" hreflang="de" href=http://{$smarty.server.SERVER_NAME}/de{substr($smarty.server.REQUEST_URI, 3)} />
{elseif mb_strstr($smarty.server.REQUEST_URI, '/es/')}
<link rel="alternate" hreflang="en" href=http://{$smarty.server.SERVER_NAME}/en{substr($smarty.server.REQUEST_URI, 3)} />
<link rel="alternate" hreflang="de" href=http://{$smarty.server.SERVER_NAME}/de{substr($smarty.server.REQUEST_URI, 3)} />
{elseif mb_strstr($smarty.server.REQUEST_URI, '/de/')}
<link rel="alternate" hreflang="es" href=http://{$smarty.server.SERVER_NAME}/es{substr($smarty.server.REQUEST_URI, 3)} />
<link rel="alternate" hreflang="en" href=http://{$smarty.server.SERVER_NAME}/en{substr($smarty.server.REQUEST_URI, 3)} />
{/if}

Related

Prestashop page speed Preload

in order to make site faster , i use "preload" for stylesheet and javascript files as below :
{foreach $stylesheets.external as $stylesheet}
<link rel="preload" href="{$stylesheet.uri}" as="style">
<link rel="stylesheet" href="{$stylesheet.uri}" media="{$stylesheet.media}">
{/foreach}
{foreach $stylesheets.inline as $stylesheet}
<style>
{$stylesheet.content}
</style>
{/foreach}
{foreach $javascript.external as $js}
<link rel="preload" href="{$js.uri}" as="script">
<script src="{$js.uri}" {$js.attribute}></script>
{/foreach}
{foreach $javascript.inline as $js}
<script type="text/javascript">
{$js.content nofilter}
</script>
{/foreach}
{if isset($vars) && $vars|#count}
<script type="text/javascript">
{foreach from=$vars key=var_name item=var_value}
var {$var_name} = {$var_value|json_encode nofilter};
{/foreach}
</script>
{/if}
all css code is in custom.css file and it contains media queries .
for desktop it works well .
How should i modifiy for responsive devices ?
should i put media uery one by one in a separate file ? and how include it in stylesheet.tpl file ?

CSS getted away with view.blade.php

I have a .blade.php view that is nice and well designed with css, but when I put a variable like {{$data}} or even inside a for each loop {{$d->col1}} the css design get away.
What is the reason to be
#foreach($data as $d )
{{$d->price}}
#endforeach
I corrected myself
I changed
<link rel="stylesheet" href="css/bootstrap.min.css" rel="stylesheet">
to
<link rel="stylesheet" href="{{ asset('css/bootstrap.min.css') }}" rel="stylesheet">
And the problem solved.

Problems with #yield and templating

I'm very new to Laravel and I'm trying to figure out how to use the templating.
I feel so sure that what I have here should work, but I keep getting an error when I run it. I think it has to do with having to #yield commands on the same line. Is this simply a limitation of the blade engine?
routes.php
Route::get('/', function()
{
return View::make('hello');
});
// Test Route:
Route::get('jtest', function(){
$page = array(
"lang" => "en",
"title" => "jtest",
"css" => "css/layout.css",
"rand" => rand()
);
return View::make('jtest')->with('page', $page);
});
jtest.blade.php
#extends('layout')
#section('html-lang')
#if ( isset($page['lang']) )
{{ $page['lang'] }}
#endif
#endsection
#section('title')
#if ( isset($page['title']) )
{{ $page['title'] }}
#endif
#endsection
#section('meta-description')
#if ( isset($page['meta-description']) )
{{ $page['meta-description'] }}
#endif
#endsection
#section('css')
#if ( isset( $page['css'] ) )
{{ $page['css'] }}
#endif
#endsection
#section('rand')
#if ( isset( $page['rand'] ) )
{{ $page['rand'] }}
#endif
#endsection
layout.blade.php
<!doctype html>
<html lang="#yield('html-lang')">
<head>
<meta charset="utf-8">
<title>#yield('title')</title>
<meta name="description" content="#yield('meta-description')">
<meta name="author" content="Jimmy Hogoboom">
<link rel="stylesheet" href="#yield('css')?r=#yield('rand')">
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<script src=""></script>
</body>
</html>
And the error is
syntax error, unexpected '='
and the line the error's on looks like this:
<link rel="stylesheet" href="<?php echo $__env->yieldContent('css')?r=#yield('rand'); ?>">
So the problem is here:
<link rel="stylesheet" href="#yield('css')?r=#yield('rand')">
If I remove the second #yield:
<link rel="stylesheet" href="#yield('css')?r=">
the page loads fine.
So is this just a limitation of blade, or is there some other way I should be placing these values in the page?
The best idea is to use #yield and sections only for bigger parts like main content or for a sidebar.
If you need 'isset' condition you can use
#if(isset($title)){{$title}}#endif
But this also should be done on controller with clean php including default value for a variable.
I am not sure why you need to use #yield for a small thing.
the following simple code will do the job:
<link rel="stylesheet" href="{{ $page['css'] }}?r={{ $page['rand'] }}">

can not finding the css,js and images

i am very new in codeigniter.I have a static web page.i just want to convert it into dynamic web page.First of all i pasted all the files in the view folder of the MVC of the codeigniter.Here i have css, javascript and images folder and my php files.
I have created a controller like this..
<?php
class Saffron extends CI_Controller
{
function index()
{
$this->load->view('home');
}
}
?>
and my home.php page is just like this..
<!DOCTYPE html>
<html lang="en">
<head>
<title>Home</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css"
media="screen" href="<?= base_url() ?>application/views/css/reset.css">
<link rel="stylesheet" type="text/css"
media="screen" href="<?= base_url() ?>application/views/css/style.css">
<link rel="stylesheet" type="text/css"
media="screen" href="<?= base_url() ?>application/views/css/slider.css">
<script src="<? echo base_url(); ?>application/views/js/jquery-1.7.min.js"></script>
<script src="<? echo base_url(); ?>application/views/js/jquery.easing.1.3.js"></script>
<script src="<? echo base_url(); ?>application/views/js/tms-0.4.1.js"></script>
<script src="<? echo base_url(); ?>application/views/js/vpb_script.js"></script>
<script src="<? echo base_url(); ?>application/views/js/pop.js"></script>
<!--start popup window ref-->
<link href="application/views/css/colorbox.css"
rel="stylesheet" type="text/css" media="all" />
<script src="<? echo base_url(); ?>application/views/js/jquery_002.js"></script>
<script>
$(document).ready(function(){
$(".image_show").colorbox({rel:'image_show', transition:"fade"});
});
</script>
<!--end popup window ref-->
<!--[if lt IE 8]>
<div style=' clear: both; text-align:center; position: relative;'>
<a href="http://windows.microsoft.com/en-US/
internet-explorer/products/ie/home?ocid=ie6_countdown_bannercode">
<img src="http://storage.ie6countdown.com/assets/100/
images/banners/warning_bar_0000_us.jpg" border="0" height="42"
width="820" alt="You are using an outdated browser. For a faster,
safer browsing experience, upgrade for free today." />
</a>
</div>
<![endif]-->
<!--[if lt IE 9]>
<script type="text/javascript" src="js/html5.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="css/ie.css">
<![endif]-->
</head>
<body>
<!--<div class="bg-top">-->
<div class="bgr">
<!--==============================Wrapper=================================-->
<div class="wrapper">
<!-----------------------Header --------------------------->
<header>
<div class="head">
<h1>
<a href="index.html">
<img src="<?php echo base_url(); ?>application/views/images/logo.jpg" alt=""></a>
sign up
<a href="javascript:void(0);"
class="classname1" onClick="vpb_show_login_box();">login</a>
</h1>
</div>
<?php
include_once('navigation.php');
include_once('slider.php');
include_once('offers.php');
include_once('invite.php');
include_once('testimonial.php');
include_once('special_item.php');
include_once('footer.php');
include_once('popup.php');
?>
Now what the mistake there...or anyelse that i can't recognizing??...please hlp me.
Thanks in Advance...
You forgot to put echo on several places.
I can show you my solution for putting files in header. First I made a folder in the root and named it public, and in that folder I created folders for needed documents (css, img, js...). In constants.php I made this:
$root = "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
define('ABSOLUTE_PATH', str_replace('system/','', BASEPATH));
define('BASE', $root);
define('CSS', BASE . 'public/css/');
define('JS', BASE . 'public/js/');
define('IMG', BASE . 'public/img/');
So in the header you can do this:
<link rel="stylesheet" href="<?php echo CSS ?>reset.css">
This is a easy way to maintain and update your files.
Sasha gave a good solution, but to answer your question: all your CSS, images, JS should not reside inside the application folder, but in a folder on the same level as application. assetsis a common name for such a folder.
Try this:
in your config file, define the base_url() ex, base_url() = 'yoursite';
in root directory create a folder and name it resource and put all your css, js, img folders inside
in your html/php view file (ex. application/views/test.php) along with html code put these php codes, example
NOTE: don't worry about echoing the base_url in every js or css file that you link because base has been already defined.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Home</title>
<meta charset="utf-8">
<base href="<?php echo base_url(); ?>" />
<link rel="stylesheet" type="text/css" media="screen" href="resource/css/reset.css">
<link rel="stylesheet" type="text/css" media="screen" href="resource/css/style.css">
<link rel="stylesheet" type="text/css" media="screen" href="resource/css/slider.css">
<script src="resource/js/jquery-1.7.min.js"></script>
<script src="resource/js/jquery.easing.1.3.js"></script>
<script src="resource/js/tms-0.4.1.js"></script>
<script src="resource/js/vpb_script.js"></script>
<script src="resource/js/pop.js"></script>

How to iterate over an array with HAML?

I have this in a HAML layout (layout.haml)
- #fonts.each do |font|
%link{:href=>"//fonts.googleapis.com/css?family={font}",:rel=>"stylesheet",:type=>"text/css"}
And I have this in the HAML template index.html.haml
- #fonts = ['Lato:400,300,100','Droid+Serif:700,400'];
When I compile, I get this:
<link href='//fonts.googleapis.com/css?family={font}' rel='stylesheet' type='text/css' />
<link href='//fonts.googleapis.com/css?family={font}' rel='stylesheet' type='text/css' />
What am I doing wrong?
You forgot the hash symbol.
- #fonts.each do |font|
%link{:href=>"//fonts.googleapis.com/css?family=#{font}",:rel=>"stylesheet",:type=>"text/css"}
^ here

Resources