Embedding a block element in a theme, css and js not loaded.
Permalink
I'm trying to add a block element to the header of my theme.
The block is located here
ROOT->blocks-><blockname> and the block-template is
ROOT->blocks-><blockname>->templates-><template_name>-> files: view.php, view.js, view.css
In my themes header.php I've added this code:
The css and js are not loaded.
What am I doing wrong?
If I add the block-element to the page through the admin interface, the js and css is loaded as expected.
-
Morten Sjøgren
Developer at AdMad
The block is located here
ROOT->blocks-><blockname> and the block-template is
ROOT->blocks-><blockname>->templates-><template_name>-> files: view.php, view.js, view.css
In my themes header.php I've added this code:
$bt = BlockType::getByHandle( '<block_name>' ); $bt->controller->displayPages = 'top'; $bt->controller->orderBy = 'display_asc'; $bt->controller->displaySubPages = 'all'; $bt->controller->displaySubPageLevels = 'all'; $bt->render( "templates/<template_name>/view" );
The css and js are not loaded.
What am I doing wrong?
If I add the block-element to the page through the admin interface, the js and css is loaded as expected.
-
Morten Sjøgren
Developer at AdMad
The reason I use
Is because that
Doesn't work, this is because that "templates/<template_name>" becomes "templates/<template_name>.php" in BlockView::render which isn't a dir.
$bt->render( "templates/<template_name>/view" );
Is because that
$bt->render( "templates/<template_name>" );
Doesn't work, this is because that "templates/<template_name>" becomes "templates/<template_name>.php" in BlockView::render which isn't a dir.
With Concrete5.5 we have a GlobalArea that makes that I did in my initial post unnecessary.
Simply add a GlobalArea to your theme and add the block-element to it through normal editing.
Much easier and much cleaner, thanks for adding it.
Simply add a GlobalArea to your theme and add the block-element to it through normal editing.
Much easier and much cleaner, thanks for adding it.
Should have been
ROOT->blocks->BLOCK_NAME and the block-template is
ROOT->blocks->BLOCK_NAME->templates->TEMPLATE_NAME-> files: view.php, view.js, view.css