Two Custom Templates on same page...
Permalink
On the home page of a site I'm working on I have two news lists from two separate news pages elsewhere on my site.
I need to use separate templates for both, but when it do, the two page lists keep overriding CSS styles from each other. How can I have it so both page lists are completely separate? Also, I have edited the View.php files to be slightly different, but they are also overriding.
Is there are way to rename the view.css file for each template?
I need to use separate templates for both, but when it do, the two page lists keep overriding CSS styles from each other. How can I have it so both page lists are completely separate? Also, I have edited the View.php files to be slightly different, but they are also overriding.
Is there are way to rename the view.css file for each template?
you need to change the view, and the css so they don't interfere
I'm sorry, I'm not sure what you mean...
Is there a way to rename the view.css file in each template?
Is there a way to rename the view.css file in each template?
Hi Dave,
the easiest way, would be to wrap each view.php in a div with a specific id - for example, in your first view.php you could have <div id="newslist1"> and in your second, <div id="newslist2">. And then, just using the one view.css, you can define rules for each, by referencing the id's - eg. #newsitem1 p { color: black; } and #newsitem2 p { color: blue; }.
Make sense?
Oh, and when I say "each view.php" obviously you only have one file called view.php, but in your templates/ folder, you can add files called newslist1.php and newslist2.php and then apply the relevant one by selecting the template on your block.
Jon
the easiest way, would be to wrap each view.php in a div with a specific id - for example, in your first view.php you could have <div id="newslist1"> and in your second, <div id="newslist2">. And then, just using the one view.css, you can define rules for each, by referencing the id's - eg. #newsitem1 p { color: black; } and #newsitem2 p { color: blue; }.
Make sense?
Oh, and when I say "each view.php" obviously you only have one file called view.php, but in your templates/ folder, you can add files called newslist1.php and newslist2.php and then apply the relevant one by selecting the template on your block.
Jon
For the view.css files I have made the names of each element different by changing the class names: eg. .newsflash is now .newsflash1
.newsflashcontain is now .newsflashcontain1 etc. I have also changed the class names in the view.php file as well. This works to prevent CSS overriding.
However, the view.php files are still overriding. I have added an AddThis section to the end of one news list. I don't want on the other news list. Not sure how I can make the view.php files independent of each other. I have tried wrapping them with different div id's (below) but it doesn't seem to work. When I wrap them in a different id, do I need to change the name of the file from view.php to someting else to make it work?
.newsflashcontain is now .newsflashcontain1 etc. I have also changed the class names in the view.php file as well. This works to prevent CSS overriding.
However, the view.php files are still overriding. I have added an AddThis section to the end of one news list. I don't want on the other news list. Not sure how I can make the view.php files independent of each other. I have tried wrapping them with different div id's (below) but it doesn't seem to work. When I wrap them in a different id, do I need to change the name of the file from view.php to someting else to make it work?
As I said, you have to render different templates. You're using one block called news_list correct? Inside the block folder, you have a view.php file which is your default template. To use a different template, you need to create a second file and place it inside a templates folder (/blocks/news_list/templates/myTemplate.php). If you're including your block using code, and not by clicking "add block" in the CMS as your code snippet above appears to imply, then you need to add the line in order to use the correct template.
Jon
$bt->render('myTemplate');
Jon
I'm adding the block by just clicking Add Block in the CMS. The Block which I have various templates for is called News_List. I have 4 different templates. Only two of them ever appear together on the same page. I am choosing the different templates within the CMS. I'm still not sure what you are explaining though... sorry
Well, it kinda sounds like you're doing everything correct... You don't happen to have a live URL I can see do you??
If not, can you just list exactly what files you have inside /blocks/news_list/templates/ please??
Jon
If not, can you just list exactly what files you have inside /blocks/news_list/templates/ please??
Jon
Hi Jon, I've just sent you a PM.
I have tried having each template as just a PHP file inside the templates folder. eg. news.php, small_news.php etc and having only one view.css... The view.php files are still interfering with each other. Can anybody help me on this? I have spent the last two evenings trying to figure it out... Please.
Did this ever get worked out?
I am having same issues..
I am having same issues..