I’ve built one variable (horaires_lundi) in this file :
app/code/community/Unirgy/StoreLocator/controllers/Adminhtml/Locationcontroller.php
->setTitle($this->getRequest()->getParam('title'))
->setNotes($this->getRequest()->getParam('notes'))
->setStreetAddress($this->getRequest()->getParam('street_address'))
->setHorairesLundi($this->getRequest()->getParam('horaires_lundi'))
All variables are well displayed in JavaScript in this file :
app/design/frontend/default/default/template/unirgy/storelocator/map.phtml
(function(){
var storeLocator = new UnirgyStoreLocator({
mapEl: $('map'),
sidebarEl: $('sidebar'),
searchUrl: '<?php echo $this->getUrl('ustorelocator/location/search')?>',
generateSidebarHtml: function(m) {
return '<span style="font-size:14px; color:#C68804;"><b>' + m.title + '</b></span><br/>(Distance : ' + parseFloat(m.distance).toFixed(1) + ' ' + m.units + ')<br/>'
+ m.street_address + ' ' + m.test + ' ' + m.city + '<br/><b>' + m.notes + '</b><br/>';
},
generateMarkerHtml: function(m) {
var url = m.website_url.replace(/\s/,'');
var dataForm = new VarienForm('form-validate', true);
return '<span style="font-size:14px; color:#C68804;">' + m.title + '</span><br/>'
+ '<?php if (trim($this->getHorairesLundi())!=""): ?>Lun '+ m.horaires_lundi +'<?php else : ?>No horaire lundi<br/><?php endif; ?>'
variable m.horaires_lundi in JavaScript is well displayed in frontend.
But I can’t make a condition in PHP to display m.horaires_lundi only if m.horaires_lundi exists…
Above I made a try with
<?php if (trim($this->getHorairesLundi())!=""): ?>
Is it a goog method? what else must I do?
Is there an other method with something like:
<?php if (Mage::helper(...
I’ve found a tutorial about Magento but can’t find my solution.
There’s a significant distinction between PHP and JavaScript: the former is a server-side scripting language, the latter a client-side scripting language. Though you can use PHP to conditionally
echoJavaScript code to the browser (which I don’t recommend), you can’t access JavaScript variables in PHP. Just test for the presence of a JavaScript variable in the script itself.If I understand your goal correctly, you can rewrite your last line of code to