The Joomla! Forum ™





Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
PostPosted: Wed Mar 19, 2008 9:35 am 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Tue Aug 23, 2005 7:17 pm
Posts: 185
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?


You do not have the required permissions to view the files attached to this post.

_________________
http://www.sintagespareas.gr :  Recipes in Greek


Top
 Profile  
 
PostPosted: Wed Jun 18, 2008 2:24 am 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Sep 05, 2007 9:42 pm
Posts: 9
Location: Seattle, WA
I would love to know the answer to this as well....anyone?


Top
 Profile  
 
PostPosted: Fri Oct 10, 2008 2:50 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Fri Oct 10, 2008 1:50 pm
Posts: 1
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
Code:
/components/com_content/views/<view>/tmpl/


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.


Top
 Profile  
 
PostPosted: Fri Mar 20, 2009 1:04 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Mar 20, 2009 12:55 pm
Posts: 6
Hi Koyan, I'm very new in Joomla and I was looking for the same same solution!

Have you already shared your layout somewhere?

_________________
"help will save the world!"


Top
 Profile  
 
PostPosted: Wed Mar 31, 2010 2:54 pm 
User avatar
Joomla! Fledgling
Joomla! Fledgling

Joined: Wed Feb 03, 2010 9:06 am
Posts: 3
I'm still curious to know if this is possible without hacking the core element.


Top
 Profile  
 
PostPosted: Tue Apr 06, 2010 4:22 pm 
Joomla! Explorer
Joomla! Explorer

Joined: Fri Feb 26, 2010 4:01 pm
Posts: 291
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.

_________________
Erich
www.bectin.com


Top
 Profile  
 
PostPosted: Wed Jul 28, 2010 11:10 am 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Tue Jan 22, 2008 8:01 pm
Posts: 61
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?

_________________
Davide Taddei
http://davidetaddei.[URL banned].com


Top
 Profile  
 
PostPosted: Wed Jul 28, 2010 11:20 am 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Tue Jan 22, 2008 8:01 pm
Posts: 61
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 ;-)

_________________
Davide Taddei
http://davidetaddei.[URL banned].com


Top
 Profile  
 
PostPosted: Wed Oct 13, 2010 6:28 am 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Mon Mar 30, 2009 11:27 am
Posts: 162
Location: www
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.

_________________
work hard, party harder
http://smartwebstudio.com


Top
 Profile  
 
PostPosted: Fri Apr 01, 2011 2:16 pm 
User avatar
Joomla! Fledgling
Joomla! Fledgling

Joined: Tue Aug 26, 2008 4:33 am
Posts: 4
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;



+

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 ;-)


Then you can use the existing view and model and just add a different one if you really need to.

_________________
Saludos,
--
Chongkan - Likan Development - Diseño Web y Desarrollo a la medida - http://www.likandevelopment.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 



Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group