What's the process of embedding a block in my theme

Permalink
Hi there, Like the title what's the thought process behind this.
It seems every example of a block I come across looks different.

I've got the auto-nav on fine as there's plenty of examples but how do I work this out for any block?

Specifically I want to add that scrolling images block that's on the sample site in my theme but I can't find a shred of help on that one.

Can someone point me in the right direction?

 
CodeOtaku replied on at Permalink Reply
CodeOtaku
I am very new to C5 development, but I think you use code like this:
<?php 
$block = Block::getByName('Name_of_Block');  
if( $block && $block->bID ) $block->display();
?>


And I think you want to use the Slide Show block. Maybe check out the source code of the theme you mentioned to see what they did.
Jack replied on at Permalink Reply
In the default theme the .php files just contain the code for editable areas. It appears they have just added the slideshow to every page of the theme.
jaredquinn replied on at Permalink Reply
jaredquinn
For the slideshow block:

$bt_ss = BlockType::getByHandle('slideshow');
$bt_ss->controller->defaultFadeDuration = 10;
$bt_ss->controller->defaultDuration = 10;
$bt_ss->controller->duration = 10;
$bt_ss->controller->minHeight = 300;
$bt_ss->controller->fsID = 3;
$bt_ss->controller->type = 'FILESET'; // or CUSTOM
$bt_ss->controller->playback = 'RANDOM'; // or ORDER,  RANDOM-SET
$bt_ss->controller->loadBlockInformation();
$bt_ss->render('view');


If you want to use a custom slideshow, you would have to build your own array of images, but you can get some guidance on that from the block controller.
hursey013 replied on at Permalink Reply
hursey013
Another option thats a little less complicated is to create a global scrapbook and and the block to it - that way you can modify it with all the settings you want using the c5 gui. You can then bring that scrapbook item into your template using some code like this:
<?php
               $b = Block::getByName('My Block Name');
               $b->display();
               ?>
Jack replied on at Permalink Reply
Please see my other comment in reply to parent with this issue. I like this way but same problem.
Jack replied on at Permalink Reply
I've noticed a problem.
If I do the above or if I do this

$block = Block::getByName('Banner_Slideshow');  
if( $block && $block->bID ) $block->display();


The block goes in fine, however the CSS for the block doesn't get included in the head. It's in the HTML but the CSS file .SlieImgWrap is supposed to have ect. isn't included.

It is only added if I add a block through to UI on an editable area and I have to do that for every page. Not ideal.

What have I missed