Answer the question
In order to leave comments, you need to log in
How to display a Joomla module using javascript?
The task is to display the desired module in the content of the main page, depending on the resolution of the monitor on the client.
The solution of the problem, as I see it, point by point:
In the html code of the template, insert the code
<?php
// если находимся на главной, добавляем стандартными средствами joomla код javascript
$menuha = & JSite::getMenu();
if ($menuha->getActive() == $menuha->getDefault()) {
$document = & JFactory::getDocument();
$document->addScript('/media/system/js/vin.js');
}
?>
<p id="vin"> </p>
setTimeout(function(){
var vin = document.getElementById("vin");
if (screen.width > 1152) {
// vin.innerHTML = "{loadposition Vinaora}"; - к сожалению оба способа
// vin.innerHTML = " {module Vinaora}"; - вставки модуля тут не работают
} else {
// vin.innerHTML = "{loadposition Vinaora2}"; - к сожалению оба способа
// vin.innerHTML = " {module Vinaora2}"; - вставки модуля тут не работают
}
}, 1200);
$(document).ready(function() {
$('#vin').load('ПУТЬ_К_ФАЙЛУ/mod_vt_nivo_slider.php');
});
Answer the question
In order to leave comments, you need to log in
Put the content of the module in a hidden block and after loading the dom with javascript, move the content from the hidden block to the right place.
I don’t know how to do it on mootols, but on jquery it will be something like this:
<div class="hidden-module" id="hm1"><jdoc:include type=”modules” name=”hiddenpos” /> </div>
<!-- html -->
<div class="visible-module" id="vm1"></div>
<script>
$(document).ready(function(){
$('#vm1').html($('#hm1').html());
});
</script>
<source>
you can ask a question) why exactly js output? it's just not absolutely necessary for your decision
<jdoc:include type='modules' name='module_position' />
and have to write. and you also need to correct "templateDetails.xml" which lies at the root of the template, and add the name of your module there, i.e.<positions>
<!--все стандартные позиции шаблона-->
<position>module_position</position>
</positions>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question