Sujet fermé
Note de ce sujet :
  • Moyenne : 0 (0 vote(s))
  • 1
  • 2
  • 3
  • 4
  • 5

[Résolu] smarty et balise {php}
#3

Salut,

Merci pour la réponse rapide mais echo n'est pas une balise mais une fonction php :

Admin => Content => Global Content Blocks

Menu :

Code :
[== Indéfini ==]
{php}
global $gCms;

$manager =& $gCms->GetHierarchyManager();

$var = 'root_page_id';
if( isset($params['assign']) && $params['assign'] != '' )
{
  $var = $params['assign'];
}
$result = "NO RESULT";
$thisPage = $gCms->variables['content_id'];
$currentNode = &$manager->sureGetNodeById($thisPage);
while( isset($currentNode) && $currentNode->getLevel() >= 0 )
{
    $currentContent =& $currentNode->getContent();
    $result = $currentContent->Hierarchy();
    $currentNode =& $currentNode->getParentNode();
}

/*
echo $result;
*/



switch ($result) {

case "":
    $home = true;
    break;    
    
case 1:
    $home = true;
    break;    
case 2:
    $project = true;
    break;        
    
case 3:
    $partners = true;
    break;
    
case 4:
    $library = true;
    break;
        
case 5:
    $contact = true;
    break;
    
default:
  $home = true;
   break;
}
/*
echo $gCms->variables['page_name'];
*/
{/php}
<div id="header_bottom">
  <ul class="nav">
    <li ><a href="index.php?page=home" class="bouton_menu{php} if ($home == true){echo "_current"; }  {/php}"  onmouseover ="javascript:ak_hidelayer('sm_1');ak_hidelayer('sm_2');ak_hidelayer('sm_3')" >HOME</a></li>
    <li><a href="index.php?page=project" class="bouton_menu{php} if ($project == true){echo "_current"; }  {/php}"  onmouseover ="javascript:ak_showlayer('sm_3');ak_hidelayer('sm_1');ak_hidelayer('sm_2')">PROJECT</a>
      <ul class="submenu" id="sm_3" onmouseout="ak_hidelayer('sm_3')" >
<li  onmouseover ="javascript:ak_showlayer('sm_3')"><a href="index.php?page=committees">Management Committees</a></li>
        <li  onmouseover ="javascript:ak_showlayer('sm_3')"><a href="index.php?page=project">MIP-DILI Project</a></li>
        <li  onmouseover ="javascript:ak_showlayer('sm_3')"><a href="index.php?page=work-package-1">Work package 1</a></li>
        <li  onmouseover ="javascript:ak_showlayer('sm_3')"><a href="index.php?page=work-package-2">Work package 2</a></li>
        <li  onmouseover ="javascript:ak_showlayer('sm_3')"><a href="index.php?page=work-package-3">Work package 3</a></li>
        <li  onmouseover ="javascript:ak_showlayer('sm_3')"><a href="index.php?page=work-package-4">Work package 4</a></li>
        <li  onmouseover ="javascript:ak_showlayer('sm_3')"><a href="index.php?page=work-package-5">Work package 5</a></li>
        <li  onmouseover ="javascript:ak_showlayer('sm_3')"><a href="index.php?page=work-package-6">Work package 6</a></li>
        <li  onmouseover ="javascript:ak_showlayer('sm_3')"><a href="index.php?page=work-package-7">Work package 7</a></li>
    </li>
      </ul>
    <li ><a href="index.php?page=partners"class="bouton_menu{php} if ($partners == true){echo "_current"; }  {/php}" onmouseover="javascript:ak_showlayer('sm_1');ak_hidelayer('sm_2');ak_hidelayer('sm_3')" >PARTNERS</a>
      <ul class="submenu" id="sm_1"  onmouseout="ak_hidelayer('sm_1')">
        <li onmouseover ="javascript:ak_showlayer('sm_1')"><a href="index.php?page=partners&menu=efpia">EFPIA Members</a></li>
<li onmouseover ="javascript:ak_showlayer('sm_1')"><a href="index.php?page=partners&menu=academics">Academics</a></li>
<li onmouseover ="javascript:ak_showlayer('sm_1')"><a href="index.php?page=partners&menu=smes">SMEs</a></li>
  
        <!-- <li><a href="index.php?page=job-announcements">Job Announcements</a></li>-->
      </ul>
    </li>
    <li ><a href="index.php?page=library" class="bouton_menu{php} if ($library == true){echo "_current"; }  {/php}" onmouseover="javascript:showlayer('sm_2');ak_hidelayer('sm_1');ak_hidelayer('sm_3')" >LIBRARY</a>
      <ul class="submenu" id="sm_2"  onmouseout="ak_hidelayer('sm_2')">
        <li onmouseover ="javascript:ak_showlayer('sm_2')"><a href="index.php?page=library">News & Publications</a></li>
        <li onmouseover ="javascript:ak_showlayer('sm_2')"><a href="index.php?page=archives">Archives</a></li>
        <li onmouseover ="javascript:ak_showlayer('sm_2')"><a href="index.php?page=glossary">Glossary</a></li>
<li onmouseover ="javascript:ak_showlayer('sm_2')"><a href="index.php?page=links">Links</a></li>
      </ul>
    </li>
    <!--  <li  ><a href="index.php?page=news" class="bouton_menu{php} if ($news == true){echo "_current"; }  {/php}">NEWS</a></li>-->
    <!--    <li><a href="index.php?page=events" class="bouton_menu{php} if ($events == true){echo "_current"; }  {/php}">EVENTS</a></li>-->
    <li ><a href="index.php?page=contact" class="bouton_menu{php} if ($contact == true){echo "_current"; }  {/php}" onmouseover ="javascript:ak_hidelayer('sm_1');ak_hidelayer('sm_2');ak_hidelayer('sm_3')">CONTACT</a></li>
  </ul>
</div>

Les erreurs viennent de ceci :

{php} if ($home == true){echo "_current"; } {/php}

alors que normalement :

SmartyBC.class.php :

Code :
[== Indéfini ==]
    public function __construct(array $options=array())
    {
        parent::__construct($options);
        // register {php} tag
        $this->registerPlugin('block', 'php', 'smarty_php_tag');
    }


/**
* Smarty {php}{/php} block function
*
* @param array   $params   parameter list
* @param string  $content  contents of the block
* @param object  $template template object
* @param boolean &$repeat  repeat flag
* @return string content re-formatted
*/
function smarty_php_tag($params, $content, $template, &$repeat)
{
    eval($content);

    return '';
}

Le PHP devrait être eval, non parsé.
Sujet fermé


Messages dans ce sujet

Atteindre :


Utilisateur(s) parcourant ce sujet : 1 visiteur(s)