Custom blocks and several css files
Permalink
Hi.
I am experimenting with custom block templates.
I have made 1 test block-templates to one block.
Everything works.
But I would like to connect 2 different css files to 2 templates so I don't have to hardcode the css in the template (same css classes and IDs in all 3 templates, just different values).
Is this possible?
Structure I would like:
ROOT/block/blockname/
view.css
view.php
ROOT/block/blockname/templates/
theme1.css
theme1.php
theme2.css
theme2.php
I am experimenting with custom block templates.
I have made 1 test block-templates to one block.
Everything works.
But I would like to connect 2 different css files to 2 templates so I don't have to hardcode the css in the template (same css classes and IDs in all 3 templates, just different values).
Is this possible?
Structure I would like:
ROOT/block/blockname/
view.css
view.php
ROOT/block/blockname/templates/
theme1.css
theme1.php
theme2.css
theme2.php
I have tried but get the following error when I choose the custom template in the menu.
"Custom Template:
There are no custom templates available."
*Update
Before I posted the first time I tried to make 2 folders within the templates folder but I got a script error since there was no file to load.
When I tried again now but changed the filenames to view there was no problems anymore!
So now it work!
And I will check out your div suggestion to be able to have 2 different designs on the same page.
"Custom Template:
There are no custom templates available."
*Update
Before I posted the first time I tried to make 2 folders within the templates folder but I got a script error since there was no file to load.
When I tried again now but changed the filenames to view there was no problems anymore!
So now it work!
And I will check out your div suggestion to be able to have 2 different designs on the same page.
in case my answer was helpfull, please mark my response as best answer. thanks!
Pretty sure the idea is to mark other people's answers as 'best answer', not your own.
What might be a nice addition to the forum is a voting system, on whether the reply solved the issue at hand. Kind of like a success rate vote or "this worked for me button". I like best answer, as well as I think both could work in tandem very nicely, as it would allow everyone to vote not just the threads author. This way people that agree with whats been said could also say its worked for them as a vote from experience, and users having the same issue in the future are more likely to find the answer, while also giving the threads author the ability to mark what solved their exact issue.
Just a thought.
Just a thought.
The Default View:
blocks/yourblock/controller.php
blocks/yourblock/view.php
blocks/yourblock/view.css
Aditional Template One:
blocks/yourblock/template_one/view.php
blocks/yourblock/template_one/view.css
Aditional Template Two:
blocks/yourblock/template_two/view.php
blocks/yourblock/template_two/view.css
In case you need to place your block multiple times on the same page and with different templates applied, than you need to wrap your templates with different css-selectors as well.
blocks/yourblock/template_one/view.php
blocks/yourblock/template_one/view.css
#template-one .foo { }