İyi günler herkese,
Arkadaşlar sitemde dil seçeneklerini ve para birimi seçeneklerini bir ayar butonu ile popup olarak görüntülemeye çalışıyorum. Ama ufak bir sorunla karşılaştım.
Sweetalert kütüphanesini kullandım.
https://sweetalert2.github.io/
Şöyle bir kod var:
<button onclick="langcurrsettings()" type="button" class="btn btn-block btn-settings">
<i class="fa fa-cogs"></i>
</button>
<script>
function langcurrsettings() {
Swal.fire({
title: '<strong>General Settings</strong>',
icon: '',
html:
'<br>' +
'<span style="font-size:14px">Select Language:</span>' +
'<br>' +
'<?php echo $language; ?>'+
'<br>' +
'<span style="font-size:14px">Select Currency:</span>' +
'<br>' +
'<?php echo $currency; ?>' +
'<br>',
showCloseButton: true,
showCancelButton: false,
showConfirmButton: false,
focusConfirm: false,
focusCancel: false,
buttonsStyling: true,
confirmButtonText: '<span style="font-size:14px;"><i class="fa fa-thumbs-up"></i> Continue!</span>'
})
}
</script>Bu kodda "<?php echo $currency; ?>" değişkeni ile para birimini çekmeye çalışıyorum. <?php echo $currency; ?> kodunu script dışında kullanırsam çalışıyor, sayfaya para birimleri geliyor fakat script içinde kullanırsam popup çalışmamaya başlıyor. konsolda "
Uncaught ReferenceError: langcurrsettings is not defined at HTMLButtonElement.onclick" şeklinde bir hata alıyorum.
yada $currency değişkeninin geldiği sayfa olan currency.tpl'nin içini boşaltıp rastgele bir html kodu yazdığımda çalışıyor. ama içinde php kodu varken sorun oluyor.
currency.tpl içeriği böyle:
<?php if (count($currencies) > 1) { ?>
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form-currency">
<?php foreach ($currencies as $currency) { ?>
<?php if ($currency['symbol_left'] && $currency['code'] == $code) { ?>
<strong><?php echo $currency['symbol_left']; ?> <?php echo $currency['title']; ?></strong>
<?php } elseif ($currency['symbol_right'] && $currency['code'] == $code) { ?>
<strong><?php echo $currency['symbol_right']; ?> <?php echo $currency['title']; ?></strong>
<?php } ?>
<?php } ?>
<?php foreach ($currencies as $currency) { ?>
<?php if ($currency['symbol_left']) { ?>
<button class="currency-select btn btn-link btn-block" type="button" name="<?php echo $currency['code']; ?>"><?php echo $currency['symbol_left']; ?> <?php echo $currency['title']; ?></button>
<?php } else { ?>
<button class="currency-select btn btn-link btn-block" type="button" name="<?php echo $currency['code']; ?>"><?php echo $currency['symbol_right']; ?> <?php echo $currency['title']; ?></button>
<?php } ?>
<?php } ?>
<input type="hidden" name="code" value="" />
<input type="hidden" name="redirect" value="<?php echo $redirect; ?>" />
</form>
<?php } ?>Birlikte çalışmaları için ne şekilde düzenleme yapmam lazım yardımcı olabilecek olan var mı ?