Question

I've created a biography block for concrete5. I need a script to execute only once on pages that contain this block, I can't figure out how to add the script in. The view.php doesn't make sense because I only want it to execute once per page not once per block. Any Ideas?

Edit:

More specifically, I've created a block that has a picture on the left and a bio on the right. I want this to switch every other block so that it has better definition and an easier to follow page layout. I've written a script that will do this:

$(function(){
    jQuery(".bio-block:nth-child(even)").each(function() {
        var id = $(this).attr('id');
        if (id != null){
            jQuery("#"+id+" > .bio-image").before(jQuery("#"+id+" > .bio-text"));
        }
    });
});

But I need it included once after the page has loaded on each page that has bio blocks. There are multiple pages, one page for each team: marketing, sales, management, etc.

Was it helpful?

Solution

concrete5 blocks have a view.js file: blocks/my_block_handle/view.js This will be automatically included once and only once, no matter how many of the same block you have on a page.

OTHER TIPS

Hard to say without knowing more details of your situation, but it sounds like you probably want a single_page instead of a block. See http://www.concrete5.org/documentation/developers/pages/single-pages for more info.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top