Category Alternate Layout does not use defined layout

The support for Joomla 2.5 ended on December 31, 2014. Possible bugs in Joomla 2.5 will not be patched anymore. This forum has been closed. Please update your website to Joomla 3.x

Moderators: ooffick, dam-man

Forum rules
Please use the official Bug Tracker to report a bug: http://issues.joomla.org
vfrrider99
Joomla! Apprentice
Joomla! Apprentice
Posts: 12
Joined: Sun Dec 05, 2010 11:50 pm

Category Alternate Layout does not use defined layout

Postby vfrrider99 » Thu Dec 30, 2010 1:59 am

This is either a bug in the logic or a bug in my understanding of the use of the alternate layout option.

Under my templates html/com_content/category directory i made copies of blog.php to member.php and blog_item.php to member_item.php altering them according to my needs.

However, these are not loaded, because as far as I can tell with my limited PHP understanding the layout override is never called in components/com_content/views/category/view.html.php at line 116
if ($layout = $category->params->get('category_layout')) {
$this->setLayout($layout);
}

as the logic at line 114 returns false,

if (($active) || ((strpos($active->link, 'view=category') === false) || (strpos($active->link, '&id=' . (string) $category->id) === false))) {

If I reverse the logic to

if (($active) || ((strpos($active->link, 'view=category') === true) || (strpos($active->link, '&id=' . (string) $category->id) === true))) {

then the alternate layout is used to render the page.


As stated above, I do not know if this is a bug or just a limitation in my knowledge as I do not understand the check against the active menu as defined in the view_html.php file
// Check for layout override only if this is not the active menu item
// If it is the active menu item, then the view and category id will match
and under what circumstances the statement at line 114 will return true.

Can you confirm if I should be able to set specific category layout overrides, just with the addition of the two files or if this is not the correct usage of the layout override.

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7985
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: Category Alternate Layout does not use defined layout

Postby mcsmom » Fri Dec 31, 2010 1:33 am

The alternate layout is defined inside the specific item. So if you have an alternative layout for a category you would edit that categoy and select the alternate layout and save it.

If you google joomla 1.6 alternate layout you will find some material on this.

Note that alterative menu layouts (which have xml files) are treated somewhat differently.
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

vfrrider99
Joomla! Apprentice
Joomla! Apprentice
Posts: 12
Joined: Sun Dec 05, 2010 11:50 pm

Re: Category Alternate Layout does not use defined layout

Postby vfrrider99 » Fri Dec 31, 2010 2:36 am

That is what I have done, created a category override called member by the creation of member.php and member_item.php in the templates category folder.

This setting is being ignored when the page is being rendered

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7985
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: Category Alternate Layout does not use defined layout

Postby mcsmom » Fri Dec 31, 2010 3:08 am

Then you need to go into the category and select the layout and save it.
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

vfrrider99
Joomla! Apprentice
Joomla! Apprentice
Posts: 12
Joined: Sun Dec 05, 2010 11:50 pm

Re: Category Alternate Layout does not use defined layout

Postby vfrrider99 » Fri Dec 31, 2010 11:38 am

I have always had the alternative layout saved in the category and have confirmed that the database holds the following value for params
{"category_layout":"bni:member","image":""}

It only loads the new layout when I alter the code in view.html.php as mentioned in the first post.

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7985
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: Category Alternate Layout does not use defined layout

Postby mcsmom » Fri Dec 31, 2010 4:37 pm

Will you please post that in the tracker under category layouts.
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

jk1980
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Thu Feb 17, 2011 10:53 pm

Re: Category Alternate Layout does not use defined layout

Postby jk1980 » Thu Feb 17, 2011 10:56 pm

Hello,

I have the same problem, maybe did you find solution?

Thank you for help

vfrrider99
Joomla! Apprentice
Joomla! Apprentice
Posts: 12
Joined: Sun Dec 05, 2010 11:50 pm

Re: Category Alternate Layout does not use defined layout

Postby vfrrider99 » Fri Feb 18, 2011 8:06 am

No I entered a Bug report for this but that was the last thing that happened.

jk1980
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Thu Feb 17, 2011 10:53 pm

Re: Category Alternate Layout does not use defined layout

Postby jk1980 » Fri Feb 18, 2011 11:28 am

I know what we are doing wrong.

First, sorry for my english, it's not my natvie language :-)

To make alternative layout for content we must add new "Menu Item Type".
Just put in your template content directory xml file (i.e. alternate.xml) then add new menu item and select that type for that new item. It works.

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7985
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: Category Alternate Layout does not use defined layout

Postby mcsmom » Fri Feb 18, 2011 7:07 pm

No that is only to make an alternative menu layout not an alternative layout.
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

jk1980
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Thu Feb 17, 2011 10:53 pm

Re: Category Alternate Layout does not use defined layout

Postby jk1980 » Mon Feb 21, 2011 8:23 am

True, but without this alternate layout (component) doesn't working for me :-(

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7985
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: Category Alternate Layout does not use defined layout

Postby mcsmom » Tue Feb 22, 2011 11:17 am

I've been trying to find this issue and I think it may be related to what component you are using.Is everyone using com_content? Have you tried a category alternative layout in other components?
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

vfrrider99
Joomla! Apprentice
Joomla! Apprentice
Posts: 12
Joined: Sun Dec 05, 2010 11:50 pm

Re: Category Alternate Layout does not use defined layout

Postby vfrrider99 » Tue Feb 22, 2011 1:27 pm

Elin,
I have only needed the layout change in com_content so have not tried other components. The logic as far as I can tell only checks for a alternate menu layout being set and does not get as far as looking for a alternate content layout as per the first message in this thread.

Looking at the 3 other components that use this logic, com_contact, com_newsfeeds and com_weblinks, the only difference in the process of selecting an alternative layout is the logic string at line 114, the others have $this->category->id whereas com_content has $category->id. I thought this might be the problem but unfortunately it was not that simple, changing the line just causes an error.

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7985
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: Category Alternate Layout does not use defined layout

Postby mcsmom » Tue Feb 22, 2011 1:58 pm

Ok thanks. It's somewhat confusing to me because of the way the active menu overrides the alternative layout. I have been working on it though.
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

barback
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Sat Feb 10, 2007 11:16 pm

Re: Category Alternate Layout does not use defined layout

Postby barback » Mon Mar 21, 2011 4:05 pm

Alternative layouts will NOT be implemented if a menu item pointing to that category exists. (Even if you arrive at the category via list, or other non-menu link.)

I have been experimenting with the layout overrides, too.

I have created templates/my-template/hmtl/com_content/category/blogworm.php as well as blogworm_item.php and blogworm_item.xml.

I have added lines in the .sys.ini language file for the new menu item type.

When I choose the alternative menu item, then my layout overrides are applied to the blog display of the category.

But it is not possible for me to select this category override in the category manager options or category manager for a particular category -- it does not appear in the menu of alternative layouts.

It seems that having the .xml file precludes the use of the alternative as a an option to be selected at the category level?

I cloned my .php files with yet another name and the alternative layout was then available at the category level -- and it worked on a category that had no menu item pointing to it.

It wasn't clear to me that the extra step for making an override into a custom menu item type by adding the .xml file would destroy the override as a alternative layout. Is this the intended behavior, or a bug?

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7985
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: Category Alternate Layout does not use defined layout

Postby mcsmom » Tue Mar 29, 2011 5:53 am

That's intended behavior. You can do one or the other for a given layout, depending on if you want to use it for menu items (in which case it will show up on the list of menu types) or for non menu items (to override on drill downs).
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

Cerebrl
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Mon Nov 02, 2009 1:46 am

Re: Category Alternate Layout does not use defined layout

Postby Cerebrl » Mon Jun 20, 2011 4:19 am

Okay, I have to join in. I have spent an entire day trying to get alternative layouts to work for categories and articles. Nothing has worked. I've done everything per spec, and can't get it to switch to my template's layout. This has got to be a bug. Please, can someone shed some light on this?

Justin

geraldtarrant
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Sat Jul 09, 2011 1:32 pm

Re: Category Alternate Layout does not use defined layout

Postby geraldtarrant » Sat Jul 09, 2011 2:57 pm

I have the same problem and I didn't find answer neither on the forum nor on all internet. I created alternative blog layout "example" based on "blog.php" called:
"example.php" and associated files "example_item.php", "example_child.php" and "example_links.php".
I didn't created "example.xml" because it would be recognized as "alternative menu type item", not "category alternative layout" (altough in components\com_content\views\category\tmpl there is "blog.xml" file - i don't know how this mechanism work). All files I placed in "\templates\mytemplate\html\com_content\category"

There is NO any menu item pointing to it (it's sub-category with its own alternative category layout called "example" as I wrote earlier).

Alternative blog layout does not work. "example.php" is being loaded but NOT "example_item.php" ( I checked the output).

On the other hand Alternative list layout works well, without any problems, as well as overriden blog layout or list layout. Only alternative blog layout doesn't work. I spend many days at this, but didn't find solution. I don't know PHP too well. I use joomla 1.6.4.

I join to others - if it is a bug, please release a fix, or if it intended behavior - give solution how to make the alternative blog layout to work.

avra911
Joomla! Apprentice
Joomla! Apprentice
Posts: 7
Joined: Sat Nov 03, 2007 9:36 pm

Re: Category Alternate Layout does not use defined layout

Postby avra911 » Sat Aug 06, 2011 3:31 pm

That's right,

The alternative category layout is working only if you create a menu item.

I'm using Joomla 1.7. It shoulded work if you select the layout in admin, category edit page, but it's not. You have to find a workaround creating a menu item for that blog category page!

Razvan

k2_02
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Tue Aug 11, 2009 2:12 pm

Re: Category Alternate Layout does not use defined layout

Postby k2_02 » Wed Aug 31, 2011 7:32 pm

Having the same problem as the previous two posters. Have created an alternate Blog layout (mylayout.php) and accompanying item layout (mylayout_item.php) but the item layout is not being loaded. I really need this fixed as I require multiple layouts for different portions (member vs public) portions of the site.

benno_71
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sun Jul 03, 2011 2:18 pm

Re: Category Alternate Layout does not use defined layout

Postby benno_71 » Mon Sep 12, 2011 5:32 pm

Hello
I have the same problem with the new menu item (Joomla 1.7). I have made a layout override. When I choose this menu type, then the link would be like "index.php?option=mycomponent&view=xy&layout=mytemplate:mylayoutoverride". On the Frontend, the link would be like "index.php?option=mycomponent&view=xy&layout=mytemplate:mylayoutoverride&Itemid=nm".

If I klick on this link, some php error would be thrown. In my opinion, the problem lies in the doublepoint ":". If I change the link to "index.php?option=mycomponent&view=xy&layout=mylayoutoverride&Itemid=nm" then all is ok.

In the controller.php sourcefile of the joomla libraries in the function display() there is the code line

Code: Select all

$viewLayout = JRequest::getCmd('layout', 'default');
. The problem is, that the variable $viewLayout has the value mytemplatemylayoutoverride without the doublepoint ":".

Whats going wrong?

clongato
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Sat Mar 01, 2008 6:41 pm

Re: Category Alternate Layout does not use defined layout

Postby clongato » Thu Sep 22, 2011 1:12 am

I´m facing the same problem and I´ll resume what I found out:
- if you have a menu item pointing to the category Joomla! will use the layout specified on the menu link and that´s the reason the alternative layout doesn´t work.
- if you don´t have a menu item poiting to the category the alternative layout will be used.

As it is, if you create a menu item poiting to the category the only way to use the alternative layout is to create a new XML file and save it in the category view and, of course, create the template files - and you choose that particular layout in the menu settings; if you don´t create the menu item you just need to create the template files and select the layout in the category settings.

Someone said that this behavior is intentional, but this just makes no sense. The only reason you would need to create a new XML file is to set different parameters for the view and that´s quite different from creating a new design for the same information.

And why would I suppose natural to think that in order to create a different layout I would need to create a menu item? Or to be careful to NOT create a menu item if I use an alternative layout so my design don´t fall apart?

It´s just a convoluted way of coupling things that doesn´t necessary go together. And one that is not possible to avoid.

fiyom
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Thu Mar 05, 2009 8:04 pm

Re: Category Alternate Layout does not use defined layout

Postby fiyom » Wed Oct 05, 2011 9:11 am

I am having the same problem with Joomla 1.7. All the menu items have failed to link with the contents. It continued to give HTTP Error 404 - File or directory not found.
Internet Information Services (IIS). Any solution found yet?

lyndonr
Joomla! Apprentice
Joomla! Apprentice
Posts: 44
Joined: Tue Oct 16, 2007 2:33 am

Re: Category Alternate Layout does not use defined layout

Postby lyndonr » Wed Nov 16, 2011 8:57 pm

hmm... I've now spent a day on this as well. is it in the official "bug" list yet and if so is there a link so I can track this issue?

Specifically I'd like to get alternative menu items working for my site, but at this point it's just not happening.

I've posted about this issue in the 1.7 template override forum here http://forum.joomla.org/viewtopic.php?p=2669445 and another person has posted about his troubles with this in the main 1.7 template forum here http://forum.joomla.org/viewtopic.php?p=2441315.

my only alternative is to go back to my old fallback and put 2 different layouts in the same template override file, then sense what page I'm on through checking my body's id with javascript and route accordingly. just hate having two (or more!) layout possibilities in the same file. if alternative layouts worked, we could logically separate layouts by file.

thanks in advance for this community's help.

lyndonr
Joomla! Apprentice
Joomla! Apprentice
Posts: 44
Joined: Tue Oct 16, 2007 2:33 am

Re: Category Alternate Layout does not use defined layout

Postby lyndonr » Mon Nov 21, 2011 5:31 pm

just a bump. any new info on this joomla masters?

edit: ok I'm a dummy, I finally got an alternative menu item working, as several people have already stated, make sure you don't have another menu item pointing to that category, the default override will be used and your custom will be ignored.

HOWEVER, I still can't get an alternative layout working without creating an XML file and choosing it as a menu item. Simple alternative layouts seem to be ignored and I believe this to be a bug.

barback
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Sat Feb 10, 2007 11:16 pm

Re: Category Alternate Layout does not use defined layout

Postby barback » Mon Nov 21, 2011 6:14 pm

I recently presented on this topic at Joomla! Day NYC. Following this forum thread caused me some concern that between a presentation last March and this one in October something had become broken.

I thoroughly tested all aspects of the com_content overrides and the only view that would not work was the one called "categories" -- this was used in the sample data demonstration for the Australian Parks photo album. (see my October 13 blog post at http://irislines.com/blog.html )

All other overrides work as the documentation suggests:

* an override saved in your template's html folder with the name default.php will be used throughout your site.
* an override saved in your template's html folder with a new-name.php will be used for articles or categories THAT ARE NOT DISPLAYED BY A MENU ITEM and for which you specify the alternative layout.
* an override saved in your template's html folder with a new-name.php AND a matching new-name.xml file will be available as a menu item type. Any existing menu item for that article or category will have to be revised to use the new menu item type.

IF a menu item exists you MUST create the appropriate .xml file AND USE IT.
If you want your alternative layout available for both menu-accessed articles or categories and blog or module-accessed articles or categories that have no menu items associated, you'll need to create two different .php files, one with an associated .xml file and one without.

If the .xml file exists, the override is only a menu item type override. if there is no .xml file, your override is only an alternative layout, and must be specified for each article or category using the alternative layout parameter.

Even though you specify the alternative layout parameter, it will NOT be used if you create a menu item for that article or category unless you create the .xml file and use that menu item type.

lyndonr
Joomla! Apprentice
Joomla! Apprentice
Posts: 44
Joined: Tue Oct 16, 2007 2:33 am

Re: Category Alternate Layout does not use defined layout

Postby lyndonr » Mon Nov 21, 2011 7:10 pm

barback - thanks very much.

regarding this point...
* an override saved in your template's html folder with a new-name.php will be used for articles or categories THAT ARE NOT DISPLAYED BY A MENU ITEM and for which you specify the alternative layout.

this may be a stupid question, but if I have no menu item for an article (no matter what type), how would it be displayed on the front end? all articles need to have some kind of display mechanism.

for example, I can create an uncategorized test article, specify an alternative layout, but how would I see it if I don't create some kind of menu to it, thus overriding my alternative with the default? hmmm..

sorry for this. again just trying to make alternative layouts work. alternative menu items do work as advertised for me.

barback
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Sat Feb 10, 2007 11:16 pm

Re: Category Alternate Layout does not use defined layout

Postby barback » Mon Nov 21, 2011 9:15 pm

If you create a menu item to display a category list or blog, then you don't have a menu link to a specific article. Alternative layout for the article could be used when people click through to Read More....

Or perhaps you use a "latest articles" module. Again, you wouldn't necessarily have a menu link to the article....

If you link to a parent category in a way that sub-categories are listed (list or blog of the parent) access to the sub-categories would be provided without a specific menu item to the sub-category.

lyndonr
Joomla! Apprentice
Joomla! Apprentice
Posts: 44
Joined: Tue Oct 16, 2007 2:33 am

Re: Category Alternate Layout does not use defined layout

Postby lyndonr » Wed Nov 23, 2011 2:16 pm

thanks barback! makes sense. although it's difficult to envision a scenario where I would need to use alternative category layouts without just creating an XML file and menu item.

benno_71
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sun Jul 03, 2011 2:18 pm

Re: Category Alternate Layout does not use defined layout

Postby benno_71 » Sun Dec 04, 2011 4:51 pm

benno_71 wrote:Hello
I have the same problem with the new menu item (Joomla 1.7). I have made a layout override. When I choose this menu type, then the link would be like "index.php?option=mycomponent&view=xy&layout=mytemplate:mylayoutoverride". On the Frontend, the link would be like "index.php?option=mycomponent&view=xy&layout=mytemplate:mylayoutoverride&Itemid=nm".

If I klick on this link, some php error would be thrown. In my opinion, the problem lies in the doublepoint ":". If I change the link to "index.php?option=mycomponent&view=xy&layout=mylayoutoverride&Itemid=nm" then all is ok.

In the controller.php sourcefile of the joomla libraries in the function display() there is the code line

Code: Select all

$viewLayout = JRequest::getCmd('layout', 'default');
. The problem is, that the variable $viewLayout has the value mytemplatemylayoutoverride without the doublepoint ":".

Whats going wrong?


After joomla core code analysis I have found out the real problem:
Every view (for example view.html.php) must check if an alternative layout is choosen in the menu item. If so, then the view must set the correct layout. In general, this can be solved by adding the following lines of code in the display() function of the view:

Code: Select all

// Check for layout override
$active = JFactory::getApplication()->getMenu()->getActive();
if (isset($active->query['layout'])) {
  $this->setLayout($active->query['layout']);
}


I have found this lines of codes in some views for example in the file view.html.php on components/com_users/views/login.

Benno


Return to “Joomla! 2.5 Bug Reporting”

Who is online

Users browsing this forum: No registered users and 2 guests