Howto solve Layout not found error

Did you find a bug in Joomla! 3.x but aren't sure? This forum is the place to help figure out if the problem is a bug and how to report it. If you are an experienced Joomla! user and are certain that you have found a bug please use the Bug Tracker to submit your issue.
This forum is for discussion about bugs and to get help with reporting them to the Bug Tracker: https://issues.joomla.org

Moderator: ooffick

Forum rules
Please use the official Bug Tracker to report a bug: https://issues.joomla.org
Locked
rameshelamathi
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 130
Joined: Sun May 11, 2008 3:00 pm
Contact:

Howto solve Layout not found error

Post by rameshelamathi » Fri Jul 26, 2013 9:26 am

I ran into this problem after upgrading to Joomla 3.1.4

While looking for layouts, Joomla is stripping the view name in a strange way, which produces this error.

For example,
You have a view: taxrule
Folder:

Code: Select all

/administrator/components/com_example/views/taxrule 
You have named the view class in view.html.php as ComponentViewTaxRule

Joomla strips the TaxRule into two based on the uppercase letters. ( :-[ ) and takes only the first part of it (tax)
So, it looks for a layout in the tmpl folder in

Code: Select all

/administrator/components/com_example/views/tax
This obviously does not exisit. So joomla throws the Layout not found error.

Solution:
Rename the lastpart of all your view classes to use the lowercase letters
Example:

Code: Select all

MyComponentViewTaxRule extends JViewLegacy
to

Code: Select all

MyComponentViewTaxrule extends JViewLegacy
Last edited by rameshelamathi on Fri Jul 26, 2013 2:19 pm, edited 2 times in total.
Open Source is freedom
----------------------------

User avatar
brian
Joomla! Master
Joomla! Master
Posts: 11773
Joined: Fri Aug 12, 2005 7:19 am
Location: Leeds, UK
Contact:

Re: Howto solve Layout not found error

Post by brian » Fri Jul 26, 2013 9:54 am

Hi Ramesh

Is it related to this change do you think https://github.com/joomla/joomla-cms/pull/969/files

Above my knowledge I'm afraid but if it is this then can you please raise an issue on the tracker
"Exploited yesterday... Hacked tomorrow"
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/

User avatar
brian
Joomla! Master
Joomla! Master
Posts: 11773
Joined: Fri Aug 12, 2005 7:19 am
Location: Leeds, UK
Contact:

Re: Howto solve Layout not found error

Post by brian » Fri Jul 26, 2013 10:07 am

Correction Ramesh its probably this https://github.com/joomla/joomla-cms/co ... dd0a36787e
"Exploited yesterday... Hacked tomorrow"
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/

rameshelamathi
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 130
Joined: Sun May 11, 2008 3:00 pm
Contact:

Re: Howto solve Layout not found error

Post by rameshelamathi » Fri Jul 26, 2013 10:13 am

Hello Brian

You are right.
Here is more info.

In the legacy view class (/libraries/legacy/view/legacy.php), these two lines take the layout path (Line number: 471)

Code: Select all

$lastPart = substr($classname, $viewpos + 4);
$pathParts = explode(' ', JStringNormalise::fromCamelCase($lastPart));
fromcamelCase function does the stripping (in /libraries/joomla/string/normalise.php)

Code: Select all

public static function fromCamelCase($input, $grouped = false)
	{
		return $grouped
			? preg_split('/(?<=[^A-Z_])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][^A-Z_])/x', $input)
			: trim(preg_replace('#([A-Z])#', ' $1', $input));
	}
The code reference above this function reads:
* "FooBarABCDef" becomes array("Foo", "Bar", "ABC", "Def")

So TaxRule becomes array('Tax', 'Rule')

The legacy view class then takes just the first one (tax)

Code: Select all

if (!empty($pathParts[1]))
			{
				$this->_name = strtolower($pathParts[0]);
			}

Open Source is freedom
----------------------------

rameshelamathi
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 130
Joined: Sun May 11, 2008 3:00 pm
Contact:

Re: Howto solve Layout not found error

Post by rameshelamathi » Fri Jul 26, 2013 10:14 am

Sadly, many developers have named their views using a combination of upper and lower cases.
Open Source is freedom
----------------------------

mahagr
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Fri Sep 26, 2008 4:55 pm

Re: Howto solve Layout not found error

Post by mahagr » Fri Jul 26, 2013 10:57 am


User avatar
H13
Joomla! Ace
Joomla! Ace
Posts: 1485
Joined: Sun Dec 10, 2006 6:39 pm
Location: Czech Republic
Contact:

Re: Howto solve Layout not found error

Post by H13 » Fri Jul 26, 2013 1:55 pm

- Phoca Gallery - powerful image gallery - http://www.phoca.cz/phocagallery/
- Phoca Restaurant Menu - http://www.phoca.cz/restaurantmenudemo/
- Phoca Cart - e-commerce platform for Joomla!
- Phoca Download - download manager for Joomla!

rameshelamathi
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 130
Joined: Sun May 11, 2008 3:00 pm
Contact:

Re: Howto solve Layout not found error

Post by rameshelamathi » Tue Jul 30, 2013 5:04 am

Open Source is freedom
----------------------------


Locked

Return to “Joomla! 3.x Bug Reporting”