Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Trying to Specify controller in layout xml for menu item
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Eric Fernance  
View profile  
 More options Mar 29 2012, 4:51 am
From: Eric Fernance <bea...@purplebeanie.com>
Date: Thu, 29 Mar 2012 18:51:30 +1000
Local: Thurs, Mar 29 2012 4:51 am
Subject: Trying to Specify controller in layout xml for menu item

Folks,

I have been banging my head against a wall for hours now and could do with some enlightenment.

I am working on a component with multiple front end views and controllers.  I want to specify in the layout xml what the controller should be to pick it up at the component entry point.

I have been trying to cobble something together based on these two docs:

http://docs.joomla.org/Component_parameters
http://docs.joomla.org/Developing_a_Model-View-Controller_(MVC)_Compo...

So far the only way I seem to be able to get something that even remotely approaches what I am trying to achieve is using this in the layout xml:

<fields name="request">
                <fieldset name="request">
                        <field
                                name="controller"
                                type="hidden"
                                default="entitlements">
                        </field>
                </fieldset>
        </fields>

It works, but it's very ugly popping a "Required Settings" pane on the right.  I actually don't need to be allowing the user to change it but I have no luck when I specify something like:

<url>
        <param name="controller" type="hidden" default="entitlements"/>
</url>

Any hints?

Eric.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
elin  
View profile  
 More options Mar 29 2012, 8:00 pm
From: elin <elin.war...@gmail.com>
Date: Thu, 29 Mar 2012 17:00:42 -0700 (PDT)
Local: Thurs, Mar 29 2012 8:00 pm
Subject: Re: Trying to Specify controller in layout xml for menu item

"Required settings" is looking for the request variables.

Elin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric Fernance  
View profile  
 More options Mar 29 2012, 10:16 pm
From: Eric Fernance <bea...@purplebeanie.com>
Date: Fri, 30 Mar 2012 12:16:16 +1000
Local: Thurs, Mar 29 2012 10:16 pm
Subject: Re: [jcms] Re: Trying to Specify controller in layout xml for menu item

Yeah that's what I thought.  But putting the controller into the <url> section of the layout XML doesn't seem to work, the only way I could get it to add was when I put it in the request section.

Eric.
On 30/03/2012, at 10:00 AM, elin wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
elin  
View profile  
 More options Mar 29 2012, 11:40 pm
From: elin <elin.war...@gmail.com>
Date: Thu, 29 Mar 2012 20:40:29 -0700 (PDT)
Local: Thurs, Mar 29 2012 11:40 pm
Subject: Re: [jcms] Re: Trying to Specify controller in layout xml for menu item

I'm not sure what you mean by the url part of the file.
The request part *is* the url ... that is where you would put the elements
making up the xxx=yy parts of the url, as in the example id=1 or id=2.
You would not normally have controller=xx as part of a url.  It's not
necessary even to have request items--featured is an example that does not
as is search (though search can optionally).  Are you thinking that you
want a task?

Can you explain why you would want controller=something in your url?

Elin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
garyamort  
View profile  
 More options Mar 31 2012, 4:00 am
From: garyamort <garyam...@gmail.com>
Date: Sat, 31 Mar 2012 01:00:07 -0700 (PDT)
Local: Sat, Mar 31 2012 4:00 am
Subject: Re: Trying to Specify controller in layout xml for menu item

I just went through the same issue to specify a task, drop the fieldset
name="request" - a fieldset tells Joomla! to display a settings tab.  Just
drop it, ie:
<fields name="request">
<field
name="controller"
type="hidden"
value="entitlements">
</field>
</fields>

I believe that I had to surround it with either <site> or <config> in order
to make it work.  I'll give my code a check when I can get my pc back from
the kids.

Also note, see the content component for how the controller is currently
being specified.  It seems that the task parameter is used to refer to a
controller, while the view component is used to refer method to be
called....though looking through it I see a lot of comments such as:
// TODO This is a bandaid, not a long term solution.
// if ($layout) {
// $append .= '&layout='.$layout;
// }

So it seems that the precise definition/usage for task/view/layout/tmpl is
currently in flux.  

Also note, if you use JController's display method, which I find more
convenient then adding 60% of that code into my own custom display method,
there are a few assumptions JController makes which can cause problems.  
No matter what you set the default model to before calling it, the base
class goes and overrides the default based on the task parameter.   In the
end, I gave up trying to make Joomla! use the default model I wanted since
it kept going overwritten by other platform methods - and instead I just
pulled my models manually.

IE instead of calling in the controller:
$model = $this->getModel('event');
$view = $this->getView();
$view->setModel($model,true);

And then later on in the view calling $model = $this->getModel();

I ended up doing:
$model = $this->getModel('event');
$view = $this->getView();
// setting default = true is useless, but I do it anyway because one day it
should work
$view->setModel($model,true);

And then later on in the view calling
$layout = $this->getLayout();
$model = $this->getModel($layout);  

It's not the end of the world, it's just not the way all the tutorials say
to set do it.  In the end, it just re-enforces my dislike for counting on
the 'default' behavior in an api and only specifying alternate behaviour -
you just can't depend on the default behaviour to always be the default.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
elin  
View profile  
 More options Mar 31 2012, 7:36 am
From: elin <elin.war...@gmail.com>
Date: Sat, 31 Mar 2012 04:36:09 -0700 (PDT)
Local: Sat, Mar 31 2012 7:36 am
Subject: Re: Trying to Specify controller in layout xml for menu item

@gary I think that's a pretty old example of code that should have been
removed instead of being left commented, the point being that the bandaid
is not needed anymore.

@Eric

Ok I think I see part of what is going on. You are mixing advice from a 2.5
document with advice from a 1.5 document.  Yes that would be frustrating.
Forget <url></url>, that is what is now in the <fields
name="request"></request>.

Can you confirm that the xml file you are working on is layout.xml that is
found in the viewname/tmpl folder on the front end? Or are you trying to do
something on the back end?

Also, usually hidden fields would be something like the autoincremented id
on create/edit.  If the user is not giving it to you and it's not
absolutely necessary I don't think you should be taking this as input from
a form, it's just taking unnecessary risks. You need to treat all user
inputs as potentially attack and/or stupid vectors. Haven't we learned
enough about Firebug recently? Give the database that yourself.  If it is a
constant that always equals entitlements I'm not sure why you want to save
it, knowing the name of the layout should, I would think, give you enough
information, but I'm not clear exactly what you are doing so I could be
wrong and I've seen adding a constant to the request this sometimes as a
workaround in 1.5 and 1.0.

All you are doing in  default.xml or nondefaultlayoutname.xml is setting
the request variables and the values of a bunch of options for rendering
the page to be saved in the menu table.

What is the name of your view? Is that also the name of your subcontroller?

Elin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric Fernance  
View profile  
 More options Mar 31 2012, 10:49 pm
From: Eric Fernance <bea...@purplebeanie.com>
Date: Sun, 1 Apr 2012 12:49:02 +1000
Local: Sat, Mar 31 2012 10:49 pm
Subject: Re: [jcms] Re: Trying to Specify controller in layout xml for menu item

Thanks Elin,  Yes you are correct about the layout file it was the viewname/tmpl folder in the front end.  

Very true about security.  I will go back to basing the controller name on the view.  Thanks for clearing up the confusion on the 1.5 v 2.5 docs though!  I thought I was going crazy!

Eric.
On 31/03/2012, at 9:36 PM, elin wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »