Adding new layout to existing component
- koyan
- Joomla! Enthusiast
- Posts: 188
- Joined: Tue Aug 23, 2005 7:17 pm
- Contact:
Adding new layout to existing component
Hallo all,
Starting from the request that is described in Standard Section Layout and category list - Links and in section list > category blog, I have created a new layout, for the com_content\views\section\tmpl
The new view shows the categories of a section, as a blog, and not as a list.
In order to do that I modified the default.php and default.xml (the second one in order to add the new parameters).
It all works well when I have them named default.php and default.xml.
The question is: is there any way that I can have my new layout as an option in the "Select Menu Item Type" in administration?
I want to add it as a new option, so that it does not override the default one, so that I can share it with others.
My first thought was to rename the default.php and default.xml to files with new names (aka blog_category.php and blog_category.xml) and change the descriptions in the xml file. I did that, but now how do I tell joomla to give this view as well as an option?
Starting from the request that is described in Standard Section Layout and category list - Links and in section list > category blog, I have created a new layout, for the com_content\views\section\tmpl
The new view shows the categories of a section, as a blog, and not as a list.
In order to do that I modified the default.php and default.xml (the second one in order to add the new parameters).
It all works well when I have them named default.php and default.xml.
The question is: is there any way that I can have my new layout as an option in the "Select Menu Item Type" in administration?
I want to add it as a new option, so that it does not override the default one, so that I can share it with others.
My first thought was to rename the default.php and default.xml to files with new names (aka blog_category.php and blog_category.xml) and change the descriptions in the xml file. I did that, but now how do I tell joomla to give this view as well as an option?
You do not have the required permissions to view the files attached to this post.
- deejson
- Joomla! Apprentice
- Posts: 9
- Joined: Wed Sep 05, 2007 9:42 pm
- Location: Seattle, WA
Re: Adding new layout to existing component
I would love to know the answer to this as well....anyone?
-
- Joomla! Fledgling
- Posts: 1
- Joined: Fri Oct 10, 2008 1:50 pm
Re: Adding new layout to existing component
This post is a bit old, but an answer would have saved me some reverse engineering time.
To add a new layout for a specific vew (such as article, archive, category, section or frontpage), create a new template in
For example, if you define an accordion template for the categories, it should be named like this :
/components/com_content/views/categories/tmpl/accordion.php
And that's all. Of course, if you need to define specific parameters, you need to create an "accordion.xml" file in the same folder. Take a look at the existing layout for a start.
I'm not fond of adding files to the tree of an official component, as it will make updates more complicated, so if somebody has a better solution, I'd be glad to know it.
To add a new layout for a specific vew (such as article, archive, category, section or frontpage), create a new template in
Code: Select all
/components/com_content/views/<view>/tmpl/
/components/com_content/views/categories/tmpl/accordion.php
And that's all. Of course, if you need to define specific parameters, you need to create an "accordion.xml" file in the same folder. Take a look at the existing layout for a start.
I'm not fond of adding files to the tree of an official component, as it will make updates more complicated, so if somebody has a better solution, I'd be glad to know it.
-
- Joomla! Apprentice
- Posts: 6
- Joined: Fri Mar 20, 2009 12:55 pm
Re: Adding new layout to existing component
Hi Koyan, I'm very new in Joomla and I was looking for the same same solution!
Have you already shared your layout somewhere?
Have you already shared your layout somewhere?
"help will save the world!"
- ludder
- Joomla! Fledgling
- Posts: 3
- Joined: Wed Feb 03, 2010 9:06 am
Re: Adding new layout to existing component
I'm still curious to know if this is possible without hacking the core element.
-
- Joomla! Explorer
- Posts: 325
- Joined: Fri Feb 26, 2010 4:01 pm
Re: Adding new layout to existing component
You can override an existing layout using the method that is described at: http://developer.joomla.org/tutorials/1 ... oomla.html . This method confines your changes to your template's directory so you don't have to make any changes to the core file system.
However, if you need to have multiple layouts, then the method in the tutorial doesn't apply because it overrides the existing layout but doesn't create a whole new layout.
However, if you need to have multiple layouts, then the method in the tutorial doesn't apply because it overrides the existing layout but doesn't create a whole new layout.
Erich
www.bectin.com
www.bectin.com
- davide.taddei
- Joomla! Intern
- Posts: 61
- Joined: Tue Jan 22, 2008 8:01 pm
- Contact:
Re: Adding new layout to existing component
Hello, I think it's good solution to simply ad a new layout file to the tmpl folder of the view because it's in any case upgrade-safe.
By the way I'm triying to challenge a new problem: i would like to add a new view to the contacts component.
I would like to ad a page with a list of the categories of the contacts, so what I'm triying to do:
1) add a new folder name "CATEGORIES" to the component/com_contact/views/ directory;
2) create a new view.html.php file;
3) create a tmpl folder;
4) add a default.php file;
In the backend I can associate a new link in the menu with the "CATEGORIES" view, but when I load the page it returns an error, do you have any idea wich is the problem?
By the way I'm triying to challenge a new problem: i would like to add a new view to the contacts component.
I would like to ad a page with a list of the categories of the contacts, so what I'm triying to do:
1) add a new folder name "CATEGORIES" to the component/com_contact/views/ directory;
2) create a new view.html.php file;
3) create a tmpl folder;
4) add a default.php file;
In the backend I can associate a new link in the menu with the "CATEGORIES" view, but when I load the page it returns an error, do you have any idea wich is the problem?
Davide Taddei
http://davidetaddei.[URL banned].com
http://davidetaddei.[URL banned].com
- davide.taddei
- Joomla! Intern
- Posts: 61
- Joined: Tue Jan 22, 2008 8:01 pm
- Contact:
Re: Adding new layout to existing component
Well.. I solved the problem by myself :-)
The controller of in the com_contact component loads a model with the same name of the view, so it need to add a categories.php file in the folder component/com_contact/moddels/ directory;
hope it will be useful for someone ;-)
The controller of in the com_contact component loads a model with the same name of the view, so it need to add a categories.php file in the folder component/com_contact/moddels/ directory;
hope it will be useful for someone ;-)
Davide Taddei
http://davidetaddei.[URL banned].com
http://davidetaddei.[URL banned].com
- piotr_cz
- Joomla! Enthusiast
- Posts: 164
- Joined: Mon Mar 30, 2009 11:27 am
- Location: Europe
- Contact:
Re: Adding new layout to existing component
Hey.
In case it would help somebody: some of the model logic is restricted to specified layouts.
For example: pagination in the category view is hardcoded in the model to work only with blog layout so if you want to create new layout with pagination, you have to include the logic in the view itself.
Or create own component.
In case it would help somebody: some of the model logic is restricted to specified layouts.
For example: pagination in the category view is hardcoded in the model to work only with blog layout so if you want to create new layout with pagination, you have to include the logic in the view itself.
Or create own component.
- chongkan
- Joomla! Fledgling
- Posts: 4
- Joined: Tue Aug 26, 2008 4:33 am
- Contact:
Re: Adding new layout to existing component
nniico's answer worked at the first time for me on 1.5.x and, if you follow nniico's method, instead of:
+davide.taddei wrote:
1) add a new folder name "CATEGORIES" to the component/com_contact/views/ directory;
2) create a new view.html.php file;
3) create a tmpl folder;
4) add a default.php file;
Then you can use the existing view and model and just add a different one if you really need to.davide.taddei wrote:Well.. I solved the problem by myself :-)
The controller of in the com_contact component loads a model with the same name of the view, so it need to add a categories.php file in the folder component/com_contact/moddels/ directory;
hope it will be useful for someone ;-)
Saludos,
--
Chongkan - Likan Development - Diseño Web y Desarrollo a la medida - http://www.likandevelopment.com
--
Chongkan - Likan Development - Diseño Web y Desarrollo a la medida - http://www.likandevelopment.com