Broken Image Slider Block

I am using the core image slider block on my site. It is only showing the first slide and It does not work unless I login to the site. Does anyone know how to fix this?

Sounds like your missing some jQuery in your theme
What theme are you using?

1 Like

No theme, just made a template with html/css. EDIT: actually I guess it would be called a custom theme then. Do I need to write some jquery to make it work? Why does it work when I am logged in?

When logged in the CMS adds jQuery to help with it’s functionality.

You can load the core jQuery into your theme using the following.

1 Like

By the core jQuery do you mean the jQuery library itself or the jQuery used by the concrete core?

Assuming you mean the jquery used by the core, do I need to load the library itself into my theme first? How do I find the correct jquery file used by the core for that block? Please bear in mind that I’m still new to development.

So the link tells you how to do this.

Take a look at the default theme files.

Look at the controller.php and then the page_theme.php

You are looking to load the jQuery library into your theme.

1 Like

Hi TM, I managed to get it to work by adding this script tag in the page: <script src="..\concrete\js\jquery.js"></script>. Thanks for the help. I really love how friendly and helpful this community is.

The issue with this is it might cause problems when you are logged in as you will have a 2 Jquery calls and they can conflict

Just drop this into your page_theme.php inside the

class PageTheme extends Theme implements ThemeProviderInterface
{

so

class PageTheme extends Theme implements ThemeProviderInterface
{
  public function registerAssets()
    {
        $this->requireAsset('font-awesome'); //gives you the core font-asewome 
        $this->requireAsset('jquery'); //gives you the core jquery
    }

1 Like

Is the following the correct file to place it in? concrete\themes\concrete\page_theme.php

I don’t have a page_theme.php in my theme directory, only full.php and different page templates + assets.

No, you need to have this file in your theme.

you can just add the page_theme.php file then add this code.

<?php
namespace Concrete\Theme\Nameofyourtheme; // this needs to be the name of your theme in camel case  so my_theme becomes MyTheme or mytheme becomes Mytheme

use Concrete\Core\Area\Layout\Preset\Provider\ThemeProviderInterface;
use Concrete\Core\Page\Theme\Theme;

class PageTheme extends Theme implements ThemeProviderInterface {

    public function registerAssets()
    {
        $this->requireAsset('font-awesome'); //gives you the core font-asewome 
        $this->requireAsset('jquery'); //gives you the core jquery
    }

}

do I just add it in the main directory of the theme? Do I need anything else in the file? I tried doing what you said with no result.

Ok is the theme in the application> theme folder and if so what is the name of you folder?

Yes, I called it soccer-theme as I’m making it for a soccer club. I replaced “Nameofyourtheme” in the code you provided with “SoccerTheme”. I created a file named page_theme.php in the soccer-theme directory and placed the code in it.

Then it should work.

I can take a look for you if you message me some details.

Sure, what do you need? I can’t seem to find how to dm on the forum.

Drop me an email with the FTP details.

email removed

You might have had better luck with the namespacing if your theme was called soccer_theme (note the underscore)

1 Like

Great spot I didn’t see that.