Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Récupérer une variable smarty dans un include PHP

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: French
View previous topic :: View next topic  
Author Message
dldstyle
Smarty n00b


Joined: 18 Aug 2010
Posts: 1

PostPosted: Wed Aug 18, 2010 12:01 pm    Post subject: Récupérer une variable smarty dans un include PHP Reply with quote

Bonjour à tous,

Je découvre smarty sur un projet de client qui a déjà son site développé avec.
Je dois récupérer une variable pour l'utiliser dans un include en PHP.

Mon code :

index.php
Code:
<?
$catpple = 'Infirmier';
$smarty->assign('catpple', $catpple);
$smarty->display('template.tpl');
?>


template.tpl
Code:

Catégorie : {--$catpple--}
{--php--}include ('../../_admin/_includes/formulaire.inc.php');{--/php--}


formulaire.inc.php
Code:

<?php
echo '<p>' .$catpple. '</p>'; // <===== NE FONCTIONNE PAS
echo '<form action="index.php" method="post" id="formulaire">
...
';
?>


[color=red]C'est la partie echo '<p>' .$catpple. '</p>'; du dernier code qui ne marche pas.[/color] Je suis sûr que cela ne doit pas être sorcier mais je sèche
Merci pour votre aide
Smile
Back to top
View user's profile Send private message
Gowser
Smarty Pro


Joined: 19 Feb 2008
Posts: 104
Location: Nantes (France)

PostPosted: Mon Aug 23, 2010 6:49 am    Post subject: Reply with quote

Bonjour

Essayer ceci :

Code:
<?php
echo '<p>' .$this->get_template_vars('catpple'). '</p>';
echo '<form action="index.php" method="post" id="formulaire">
...
';
?>


http://www.smarty.net/manual/fr/api.get.template.vars.php

Cordialement
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: French All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP