Jump to content

faire un include dans le footer prestashop 1.6.2


Recommended Posts

Bonjour,

 

Je souhaite faire un include du page pour un script en php d'une page php à la racine du mon site,

donc dans le footer (qui est monsite.themes/monThemes/footer.tpl) avant </body> j'écris

 

 

<?php

  include ('maPage.php');
?>

 

 

Mais quand je regarde le code source de ma page, je vois 

<?php

  include ('maPage.php');
?>
Ce qui ne devrai pas ce voir;  et surtout cela ne fonctionne pas visiblement.
 
En plus je ne respecte plus le MVC donc comment faire ????????
 
Merci !!!!!!!
Edited by reaman (see edit history)
Link to comment
Share on other sites

Bon dans mon footer.tpl j'inclus donc ainsi :

 

 

<?php

   {include file='maPage.php'}
?>

 

Puis dans maPage.php, j'ai le script suivant :

 

 

<?php

// This function will call the API to get best keyword for current URL.
// Then it writes the list of best keywords in a HTML list
function DisplayTopKeywords($url = "")
{
// Do not spend more than 1 second fetching the data
@ini_set("default_socket_timeout", $timeout = 1);
// Get the Keywords data
$keywords = @unserialize(file_get_contents($api));
if($keywords === false || isset($keywords["result"])) {
// DEBUG ONLY: uncomment for troubleshooting an empty output (the URL output reveals the token_auth)
// echo "Error while fetching the <a href='$api'>Top Keywords from Piwik</a>";
return;
}
 
// Display the list in HTML
$url = htmlspecialchars($url, ENT_QUOTES);
$output = "<h2>Top Keywords for <a href='$url'>$url</a></h2><ul>";
foreach($keywords as $keyword) {
$output .= "<li>". $keyword[0]. "</li>";
}
if(empty($keywords)) { $output .= "Nothing yet..."; }
$output .= "</ul>";
echo $output;
}
 
 DisplayTopKeywords();
 
?>

 

et du coup dans le footer de ma page, j'ai sa qui apparait 

 

Top Keywords from Piwik"; return; } // Display the list in HTML $url = htmlspecialchars($url, ENT_QUOTES); $output = "

Top Keywords for $url
  • "; foreach($keywords as $keyword) { $output .= "
  • ". $keyword[0]. "
  • "; } if(empty($keywords)) { $output .= "Nothing yet..."; } $output .= "

"; echo $output; } DisplayTopKeywords(); ?> ?>

 

Plutôt embarassant !!!

Link to comment
Share on other sites

ok il inclus un fichier .tpl, donc 

 

 

<?php

   {include file="maPage.tpl"}
?>

 

Et du coup cela donne

 

 

<?php

// This function will call the API to get best keyword for current URL.
// Then it writes the list of best keywords in a HTML list
function DisplayTopKeywords($url = "")
{
// Do not spend more than 1 second fetching the data
@ini_set("default_socket_timeout", $timeout = 1);
// Get the Keywords data
$keywords = @unserialize(file_get_contents($api));
if($keywords === false || isset($keywords["result"])) {
// DEBUG ONLY: uncomment for troubleshooting an empty output (the URL output reveals the token_auth)
// echo "Error while fetching the <a href='$api'>Top Keywords from Piwik</a>";
return;
}
 
// Display the list in HTML
$url = htmlspecialchars($url, ENT_QUOTES);
$output = "<h2>Top Keywords for <a href='$url'>$url</a></h2><ul>";
foreach($keywords as $keyword) {
$output .= "<li>". $keyword[0]. "</li>";
}
if(empty($keywords)) { $output .= "Nothing yet..."; }
$output .= "</ul>";
echo $output;
}
 
 DisplayTopKeywords();
 
?>

 

mais toujours le code qui s'affiche dans mon footer, j'comprends pas trop why ? 

j'tourne, j'tourne, j'tourne... En rond !!!!!! GRRRRRRRRRRRRR !!!!!!

Link to comment
Share on other sites

Bonjour,

 

à mon avis faire un simple module serait bien plus rapide.

 

car là vous essayez d'inclure un fichier php dans un fichier tpl ce qui est assez gênant. http://www.smarty.net/docsv2/fr/language.function.include.php.tpl

 

Prestashop utilise le modèle MVC donc essayez de le respecter et cela sera plus simple à mon avis.

 

 

vous pouvez aussi mettre votre code php directement dans le tpl ce qui est très pas bien mais bon à la vue de ce que vous faites cela ne peut pas être pire. http://www.smarty.net/docsv2/fr/language.function.php.tpl

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...