The Joomla! Forum ™

Forum rules

Please use the mailing list here: rather than this forum.

Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
PostPosted: Sun Jan 27, 2008 3:28 am 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Fri Dec 16, 2005 12:33 am
Posts: 150
I'm trying to learn the new rules for Joomla 1.5! components. I don't understand this piece of code:
<?php>// Require specific controller if requested
if($controller = JRequest::getWord('controller')) {
   $path = JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php';
   if (file_exists($path)) {
      require_once $path;
   } else {
      $controller = '';

What value does this statement confer $controller?
$controller = JRequest::getWord('controller')

if controller is categories, the $path will be component/xxx_component/controllers/categories.php?

I've read the API documentation, but not so useful for understanding getWord()


PostPosted: Mon Feb 04, 2008 9:18 am 
User avatar
Joomla! Ace
Joomla! Ace

Joined: Mon Dec 05, 2005 10:17 am
Posts: 1367
Location: New Orleans, LA, USA
JRequest::getWord() is a proxy method to JRequest::getVar() which is used to get a variable from the request and sanitize it.  The getWord() part means to pass it through what we call the "word" filter.  The word filter allows alphanumeric characters plus underscores and dashes I believe.

Rob Schley - Open Source Matters
Webimagery - - Professional Consulting Services
JXtended - - Free and Commercial Joomla! Extensions

PostPosted: Tue Feb 05, 2008 5:31 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Sat Dec 15, 2007 3:02 pm
Posts: 531
Location: Washington DC Metro
... and to take that statement a bit further (in case it is still a bit obtuse), it is the method used to obtain GET variables from the URL.  As RobS stated, getWord is a proxy for getVar.  There are many other proxy methods as well such as: getInt() (which returns only digits), getBool() (which returns only true/false values), etc. 

These can all be found in libraries/joomla/environment/request.php

Catch up with me on Google+:

Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

Who is online

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