Welcome, Guest
Username: Password: Remember me

TOPIC: [CLOSED] Default layout missing

Default layout missing 28 Feb 2015 12:42 #12853

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 414
  • Thank you received: 130
  • Karma: 46
VeCrea wrote:
I already forked the model and the tables, but i get nothing.
Hi VeCrea,
Its a long shot as i dont know if it is even related without seeing your component but
Interesting I forked a view.html.php file this week and for some reason i didnt get what i expected either...
(before i go further i must say that it is more than likely something that i perhaps coded wrong in my forked file)
for some reason I got default view not found return to control panel
it appears to work until I create the forked file
with the forked file in place i found that it called for a non existent display function
public function display($tpl = null)
	{
		/* Forked 
		$layout = $this->getLayout();
		
		if (!in_array($layout, array('layout1', 'layout2')))
			JError::raiseError(0, $layout . ' : ' . JText::_('JERROR_LAYOUT_PAGE_NOT_FOUND'));

		$fct = "display" . ucfirst($layout);

		$this->addForkTemplatePath();
		$this->$fct($tpl);			
		$this->_parentDisplay($tpl);
		*/
	}
I tracked it back to this function above and looking at this i can see the following
$layout = $this->getLayout();
// var_dump($layout) gives 'default'
and as we move further down the function we see
$fct = "display" . ucfirst($layout);
// so now $fct = displayDefault
and now further down the function we now call the displayDefault function
$this->$fct($tpl);
so now i search for a displayDefault function in my original view.html.php file
guess what i dont have a displayDefault function :oops:

just a wild guess but by chance could you be doing something that perhaps ends up calling the Default view similar to this above?

I am guessing the starting place here is to either hard code the layout or retrieve the actual layout name from some other existing function, class or helper
but its been a while since and i cant remember where such function may be located
$layout = $this->getLayout();

if($layout === 'default'){
	$layout = 'layout2';
        // OR $layout = getDefaultLayoutName();
       // wherever such function may be hiding
     
      //  hard coding as below would be an option too i guess
      //$layout = $this->getLayout('mydefaultlayout');
}

So as i said i know something in my forked code caused this and we know that it has caused the layout name to be lost but perhaps
$this->getLayout();
should return the the actual default table name not "default" as it does now

Just a thought

@Admin should i perhaps raise this as a ticket?
just not sure at the moment without looking into it further if its related to my additional code or could infact be an underlying bug
Last Edit: 28 Feb 2015 12:52 by BTB300.
The administrator has disabled public write access.
The following user(s) said Thank You: admin, VeCrea

Default layout missing 28 Feb 2015 13:21 #12854

  • VeCrea
  • VeCrea's Avatar
  • Offline
  • Platinum Member
  • Absolute JCook fan
  • Posts: 473
  • Thank you received: 100
  • Karma: 30
Thanks BTB300, will look into it.
Many things cooking right now ;-)
The administrator has disabled public write access.

Default layout missing 28 Feb 2015 14:47 #12858

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
This is because you have no default layout for this table. In the builder you can set it (Default entry point).

It can happens sometimes when you delete the layout setted default. I tought this was fixed and that Cook was choosing the first layout as default, but I will check again.
If you have no default layout, then you have neither the tmpl/default.php file I guess.

The workaround is to set the layout name in the url : layout=layout_name', and work without 'default' layout.


Moved to New Tickets
Coding is now a piece of cake
The administrator has disabled public write access.

Default layout missing 28 Feb 2015 15:25 #12863

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 414
  • Thank you received: 130
  • Karma: 46
