how mod_search works?

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Locked
peyrol
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed May 26, 2010 7:22 pm

how mod_search works?

Post by peyrol » Wed May 26, 2010 7:35 pm

Hello

I want to learn Joomla. So first I have read tutorial, and second print whole mod_search code.
But i don't understand sequence of which class / method is created and call. So i put this line to
all files in com_search in every method (also in templates where are no methods) and get this text at the bottom.

The question is: why after put some text into search component and hit enter file
components\com_search\search.php is executed twice?

At first time sequence is search.php -> controller.php with SearchController::search
and second is components\com_search\search.php -> components\com_search\controller.php with SearchController::display.

Why the whole file components\com_search\search.php is parsed twice?

Best Regards

Trace:
21:28:52
1 components\com_search\search.php [Line] 17 [Klasa] [Method] [Function]
2 components\com_search\controller.php [Line] 47 [Klasa] SearchController [Method] SearchController::search [Function] search
21:28:53
1 components\com_search\search.php [Line] 17 [Klasa] [Method] [Function]
2 components\com_search\controller.php [Line] 38 [Klasa] SearchController [Method] SearchController::display [Function] display
3 components\com_search\models\search.php [Line] 64 [Klasa] SearchModelSearch [Method] SearchModelSearch::__construct [Function] __construct
4 components\com_search\models\search.php [Line] 119 [Klasa] SearchModelSearch [Method] SearchModelSearch::setAreas [Function] setAreas
5 components\com_search\views\search\view.html.php [Line] 32 [Klasa] SearchViewSearch [Method] SearchViewSearch::display [Function] display
6 components\com_search\models\search.php [Line] 200 [Klasa] SearchModelSearch [Method] SearchModelSearch::getAreas [Function] getAreas
7 components\com_search\models\search.php [Line] 132 [Klasa] SearchModelSearch [Method] SearchModelSearch::getData [Function] getData
8 components\com_search\models\search.php [Line] 200 [Klasa] SearchModelSearch [Method] SearchModelSearch::getAreas [Function] getAreas
9 components\com_search\models\search.php [Line] 170 [Klasa] SearchModelSearch [Method] SearchModelSearch::getTotal [Function] getTotal
10 components\com_search\models\search.php [Line] 182 [Klasa] SearchModelSearch [Method] SearchModelSearch::getPagination [Function] getPagination
11 components\com_search\models\search.php [Line] 170 [Klasa] SearchModelSearch [Method] SearchModelSearch::getTotal [Function] getTotal
12 components\com_search\views\search\tmpl\default.php [Line] 2 [Klasa] [Method] [Function]
13 components\com_search\views\search\tmpl\default_form.php [Line] 2 [Klasa] [Method] [Function]
14 components\com_search\views\search\tmpl\default_error.php [Line] 2 [Klasa] [Method] [Function]
15 modules\mod_search\mod_search.php [Line] 14 [Klasa] [Method] [Function]
16 modules\mod_search\tmpl\default.php [Line] 2 [Klasa] [Method] [Function]

peyrol
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed May 26, 2010 7:22 pm

Re: how mod_search works?

Post by peyrol » Thu May 27, 2010 7:34 am

I just check if //$controller->redirect(); in search.php is commented then

1 components\com_search\search.php
2 components\com_search\controller.php SearchController SearchController::search search
3 modules\mod_search\mod_search.php
4 modules\mod_search\tmpl\default.php

but if I only comment //$controller->execute(JRequest::getCmd('task')); in file then backtrack looks like:

1 components\com_search\search.php
2 modules\mod_search\mod_search.php
3 modules\mod_search\tmpl\default.php

So i check $_POST and found variable 'task' with 'search' value, after uncomment all lines in the second load $_POST is empty and there is 'task' anywhere, so $controller->execute(JRequest::getCmd('task')); is not executed.

I think in the fist step URI (or something else) is modified that $controller->redirect(); load search.php once more, but in the second read $controller->redirect(); pass control to model.

Great, i suppose I answer to myself. I wonder how $controller->redirect() exactly work but I think i must read JController API.

Best Regards to you All :)

peyrol
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed May 26, 2010 7:22 pm

Re: how mod_search works?

Post by peyrol » Thu May 27, 2010 9:41 am

Ok I figure that out:

At the first run after $controller->execute(JRequest::getCmd('task')); from $_POST
command is taken -> this command is 'search',
after execute $controller->execute(JRequest::getCmd('task')); in controller inner variable
$controller->_redirect; is set into this (for example)

'/joomla/index.php?searchword=pizza&ordering=&searchphrase=all&Itemid=1&option=com_search'

after this line $controller->redirect();
redirect components\com_search\search.php again but there is no 'task' in $_POST or anywhere else. So all job is done and component go to the model.

I think.
Self explained thread

:)) Best Regards again, and thanks for hot stuff such Joomla is :)


Locked

Return to “Joomla! 1.5 Coding”