I tried to create a multible link box (see form code). If I add a link element with this code I can not, if I choosed internal page or file, get the sitemap or the file albums.
<?php defined("C5_EXECUTE") or die("Access Denied."); ?>
<?php
$remove_row_icon = '<img src="'.ASSETS_URL_IMAGES.'/icons/icon_scrapbook_delete.png" class="remove_row" style="cursor: default; height:20px; width:20px;" >';
?>
<style type="text/css">
.linkExternal { display: none; }
.linkInternal { display: none; }
.linkEmail { display: none; }
.linkFile { display: none; }
.doNotDisplay {display: none; }
</style>
<!-- Templates -->
<li class="panel panel-info changeLink rowContainer doNotDisplay">
<div class="panel-heading" style='cursor: move;'><?php echo($remove_row_icon) ?> Link</div>
<div class="panel-body">
<div class="form-group">
<?php $options = array(
'none' => t('choose linktype'),
'internal' => t('internal Page'),
'external' => t('external URL'),
'email' => t('eMail'),
'file' => t('File')
); ?>
<?php echo $form->select("sgLinkChooseType[]", $options, $sgAbstractChooseLinktype, array("class" => "linkChanger")); ?>
</div>
<div class="linkInternal form-group">
<?php echo Loader::helper("form/page_selector")->selectPage("sgLinkPage"); ?>
<?php echo $form->text("sgLinkPageText[]", $sgAbstractPageText, array('placeholder' => t('Label'))); ?>
</div>
<div class="linkExternal form-group">
<?php echo $form->text("sgLinkUrl[]", $sgAbstractUrl, array('placeholder' => t('URL'))); ?>
<?php echo $form->text("sgLinkUrlText[]", $sgAbstractUrlText, array('placeholder' => t('Label'), 'style' => 'margin-top:10px;')); ?>
</div>
<div class="linkEmail form-group">
<?php echo $form->text("sgLinkEmail[]", $sgAbstractEmail, array ('maxlength' => 255, 'placeholder' => t('email'))); ?>
</div>
<div class="linkFile form-group">
<label class="control-label">Photo</label>
<?php
$service = Core::make('helper/concrete/file_manager');
print $service->file('file', 'sgLinkFile[]', 'Select File');
?>
</div>
</div>
</li>
<!-- Templates end -->
<div class="panel panel-default well">
<ul class=" list-unstyled linkList">
</ul>
</div>
<button type="button" class="btn btn-default addLink">add</button>
<script type="text/javascript">
$(document).ready(function(){
$(document).on('click', '.remove_row', function (){
$(this).closest('.rowContainer').remove();
});
$(document).on('click', 'button.addLink', function(){
$( ".changeLink" ).clone().appendTo( ".linkList" );
$(".linkList").children().removeClass( "doNotDisplay" );
});
$(document).on('change', 'select.linkChanger', function(){
var linkPanel = $(this).closest('.panel-body');
linkPanel.children("div.linkExternal").hide();
linkPanel.children("div.linkInternal").hide();
linkPanel.children("div.linkEmail").hide();
linkPanel.children("div.linkFile").hide();
if ($(this).val() == 'external'){
linkPanel.children("div.linkExternal").show();
} else if ($(this).val() == 'internal') {
linkPanel.children("div.linkInternal").show();
} else if ($(this).val() == 'email') {
linkPanel.children("div.linkEmail").show();
} else if ($(this).val() == 'file') {
linkPanel.children("div.linkFile").show();
}
});
});
jQuery(function($) {
var panelList = $('.draggablePanelList');
panelList.sortable({
// Only make the .panel-heading child elements support dragging.
// Omit this to make then entire <li>...</li> draggable.
handle: '.panel-heading',
update: function() {
$('.panel', panelList).each(function(index, elem) {
var $listItem = $(elem),
newIndex = $listItem.index();
});
}
});
});