If it helps,
From memory
- I created a layout that was automatically set as default...
- I then went oh no the second layout should be default set it as default
- I did not delete the first layout (at least I don't think I did)

And yes no default.php of which Joomla would automatically look for in this case
Just layout1name.php and layout2name.php

At the time I did check for layout2 being set as default in it the builder but let me check again
They are not big forms will delete both and recreate them
Will confirm outcome of delete and recreate then will test just setting second as default without delete first for you if you like?
Last Edit: 28 Feb 2015 15:39 by BTB300. Reason: Added a bit more detail
The administrator has disabled public write access.

Default layout missing 28 Feb 2015 16:14 #12867

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 414
  • Thank you received: 130
  • Karma: 46
Deleted both item layouts....
Created new layout - was not set automatically as default
Set the first as default
Downloaded

And no default.php created in viewname/tmpl/
The administrator has disabled public write access.

Default layout missing 28 Feb 2015 16:19 #12868

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Item or collection ?

Because item do not have default. It is normal.
Coding is now a piece of cake
The administrator has disabled public write access.

Default layout missing 28 Feb 2015 16:34 #12869

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 414
  • Thank you received: 130
  • Karma: 46
Item...
And the display function in question above is located in
Administrator/com_componentname/views/itemviewname/view.html.php
Last Edit: 28 Feb 2015 16:46 by BTB300.
The administrator has disabled public write access.

Default layout missing 28 Feb 2015 17:57 #12870

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
So, everything is normal.

For the moment Cook generate this way. Defaults are only for lists. I do not remember why...
To my opinion, those defaults are a non sense. It is not necessary because components use SEF so url is shorter anyways.

Can somebody explains me what those defaults are for ?
Because if at least Joomla could understand we wants 'layout1' as default, it would be amazing. But no, we are forced to give 'default' name or it will not work.

About your problem, can you explain me what did you wanted to do ? When creating a link with a menu, or manually coded redirection ?
Coding is now a piece of cake
The administrator has disabled public write access.

Default layout missing 01 Mar 2015 13:13 #12872

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 414
  • Thank you received: 130
  • Karma: 46
Thank you Admin
I found my answer... And I am sorry to say that as I thought it could be related to my forked code
I dropped (cut and paste) some code that was from a pure php environment into the view.html.php file. This contained a __construct() function... As we know the construct function will run when the class is called... This __construct function in turn did not specify or capture the layout name

So when the forked view.html.php was loaded the __construct function ran automatically and returned nothing
$this->getLayout() returned 'default' and as discussed the display() function then called the missing displayDefault function
With a little bit of tweaking in the display() function I then realised that Joomla would automatically look for the default.php layout if the layout name was not provided. Removed the __construct() and all worked

As for why the default.php layout may be needed
From Joomla Docs docs.joomla.org/Absolute_Basics_of_How_a_Component_Functions
As before, if you do not specify a layout, the 'default' layout will be used. To use layouts you need to create a new folder under the related view folder named 'tmpl' and create a file named <mylayout>.php, nothing more, nothing less. If you are using the default layout this file will be named 'default.php'.

So as we can see from above your current build using layout1name.php, layout2name.php and not including a default.php is technically correct and only if you do some thing silly like I did in the forked file, or Joomla some how lost the layout name or some how call the 'default' layout would you ever encounter such problems with the current build of Cook.

So I guess we can call this closed unless you feel the need to deal with the missing default.php layout and the fact that "should someone call the default layout that it will error out in the view.html.php display() function. In all reality it could be said that if you intentionally omit the layout name or simply call the default layout it would be considered lazy coding ;)

So now back to what I was trying to do... As you know I like to push the boundaries of Cook's ability and generally end up finding minor glitches / bugs... But this time
I was simply using the publish button to display a fly based item layout but I needed fire off some other code contained in a custom class, work with the data and display it like a welcome letter rather than in a table format nothing outside the scope of the abilities of Cook Component

And one last thing thanks for your assistance... And I am sorry that the majority of the issues was my fault :unsure:
Last Edit: 01 Mar 2015 13:32 by BTB300.
The administrator has disabled public write access.

Default layout missing 17 May 2015 09:48 #13005

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
I have reviewed it all in the new version.

For the moment, I keep it like that.
The first layout created for LISTS is always 'default'
The first layout created for ITEM is what you want.

So it means that it do not really fit the standards, it is true, but I prefer it that way. It is less confusing.
If you want to have a default ITEM layout, then call it 'default'

To my opinion, Joomla should be able to receive a config for setting the default layout.
F0F is gonna come at rescue for that.
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.102 seconds

Get Started