Hardcode custom block
Permalink
Hi guys,
i'm trying to hardcode my carousel block, this block is created and work fine.
I create it with :
-http://sorgalla.com/projects/jcarousel/...
and
-http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lig...
This is the code I got to hardcoding :
The block appear, and it use js/css, so in my header of my theme I put this :
Now, all my .css works.
My lightbox work too.
But ! My carousel doesn't appear normally... I think the problem is on calling my script, but i'm not sure.
i'm trying to hardcode my carousel block, this block is created and work fine.
I create it with :
-http://sorgalla.com/projects/jcarousel/...
and
-http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lig...
This is the code I got to hardcoding :
$bt_carrousel = BlockType::getByHandle('carrousel'); $bt_carrousel->controller->fsID = 6; $bt_carrousel->controller->waitingTime = 5; $bt_carrousel->controller->animationLoop = 'circular' ; $bt_carrousel->controller->numberScroll = 'horizontal' ; $bt_carrousel->controller->height = 140 ; $bt_carrousel->controller->width = 140 ; $bt_carrousel->controller->visible = 3 ; $bt_carrousel->controller->activeButton = '<div></div>'; $bt_carrousel->controller->horizontal = 'true'; $bt_carrousel->controller->social = 'true'; $bt_carrousel->controller->theme = 'dark_rounded' ; $bt_carrousel->controller->opacity = 0.8 ; $bt_carrousel->controller->title = 'true'; $bt_carrousel->render('view');
The block appear, and it use js/css, so in my header of my theme I put this :
<link rel="stylesheet" type="text/css" href="/.../concrete5/packages/carrousel/blocks/carrousel/css/carrousel.css" /> <link rel="stylesheet" type="text/css" href="/.../concrete5/packages/carrousel/blocks/carrousel/css/skin.css" /> <link rel="stylesheet" type="text/css" href="/.../concrete5/packages/carrousel/blocks/carrousel/css/lightBox.css" /> <script src="/.../concrete5/packages/carrousel/blocks/carrousel/js/jquery.jcarousel.js"></script> <script src="/.../concrete5/packages/carrousel/blocks/carrousel/js/jquery.lightbox.js"></script>
Now, all my .css works.
My lightbox work too.
But ! My carousel doesn't appear normally... I think the problem is on calling my script, but i'm not sure.
I tried to use GlobalArea, really nice !
Just a problem, if on my web site, there is a lot of pages (for example 30 pages). Not really easy to put this on all pages...
Do i'm wrong ? There is a solution for put on all pages my block, instead of go on all pages and add GlobalArea ?
Just a problem, if on my web site, there is a lot of pages (for example 30 pages). Not really easy to put this on all pages...
Do i'm wrong ? There is a solution for put on all pages my block, instead of go on all pages and add GlobalArea ?
If you have a GlobalArea in your header, the blocks added to that GlobalArea will be shown on all pages with that header.
I think the best example of this is to look at the default theme "Greek Yogurt" located in "/concrete/themes/greek_yogurt/" in the file "concrete/themes/greek_yogurt/elements/header.php"
This is how they add a GlobalArea which contains the site-name:
You said in your original post that you were new, so you might not know the difference between an Area and a GlobalArea.
An Area is place there you can add blocks to a specific page.
A GlobalArea almost the same as an Area but can be shared between pages.
Using Greek Yogurt as an example, it mean that all pages has their own copy of Area with the name "Header Image" and can be alterned individually per page. But those same pages will all share the GlobalArea named "Header Nav" and any changes you make to that GlobalArea will apply to all pages.
I think the best example of this is to look at the default theme "Greek Yogurt" located in "/concrete/themes/greek_yogurt/" in the file "concrete/themes/greek_yogurt/elements/header.php"
This is how they add a GlobalArea which contains the site-name:
$a = new GlobalArea('Site Name'); $a->display();
You said in your original post that you were new, so you might not know the difference between an Area and a GlobalArea.
An Area is place there you can add blocks to a specific page.
A GlobalArea almost the same as an Area but can be shared between pages.
Using Greek Yogurt as an example, it mean that all pages has their own copy of Area with the name "Header Image" and can be alterned individually per page. But those same pages will all share the GlobalArea named "Header Nav" and any changes you make to that GlobalArea will apply to all pages.
An alternative solution to hardcoding an existing block is to :
Put all of my code HTML on my page, with in header the style CSS and in footer my javascript.
If for someone else, that don't work, it's a good solution, but there is two others solutions.
First,
Like AdMad say, Global Areas.
Second,
You can use scrapbook.
Put all of my code HTML on my page, with in header the style CSS and in footer my javascript.
If for someone else, that don't work, it's a good solution, but there is two others solutions.
First,
Like AdMad say, Global Areas.
Second,
You can use scrapbook.
It's not hardcoding it, but if you have a GlobalArea in your header in your theme, it will appear on all pages.
I tried to hardcode a block in our theme in concrete 5.4.2.2, but it didn't get initialized right and it couldn't find the custom theme that we wanted to use. Using a GlobalArea solved the problem for us.