в поле Ссылка на документ добавил поле Заголовок

This commit is contained in:
2025-12-03 11:53:55 +05:00
parent b829d3b6d6
commit 60dae57fb0
2 changed files with 45 additions and 2 deletions

View File

@@ -11,7 +11,6 @@
* @license GPL v.2
*/
// Ссылка
function get_field_doc_link($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength=null, $document_fields=array(), $rubric_id=0, $default=null, $_tpl=null)
{
global $AVE_Template;
@@ -39,6 +38,23 @@
$clean_field_value .= '|' . $field_param[1];
}
$doc_id = 0;
$document_name_to_display = '';
if (preg_match('/id=([0-9]+)/i', $clean_field_value, $matches)) {
$doc_id = (int)$matches[1];
}
if ($doc_id > 0) {
$document_data = get_document($doc_id);
if ($document_data && !empty($document_data['document_title'])) {
$document_name_to_display = $document_data['document_title'];
} elseif ($doc_id === 1) {
$document_name_to_display = 'Главная страница';
}
}
$AVE_Template->assign('display_value', $document_name_to_display);
$AVE_Template->assign('field_id', $field_id);
$AVE_Template->assign('field_value', $clean_field_value);

View File

@@ -1,2 +1,29 @@
<script>
{literal}
function clearDisplayField(fieldId) {
const displayField = document.getElementById('feld_' + fieldId + '_display');
if (displayField) {
displayField.value = '';
}
}
{/literal}
</script>
<div style="margin-bottom: 5px;">
<input
id="feld_{$field_id}_display"
type="text"
style="width: 400px; background-color: #f5f5f5;"
value="{$display_value|escape}"
readonly="readonly"
/>
</div>
<input id="feld_{$field_id}" type="text" style="width: 400px;" name="feld[{$field_id}]" value="{$field_value|escape}" />&nbsp;
<input value="{#MAIN_BROWSE_DOCUMENTS#}" class="basicBtn" type="button" onclick="openLinkWin('feld_{$field_id}', 'feld_{$field_id}');" />
<input
value="{#MAIN_BROWSE_DOCUMENTS#}"
class="basicBtn"
type="button"
onclick="clearDisplayField('{$field_id}'); openLinkWin('feld_{$field_id}', 'feld_{$field_id}');"
/>