Dean-O
Dean-O

Reputation: 1153

what does getcmd do in Joomla

Hi all I am new to programming in Joomla. I am going through the Joomla Programming book by Mark Dexter and Louis Landry. Which for the most part is a good book.

My question is what does $view = JRequest::getCmd('view', 'submanager'); do?

I know it is returning something to the $view variable, but not sure what. Is it looking for the word view as a request URL param? What is submanager?

Any clarity in this matter would be great.

Thanks in advance Dean-O

Upvotes: 2

Views: 1141

Answers (1)

Lodder
Lodder

Reputation: 19743

getCmd is a proxy function for getVar The difference being is that getCmd only allows words and integers based on [A-Za-z0-9.-_].

getVar simply fetches a variable that you ask it to, depending on the request method, such as a POST or GET request.

Do bare in mind that JRequest is deprecated, therefore should you need to fetch a variable, then use the following:

$jinput   = JFactory::getApplication()->input;
$variable = $jinput->get('view', 'submanager');

Example:

Lets say you have a small contact form and within that form is an input field which has name="email".

Once that form is submitted, you can then access this using:

$jinput   = JFactory::getApplication()->input;
$variable = $jinput->get('email');

So in your case, the code you provided is getting the variable view, ensuring it is a word or number and submanager is the default value for this variable.

Upvotes: 3

Related Questions