The Joomla! Forum ™



Forum rules


Please use the official Bug Tracker to report a bug: http://issues.joomla.org



Post new topic Reply to topic  [ 47 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Thu Dec 30, 2010 1:59 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Dec 05, 2010 11:50 pm
Posts: 12
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.


Top
 Profile  
 
PostPosted: Fri Dec 31, 2010 1:33 am 
User avatar
Joomla! Exemplar
Joomla! Exemplar

Joined: Thu Aug 18, 2005 8:43 pm
Posts: 7986
Location: New York
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!.


Top
 Profile  
 
PostPosted: Fri Dec 31, 2010 2:36 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Dec 05, 2010 11:50 pm
Posts: 12
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


Top
 Profile  
 
PostPosted: Fri Dec 31, 2010 3:08 am 
User avatar
Joomla! Exemplar
Joomla! Exemplar

Joined: Thu Aug 18, 2005 8:43 pm
Posts: 7986
Location: New York
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!.


Top
 Profile  
 
PostPosted: Fri Dec 31, 2010 11:38 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Dec 05, 2010 11:50 pm
Posts: 12
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.


Top
 Profile  
 
PostPosted: Fri Dec 31, 2010 4:37 pm 
User avatar
Joomla! Exemplar
Joomla! Exemplar

Joined: Thu Aug 18, 2005 8:43 pm
Posts: 7986
Location: New York
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!.


Top
 Profile  
 
PostPosted: Thu Feb 17, 2011 10:56 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Thu Feb 17, 2011 10:53 pm
Posts: 4
Hello,

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

Thank you for help


Top
 Profile  
 
PostPosted: Fri Feb 18, 2011 8:06 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Dec 05, 2010 11:50 pm
Posts: 12
No I entered a Bug report for this but that was the last thing that happened.


Top
 Profile  
 
PostPosted: Fri Feb 18, 2011 11:28 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Thu Feb 17, 2011 10:53 pm
Posts: 4
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.


Top
 Profile  
 
PostPosted: Fri Feb 18, 2011 7:07 pm 
User avatar
Joomla! Exemplar
Joomla! Exemplar

Joined: Thu Aug 18, 2005 8:43 pm
Posts: 7986
Location: New York
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!.


Top
 Profile  
 
PostPosted: Mon Feb 21, 2011 8:23 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Thu Feb 17, 2011 10:53 pm
Posts: 4
True, but without this alternate layout (component) doesn't working for me :-(


Top
 Profile  
 
PostPosted: Tue Feb 22, 2011 11:17 am 
User avatar
Joomla! Exemplar
Joomla! Exemplar

Joined: Thu Aug 18, 2005 8:43 pm
Posts: 7986
Location: New York
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!.


Top
 Profile  
 
PostPosted: Tue Feb 22, 2011 1:27 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Dec 05, 2010 11:50 pm
Posts: 12
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.


Top
 Profile  
 
PostPosted: Tue Feb 22, 2011 1:58 pm 
User avatar
Joomla! Exemplar
Joomla! Exemplar

Joined: Thu Aug 18, 2005 8:43 pm
Posts: 7986
Location: New York
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!.


Top
 Profile  
 
PostPosted: Mon Mar 21, 2011 4:05 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Feb 10, 2007 11:16 pm
Posts: 13
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?


Top
 Profile  
 
PostPosted: Tue Mar 29, 2011 5:53 am 
User avatar
Joomla! Exemplar
Joomla! Exemplar

Joined: Thu Aug 18, 2005 8:43 pm
Posts: 7986
Location: New York
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!.


Top
 Profile  
 
PostPosted: Mon Jun 20, 2011 4:19 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Nov 02, 2009 1:46 am
Posts: 6
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


Top
 Profile  
 
PostPosted: Sat Jul 09, 2011 2:57 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Sat Jul 09, 2011 1:32 pm
Posts: 1
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.


Top
 Profile  
 
PostPosted: Sat Aug 06, 2011 3:31 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Nov 03, 2007 9:36 pm
Posts: 7
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


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 7:32 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Aug 11, 2009 2:12 pm
Posts: 14
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.


Top
 Profile  
 
PostPosted: Mon Sep 12, 2011 5:32 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Sun Jul 03, 2011 2:18 pm
Posts: 3
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:
$viewLayout = JRequest::getCmd('layout', 'default');
. The problem is, that the variable $viewLayout has the value mytemplatemylayoutoverride without the doublepoint ":".

Whats going wrong?


Top
 Profile  
 
PostPosted: Thu Sep 22, 2011 1:12 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Mar 01, 2008 6:41 pm
Posts: 10
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.


Top
 Profile  
 
PostPosted: Wed Oct 05, 2011 9:11 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Mar 05, 2009 8:04 pm
Posts: 20
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?


Top
 Profile  
 
PostPosted: Wed Nov 16, 2011 8:57 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Oct 16, 2007 2:33 am
Posts: 44
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.


Top
 Profile  
 
PostPosted: Mon Nov 21, 2011 5:31 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Oct 16, 2007 2:33 am
Posts: 44
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.


Top
 Profile  
 
PostPosted: Mon Nov 21, 2011 6:14 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Feb 10, 2007 11:16 pm
Posts: 13
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.


Top
 Profile  
 
PostPosted: Mon Nov 21, 2011 7:10 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Oct 16, 2007 2:33 am
Posts: 44
barback - thanks very much.

regarding this point...
Quote:
* 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.


Top
 Profile  
 
PostPosted: Mon Nov 21, 2011 9:15 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Feb 10, 2007 11:16 pm
Posts: 13
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.


Top
 Profile  
 
PostPosted: Wed Nov 23, 2011 2:16 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Oct 16, 2007 2:33 am
Posts: 44
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.


Top
 Profile  
 
PostPosted: Sun Dec 04, 2011 4:51 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Sun Jul 03, 2011 2:18 pm
Posts: 3
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:
$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:
// 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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 47 posts ]  Go to page 1, 2  Next



Who is online

Users browsing this forum: No registered users and 7 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