Bonjour,
je n’aimais pas le fait que les TVs soient placés tout en bas d’un document lorsqu’on le modifie. J’essaie de les placer dans un onglet, par exemple juste après l’onglet "Snippets". Dans le fichier
mutate_content.dynamic.action, je remonte le code qui permet d’afficher les TVs, ceci juste après le div "tabSnippets" :
<div class="tab-page" id="tabTVs">
<h2 class="tab"><?php echo $_lang["settings_templvars"] ?></h2>
<script type="text/javascript">tpSettings.addTabPage( document.getElementById( "tabTVs" ) );</script>
<?php
// MODIFIED BY S.BRENNAN
$template = $default_template;
if(isset($_REQUEST['newtemplate'])){
$template = $_REQUEST['newtemplate'];
}
else{
if(isset($content['template'])) {
$template = $content['template'];
}
}
$sql = "SELECT DISTINCT tv.*, IF(tvc.value!='',tvc.value,tv.default_text) as value ";
$sql.= "FROM $dbase.".$table_prefix."site_tmplvars tv ";
$sql.= "INNER JOIN $dbase.".$table_prefix."site_tmplvar_templates tvtpl ON tvtpl.tmplvarid = tv.id ";
$sql.= "LEFT JOIN $dbase.".$table_prefix."site_tmplvar_contentvalues tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = $id ";
$sql.= "LEFT JOIN $dbase.".$table_prefix."site_tmplvar_access tva ON tva.tmplvarid=tv.id ";
$sql.= "WHERE tvtpl.templateid = ".$template." AND (1='".$_SESSION['mgrRole']."' OR ISNULL(tva.documentgroup)".((!$docgrp)? "":" OR tva.documentgroup IN ($docgrp)").") ORDER BY tv.rank;";
$rs = mysql_query($sql);
$limit = mysql_num_rows($rs);
if($limit>0){
echo "<table style='position:relative' border='0' cellspacing='0' cellpadding='3' width='96%'>";
require_once('tmplvars.inc.php');
require_once('tmplvars.commands.inc.php');
for ($i=0; $i<$limit; $i++) {
// go through and display all the document variables
$row = mysql_fetch_assoc($rs);
if($row['type']=='richtext'||$row['type']=='htmlarea'){ // htmlarea for backward compatibility
if (is_array($replace_richtexteditor))
$replace_richtexteditor = array_merge($replace_richtexteditor,array("tv".$row['name']));
else
$replace_richtexteditor = array("tv".$row['name']);
}
// splitter
if($i>0 && $i<$limit) echo '<tr><td colspan="2"><div class="split"></div></td></tr>';
?>
<tr style="height: 24px;">
<td align="left" valign="top" width="150">
<span class='warning'><?php echo $row['caption']; ?></span><br /><span class='comment'><?php echo $row['description']; ?></span>
</td>
<td valign="top" style="position:relative">
<?php
$tvPBV = $_POST['tv'.$row['name']]; // post back value
echo renderFormElement($row['type'], $row['name'], $row['default_text'], $row['elements'], ($tvPBV ? $tvPBV:$row['value']), ' style="width:300px;"');
?>
</td>
</tr>
<?php
} //loop through all template variables
?>
</table>
<?php
}
else {
echo $_lang['tmplvars_novars'];
}//end check to see if there are template variables to display
?>
</div>
<?php } ?>
<?php if($_REQUEST['a']!='4' && $_REQUEST['a']!=72) { ?>
<!-- Preview -->
<div class="tab-page" id="tabPreview">
<h2 class="tab"><img src="media/images/icons/preview.gif" align="absmiddle" height="12"> <?php echo $_lang['preview']; ?></h2>
<script type="text/javascript">tpSettings.addTabPage( document.getElementById( "tabPreview" ), previewdocument );</script>
<table width="96%" border="0"><tr><td><?php echo $_lang['preview_msg'];?></td></tr>
<tr><td><iframe name="preview" frameborder="0" width="100%" height="400" style="border:1px solid #E0E0E0"></iframe></td></tr>
</table>
</div>
<?php } ?>
</div>
</div>
Si vous voulez conserver également les TVs en bas du document, changez dans l’ancien code les "require" en "require_once" :
require_once('tmplvars.inc.php');
require_once('tmplvars.commands.inc.php');
mais alors il y a un conflit dans les "id"’s des "input"’s, et seul le champ en bas permet de changer les valeurs des TVs.