Multiple view.php files?
Permalink 1 user found helpful
I have two addons (the calendar and blog packages) that both use my theme's view.php file: the calendar for individual calendar event pages, and the blog for individual blog post pages.
The problem is that I need the two to be different. Is there a way to have one or the other use a different view file?
The reason I need them to be different is below, which you can skip if it's not relevant.
Thanks!
Darrell
-----
Blog posts I'd like to match the rest of the site--with the header, footer and sidebar.
Calendar events, on the other hand, I'm displaying using Tony's popup block, so I need them to have no header, etc. The popup block does give the option of displaying a page area instead of the entire page, but since the calendar event is a single page instead of a page type, it doesn't have an area (using $innerContent instead).
The problem is that I need the two to be different. Is there a way to have one or the other use a different view file?
The reason I need them to be different is below, which you can skip if it's not relevant.
Thanks!
Darrell
-----
Blog posts I'd like to match the rest of the site--with the header, footer and sidebar.
Calendar events, on the other hand, I'm displaying using Tony's popup block, so I need them to have no header, etc. The popup block does give the option of displaying a page area instead of the entire page, but since the calendar event is a single page instead of a page type, it doesn't have an area (using $innerContent instead).
That worked beautifully, thank you!
There's a more elegant version:
(at least for single_pages)
Assume this is our single page: /login
Then you have to create login.php in /single_pages
and the view.php in /themes/mytheme will render it.
Now the cool part:
create a file called login.php in /themes/mytheme and it will be used instead of view.php
Summary: domain.com/login
Single Page: single_pages/login.php
^^ This overrides concrete/single_pages/login.php, but this works with new single_pages too.
Single Page's view: /mytheme/login.php
Now you can use your own headers and footers for your single_page instead of using the ones defined in /mytheme/view.php
My way of doing it is as follows:
/mytheme/elements/page_types/
/default (for default.php in /mytheme)
header.php footer.php
/special (for special.php in /mytheme)
header.php footer.php
/mytheme/elements/single_pages/
/login (for the single_page's view in /mytheme/loginl.php)
header.php footer.php
Of course you need to tell the single page which theme to use in the file
/config/site_theme_paths.php
cheers
Fernandos
(at least for single_pages)
Assume this is our single page: /login
Then you have to create login.php in /single_pages
and the view.php in /themes/mytheme will render it.
Now the cool part:
create a file called login.php in /themes/mytheme and it will be used instead of view.php
Summary: domain.com/login
Single Page: single_pages/login.php
^^ This overrides concrete/single_pages/login.php, but this works with new single_pages too.
Single Page's view: /mytheme/login.php
Now you can use your own headers and footers for your single_page instead of using the ones defined in /mytheme/view.php
My way of doing it is as follows:
/mytheme/elements/page_types/
/default (for default.php in /mytheme)
header.php footer.php
/special (for special.php in /mytheme)
header.php footer.php
/mytheme/elements/single_pages/
/login (for the single_page's view in /mytheme/loginl.php)
header.php footer.php
Of course you need to tell the single page which theme to use in the file
/config/site_theme_paths.php
<?php $v->setThemeByPath('/login',"mytheme"); ?>
cheers
Fernandos
Hi Fernandos,
Is this method still working ?
I try to build custom single_pages on a 5.3.3.1 and I can't make my theme working.
I've (not in /packages):
/single_pages/inscription.php
/themes/my_theme/view.php
When I callhttp://mysite/inscription, view.php is not used ! So everything is broken.
Is it necessary to add /controllers/inscription.php or not ?
I'm trying to solve this for about last hours, but nothing seems to work ...
Is this method still working ?
I try to build custom single_pages on a 5.3.3.1 and I can't make my theme working.
I've (not in /packages):
/single_pages/inscription.php
/themes/my_theme/view.php
When I callhttp://mysite/inscription, view.php is not used ! So everything is broken.
Is it necessary to add /controllers/inscription.php or not ?
I'm trying to solve this for about last hours, but nothing seems to work ...
go to the pages and themes section of your dashboard, then go to the single pages page, then scroll down to the bottom, and activate that url there.
Hi, Im still not quite clear on this.
I had a little trouble working out how your folder structure was working.
Im looking to use multiple view.php because I'm creating a multiple language site and each language uses different headers and footers etc.
So i would create folders within my theme representing different languages such as /en/, /ja/, /cn/ etc., then add header.php and footer.php to them?
Then modify the site_theme_path.php file?
Then when i create single pages i would use the respective vars to point to the different themes?
Thanks a lot
Paul
I had a little trouble working out how your folder structure was working.
Im looking to use multiple view.php because I'm creating a multiple language site and each language uses different headers and footers etc.
So i would create folders within my theme representing different languages such as /en/, /ja/, /cn/ etc., then add header.php and footer.php to them?
Then modify the site_theme_path.php file?
Then when i create single pages i would use the respective vars to point to the different themes?
Thanks a lot
Paul
Create a different theme for each language:
/themes/my_theme_en
/themes/my_theme_ja
etc..
Then use the site_theme_path.php to make your site use the appropriate theme for the pages withing the site tree.
When building out your site, you'd add a page under the home page named "en" and then add all the English content under that page.
/themes/my_theme_en
/themes/my_theme_ja
etc..
Then use the site_theme_path.php to make your site use the appropriate theme for the pages withing the site tree.
When building out your site, you'd add a page under the home page named "en" and then add all the English content under that page.
Hello ryan, I have this need too, to have more than 1 view.php for a single multilingual website.
The need is to have multiple single page wrappers. That is; view.php needs to be different for different languages.
For english - theme1
For Chinese - theme1-chineseDummyTheme
Now how can i make both themes to be active for a single site with single site map.
Eagerly waiting. Thanks.
The need is to have multiple single page wrappers. That is; view.php needs to be different for different languages.
For english - theme1
For Chinese - theme1-chineseDummyTheme
Now how can i make both themes to be active for a single site with single site map.
Eagerly waiting. Thanks.
as Ryan said, Activate the Theme you want for the pages that won't have that theme (other language) pop open /config/site_theme_paths.php
Create a new theme, call it no_theme or something, make it have a default.php and a view.php the way you want it, you can even hard-code your css paths to come from the other theme if you want. Make sure it's installed in the dashboard.
Then in your /config/site_theme_paths.php file, you'll see examples of setting a theme by path:
By the way, in the calendar block, events aren't single pages, they're page types, so you should be able to set the theme in the page type defaults view.