How to add footer item javascript from single page controller after core javascripts?

Permalink
Hello!

Maybe this is simpler to solve, but I'm stuck as I can't add footer items after core javascripts, they are always prepended like this:

<script type="text/javascript" src="/packages/seisgl_gallery/js/dashboard_6glgallery.js"></script> <------------- I NEED THIS GUY AT LEAST AFTER "/concrete/js/app.js"
<script type="text/javascript" src="/index.php/tools/required/i18n_js"></script>
<script type="text/javascript">$(function() { ConcreteToolbar.start(); });</script>
<script type="text/javascript">$(function() { ConcreteDashboard.start(); });</script>
<script type="text/javascript" src="/concrete/js/jquery-ui.js"></script>
<script type="text/javascript" src="/concrete/js/jquery-ui-touch-punch.js"></script>
<script type="text/javascript" src="/concrete/js/underscore.js"></script>
<script type="text/javascript" src="/concrete/js/dashboard.js"></script>
<script type="text/javascript" src="/concrete/js/events.js"></script>
<script type="text/javascript" src="/concrete/js/bootstrap/dropdown.js"></script>
<script type="text/javascript" src="/concrete/js/bootstrap/tooltip.js"></script>
<script type="text/javascript" src="/concrete/js/bootstrap/popover.js"></script>
<script type="text/javascript" src="/concrete/js/bootstrap/transition.js"></script>
<script type="text/javascript" src="/concrete/js/bootstrap/alert.js"></script>
<script type="text/javascript" src="/concrete/js/app.js"></script>
<script type="text/javascript" src="/concrete/js/redactor.js"></script>

This is the code from the single page controller:

$this->addFooterItem($hh->javascript('dashboard_6glgallery.js',$this->pkgHandle));

Thanks!!

6glcorp
 
JohntheFish replied on at Permalink Reply
JohntheFish
Why is sequence important to you?
6glcorp replied on at Permalink Reply
6glcorp
Hello!

Solved it already

Because I needed to use some components from core/javascripts like the jQuery UI. But because those assets where included after my package assets I was getting "undefined function" javascript errors.

So to fix it, this is what I did:

From my Single Page Controller Task "edit" I marked the jquery/ui asset group as "already included" so I would get a duplicate function error.
Then I included my jquery-ui.js version from my package assets /packages/PACKAGE_NAME/js/jquery-ui.js


public function edit($gID) {
$r = ResponseAssetGroup::get();
$r->markAssetAsIncluded('javascript', 'jquery/ui');

$uh = Loader::helper('concrete/urls');
$hh = Loader::helper('html');

$pkg=Package::getByHandle($this->pkgHandle);
$uh->getPackageURL($pkg);

$this->addFooterItem($hh->javascript('jquery-ui.js',$this->pkgHandle));
$this->addFooterItem($hh->javascript('file-manager.js',$this->pkgHandle)); <---- This was the file that required the jquery-ui to be included before it

}

So now when I look at the footer items in the source code, the sequence is correct

<script type="text/javascript" src="/packages/PACKAGE_NAME/js/jquery-ui.js"></script>
<script type="text/javascript" src="/packages/PACKAGE_NAME/js/file-manager.js"></script>
<script type="text/javascript">$(function() { $('.ccm-file-manager-upload').concreteFileManager({}); });</script>
<script type="text/javascript" src="/index.php/tools/required/i18n_js"></script>
<script type="text/javascript">$(function() { ConcreteToolbar.start(); });</script>
<script type="text/javascript">$(function() { ConcreteDashboard.start(); });</script>
<script type="text/javascript" src="/concrete/js/events.js"></script>
<script type="text/javascript" src="/concrete/js/underscore.js"></script>
<script type="text/javascript" src="/concrete/js/dynatree.js"></script>
<script type="text/javascript" src="/index.php/tools/required/i18n_dynatree_js"></script>
<script type="text/javascript" src="/concrete/js/app.js"></script>
<script type="text/javascript" src="/concrete/js/sitemap.js"></script>
<script type="text/javascript" src="/concrete/js/jquery-ui-touch-punch.js"></script>
<script type="text/javascript" src="/concrete/js/dashboard.js"></script>
<script type="text/javascript" src="/concrete/js/bootstrap/dropdown.js"></script>
<script type="text/javascript" src="/concrete/js/bootstrap/tooltip.js"></script>
<script type="text/javascript" src="/concrete/js/bootstrap/popover.js"></script>
<script type="text/javascript" src="/concrete/js/bootstrap/transition.js"></script>
<script type="text/javascript" src="/concrete/js/bootstrap/alert.js"></script>
<script type="text/javascript" src="/concrete/js/redactor.js"></script>

Regards,
6glcorp replied on at Permalink Reply
6glcorp
Hello!

Solved it!

Because I needed to use some components from core/javascripts like the
jQuery UI. But because those assets where included after my package assets
I was getting "undefined function" javascript errors.

So to fix it, this is what I did:

From my Single Page Controller Task "edit" I marked the jquery/ui asset
group as "already included" so I would get a duplicate function error.
Then I included my jquery-ui.js version from my package assets
/packages/PACKAGE_NAME/js/jquery-ui.js


public function edit($gID) {
$r = ResponseAssetGroup::get();
$r->markAssetAsIncluded('javascript', 'jquery/ui');

$uh = Loader::helper('concrete/urls');
$hh = Loader::helper('html');

$pkg=Package::getByHandle($this->pkgHandle);
$uh->getPackageURL($pkg);


$this->addFooterItem($hh->javascript('jquery-ui.js',$this->pkgHandle));

$this->addFooterItem($hh->javascript('file-manager.js',$this->pkgHandle));
<---- This was the file that required the jquery-ui to be included before it

}

So now when I look at the footer items in the source code, the sequence is
correct

<script type="text/javascript"
src="/packages/PACKAGE_NAME/js/jquery-ui.js"></script>
<script type="text/javascript"
src="/packages/PACKAGE_NAME/js/file-manager.js"></script>
<script type="text/javascript">$(function() {
$('.ccm-file-manager-upload').concreteFileManager({}); });</script>
<script type="text/javascript"
src="/index.php/tools/required/i18n_js"></script>
<script type="text/javascript">$(function() { ConcreteToolbar.start();
});</script>
<script type="text/javascript">$(function() { ConcreteDashboard.start();
});</script>
<script type="text/javascript" src="/concrete/js/events.js"></script>
<script type="text/javascript" src="/concrete/js/underscore.js"></script>
<script type="text/javascript" src="/concrete/js/dynatree.js"></script>
<script type="text/javascript"
src="/index.php/tools/required/i18n_dynatree_js"></script>
<script type="text/javascript" src="/concrete/js/app.js"></script>
<script type="text/javascript" src="/concrete/js/sitemap.js"></script>
<script type="text/javascript"
src="/concrete/js/jquery-ui-touch-punch.js"></script>
<script type="text/javascript" src="/concrete/js/dashboard.js"></script>
<script type="text/javascript"
src="/concrete/js/bootstrap/dropdown.js"></script>
<script type="text/javascript"
src="/concrete/js/bootstrap/tooltip.js"></script>
<script type="text/javascript"
src="/concrete/js/bootstrap/popover.js"></script>
<script type="text/javascript"
src="/concrete/js/bootstrap/transition.js"></script>
<script type="text/javascript"
src="/concrete/js/bootstrap/alert.js"></script>
<script type="text/javascript" src="/concrete/js/redactor.js"></script>

Regards,