reaman Posted February 1, 2014 Share Posted February 1, 2014 (edited) 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 February 1, 2014 by reaman (see edit history) Link to comment Share on other sites More sharing options...
henri59fr Posted February 1, 2014 Share Posted February 1, 2014 il manque un # devant le include non ? Link to comment Share on other sites More sharing options...
reaman Posted February 1, 2014 Author Share Posted February 1, 2014 bah non, même avec cela ne change pas le problème. Merci quand même. Link to comment Share on other sites More sharing options...
coeos.pro Posted February 1, 2014 Share Posted February 1, 2014 les fichiers tpl sont des fichiers smarty donc on n'y met pas de php. si tu veux faire un include c'est par exemple dans le fichier product.tpl : {include file="$tpl_dir./product-list.tpl" products=$packItems} un peu de lecture : http://www.smarty.net/docsv2/fr/language.function.include.tpl Link to comment Share on other sites More sharing options...
reaman Posted February 1, 2014 Author Share Posted February 1, 2014 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 $api = "http://www.MonSitte.com/piwik/?module=API&method=Referrers.getKeywordsForPageUrl&format=php&filter_limit=10&token_auth=d0b5c99a2&date=previous1&period=week&idSite=1&url=" . urlencode($url); $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 More sharing options...
coeos.pro Posted February 1, 2014 Share Posted February 1, 2014 (edited) non, pas de balise php, ouvre des fichiers de ton themes comme category.tpl ou product.tpl, c'est juste : code html {include file='maPage.tpl'} code html il faut inclure un fichier tpl pas du php Edited February 1, 2014 by coeos.pro (see edit history) Link to comment Share on other sites More sharing options...
reaman Posted February 1, 2014 Author Share Posted February 1, 2014 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 $api = "http://www.monSite.com/piwik/?module=API&method=Referrers.getKeywordsForPageUrl&format=php&filter_limit=10&token_auth=f36d0b5c99a2&date=previous1&period=week&idSite=1&url=" . urlencode($url); $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 More sharing options...
Mediacom87 Posted February 2, 2014 Share Posted February 2, 2014 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now