XF 2.0 Rotating Photo Banner not functioning

craigForo

Active member
I have a rotating photo banner on my site, It worked fine in 1.5 but I cannot seem to get it functioning in 2.

I have it in an advertising module, Forum overview: Top
 
I think its something else. This is a stand-alone application. The code in the forum overview calls on it to display. Unless there is something in xen2.0 that is blocking js code, this should be functioning.
 
We don't manipulate the code you've entered, so you should look at the browser console to identify any issues. It's quite possible your JS has external dependencies that aren't available (either any longer or at that time in the rendering -- all of our JS is included at the bottom of the HTML).
 
I can see a JS error saying jQuery is undefined. The script requires jQuery library but it is loaded later on the page. So I guess in the new Xenforo version, they move the inclusion of the jQuery library from the top of the page to the bottom. This causes all the dependent scripts to break if they are included before jQuery library is included.

Is there a work around?
 
So where in the template would the 2 <script> tags that need to be placed, go? Or I don't know if Xenforo has template code like in vB (see code below) where if you put this code anywhere in any template, the JS file will be included at the bottom of the page.

{vb:js js/whatever.js}
 
How can I get the below (second group of code) to go under the code you assisted earlier;

You helped me with this
Code:
<xf:js src="/banner_files/jquery.banner-rotator.min.js" />

I need to add the below to be under it, on line 1732:
Code:
<script type="text/javascript">
    $(window).on("load", function (e) {
           $("#JQBannerRotator1").fdBannerRotator({keyboardEnabled:true,bannerAutoHeight:false,slideWidth:620,slideHeight:250,slideScaleMode:"none",slideTransition:{type:"fade",duration:300,easing:"easeOutQuad"},slideDuration:3000,slideAutoplay:true,slidePauseOnHover:true,timerPosition:"top",timerVisible:true,captionAnimationSpeed:500,captionAnimationEasing:"easeOutQuad",controlDirectionEnbled:true,controlDirectionHide:true,controlPlayEnabled:true,navigationEnabled:true,navigationPositionMargin:0,navigationAlign:"center",navigationThumbEnabled:true,navigationThumbServerScipt:"",navigationThumbSearch:".jpg",navigationThumbReplace:"_thumb.jpg",navigationThumbWidth:150,navigationThumbHeight:65,navigationThumbAnimationSpeed:200,navigationThumbAnimationEasing:"easeOutQuad"});
    });  
</script>
 
Like this?
Code:
<xf:js type="text/javascript">
    $(window).on("load", function (e) {
           $("#JQBannerRotator1").fdBannerRotator({keyboardEnabled:true,bannerAutoHeight:false,slideWidth:620,slideHeight:250,slideScaleMode:"none",slideTransition:{type:"fade",duration:300,easing:"easeOutQuad"},slideDuration:3000,slideAutoplay:true,slidePauseOnHover:true,timerPosition:"top",timerVisible:true,captionAnimationSpeed:500,captionAnimationEasing:"easeOutQuad",controlDirectionEnbled:true,controlDirectionHide:true,controlPlayEnabled:true,navigationEnabled:true,navigationPositionMargin:0,navigationAlign:"center",navigationThumbEnabled:true,navigationThumbServerScipt:"",navigationThumbSearch:".jpg",navigationThumbReplace:"_thumb.jpg",navigationThumbWidth:150,navigationThumbHeight:65,navigationThumbAnimationSpeed:200,navigationThumbAnimationEasing:"easeOutQuad"});
    });  
</xf:js>

It returns an error
 
Literally just <xf:js> as the opening tag -- no type. If you're still getting an error, I need to know the error message.
 
I have this;
Code:
<xf:js ="text/javascript">
    $(window).on("load", function (e) {
           $("#JQBannerRotator1").fdBannerRotator({keyboardEnabled:true,bannerAutoHeight:false,slideWidth:620,slideHeight:250,slideScaleMode:"none",slideTransition:{type:"fade",duration:300,easing:"easeOutQuad"},slideDuration:3000,slideAutoplay:true,slidePauseOnHover:true,timerPosition:"top",timerVisible:true,captionAnimationSpeed:500,captionAnimationEasing:"easeOutQuad",controlDirectionEnbled:true,controlDirectionHide:true,controlPlayEnabled:true,navigationEnabled:true,navigationPositionMargin:0,navigationAlign:"center",navigationThumbEnabled:true,navigationThumbServerScipt:"",navigationThumbSearch:".jpg",navigationThumbReplace:"_thumb.jpg",navigationThumbWidth:150,navigationThumbHeight:65,navigationThumbAnimationSpeed:200,navigationThumbAnimationEasing:"easeOutQuad"});
    });   
</xf:js>

And it returns this;
Code:
XF\PrintableException: Line 17: Syntax error in src/XF/Mvc/Entity/Entity.php at line 1083

    XF\Mvc\Entity\Entity->save() in src/XF/Service/Advertising/Writer.php at line 84
    XF\Service\Advertising\Writer->write() in src/XF/Repository/Advertising.php at line 70
    XF\Repository\Advertising->writeAdsTemplate() in src/XF/Entity/Advertising.php at line 37
    XF\Entity\Advertising->XF\Entity\{closure}() in src/XF.php at line 244
    XF::triggerRunOnce() in src/XF/Mvc/Dispatcher.php at line 137
    XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 41
    XF\Mvc\Dispatcher->run() in src/XF/App.php at line 1880
    XF\App->run() in src/XF.php at line 328
    XF::runApp() in admin.php at line 13
 
Back
Top Bottom