Where is the default component set in code

37 views
Skip to first unread message

WJHildreth

unread,
Jun 23, 2016, 1:20:08 PM6/23/16
to Joomla! General Development
Hello all,

This may be a simple question, but I cannot seem to figure it out.

I started with the index.php file on the front end of a Joomla 3.5.1 install to trace the program execution.  Trying to educate myself on how the internals of joomla works.

Well, I know that a JApplicationSite object is created and walked myself through the code if its creation using netbeans.

Then I started down the execute() method and learned that the document is created and populated with some information, loads the template and executes the component.  All in the JApplicationsite, dispatch() method.

Well the best I can tell from reading code, if I entered the site application with http://mysite..com that the components option would be null.  It isn't passed on the url and I am not seeing it set in the code.

Now, I know if option is not set when firing the site application it defaults to com_content.

Can some one, PLEASE tell me where the code sets this default value?

When in dispatch() it calls JComponentHelper::renderComponent($component) and as best I can tell, in the scenario above, $component = null.  The renderComponent() method would throw and exception if the component is null.

Many thanks for your time and energy.

Joe

sovainfo

unread,
Jun 23, 2016, 7:37:49 PM6/23/16
to Joomla! General Development
Don't know what makes you think that the component defaults to com_content. The menu item with the home set to 1 determines the component.
Sorry, cant help you yet to the place where this happens. When you change the home menu item you'll see that it takes that component.

Randy Carey

unread,
Jun 24, 2016, 8:33:30 AM6/24/16
to Joomla! General Development

I found the book Joomla Programming to be very helpful in explaining how Joomla works.  Chapter 3 walks one through The Anatomy of an Execution Cycle, and this walks through the code with explanation as to what is happening at every important step.  The book was initiallly written for 2.5, but its explanations of the Joomla core is still applicable today.

WJHildreth

unread,
Jun 24, 2016, 10:57:49 AM6/24/16
to Joomla! General Development
I didn't realize that was what was happening.  I just assumed that it was com_content because of the featured article, but whatever assigned to the HOME link makes sense.

I realize this is answering my own question, but it happens in the JRouterSite load() method while in the Application execution method.  When it builds the route, it gets a JMenuSite object them runs the load() method which queries the DB and sets the component and view.

Thanks for that tidbit of info, that clears a few things up in my cloudy mind.

Regards,

Joe

WJHildreth

unread,
Jun 24, 2016, 11:11:39 AM6/24/16
to Joomla! General Development
Randy,

I have that book.  Albeit it has been a while since I have read it.  I will compare what is in the book to the code for J3.5.  It looks like, at least on the surface that the Initialise(), route(), dispatch() and render() methods are all handled by the application execute() method now.  I am a relatively new programmer and I am just trying to wrap my head around, what appears to me, a very complex framework.

Thanks for the link too, and your help.

Joe

Reply all
Reply to author
Forward
0 new messages