kirgy
kirgy

Reputation: 1607

Editing Block in Concrete5

I'm trying to edit a standard block in Concrete5 - the image_slider block to modify it's transition speed.

In theory this should be really simple; changing the speed value located in:

..concrete/blocks/image_slider/view.js

So I copied this file to

..application/blocks/image_slider/view.js 

and changed the value.

At this point, the slider does execute the function, but for some reason the javascript is not operating as expected - its executing (I added a console.log for testing), but the slider no longer slides and the navigation arrows are missing. Inspecting the slider no class changes are happening.

I can't find any information on extending the view.js in my own application, and whatever I try doesn't seem to work.

The block I'm using can be found on their github, I'm running Concrete5 v5.7.5.2: https://github.com/concrete5/concrete5/tree/5.7.5.2/web/concrete/blocks/image_slider

Upvotes: 1

Views: 297

Answers (2)

Marc Bosse
Marc Bosse

Reputation: 401

When you're overriding a core Concrete5 block, I find it's good practice to copy over the entire blocks folder from the Concrete folder to your Application folder.

Normally this speed change can be handled in the Image Slider form, while it's being added to your page. If you're trying to update the speeds base value you're better off editing the default value passed in the image slider form during setup -> application\blocks\image_slider\form_setup_html.php (for me it's line 298).

<?php
echo $form->number($view->field('speed'),
    $speed ? $speed : 500, 
    array(
        'min' => '1',
        'max' => '99999'
    ))?>

<span class="input-group-addon"><?php echo t('ms'); ?></span>

Updating '500' to your desired base speed in milliseconds should take care of it for you!

Upvotes: 2

Daniel Gasser
Daniel Gasser

Reputation: 5133

The overriding you're doing is correct, anyway in the latest version (5.7.5.6) there is no view.js in concrete/blocks/image_slider.

So, to get it running you'll need to override the view.php into (application/blocks/image_slider/view.php).

The options are handled in the view.php starting at line 9:

<script>
$(document).ready(function(){
    $(function () {
        $("#ccm-image-slider-<?php echo $bID ?>").responsiveSlides({
            prevText: "",   // String: Text for the "previous" button
            nextText: "",
            <?php if($navigationType == 0) { ?>
            nav:true,
            <?php } else { ?>
            pager: true,
            <?php } ?>
            <?php if ($timeout) { echo "timeout: $timeout,"; } ?>
            <?php if ($speed) { echo "speed: $speed,"; } ?>
            <?php if ($pause) { echo "pause: true,"; } ?>
            <?php if ($noAnimate) { echo "auto: false,"; } ?>
            // transition
            transition: //your code here
        });
    });
});
</script>

And, as @tofraser said, disable all caches during development.

Upvotes: 1

Related Questions