I just trying to make things easer to myself.

For example I have news and I'd like to show page with 5(why not)
short descriptions of news (only name and link to full news). And I
want to show full news with all information - name, date and text.

So idea is make some functions which would do all parsing  cause than I
parse small news and full news I do practically the same. I realize it
this way:

class NewsController extends MyAppController
{
var $name = 'News';
var $uses = array('News');


var $pagePatternByDefault = 'showSmallNewsRule';
var $objectsOnPage = NewsOnPage;


        function showNews($id=1){
                $showruleName = 'showBigNewsRule';
                $this->getShowRule($showruleName);
                $this->condition = "news.id = '$id'";
                $res = $this->getDataByShowrule();
                $this->set('res',$this->parseObjByData($res[0]));
                $this->render();
                }



        function showNewsAll($page=1){
                $this->page = $page;
                $this->getShowRule();
                
$this->set('res',$this->parseObjByDataArr($this->getDataByShowrule()));
                $this->render();
                }


}



and this (it's only part of MyAppController but i suppose that's enough
for this example )


class MyAppController extends AppController{
var $name = 'MyApp';

//prop for current subclass
var $pagePatternByDefault;
var $objectsOnPage;

//prop for curent task
var $condition;
var $page;
var $showrule;



        function getShowRule($showrule=false){
                $ShowRulesRegistry = new ShowRulesRegistry();

                if($ShowRulesRegistry->isValid($showrule)){
                $this->showrule = $ShowRulesRegistry->get($showrule);
                }

                else{
                $this->showrule =
$ShowRulesRegistry->get($this->pagePatternByDefault);
                }
                return $this->showrule;
        }



        function parseObjByData($data){
                $showrule = $this->showrule;
                $this->set('res', $data);
                ob_start();
                $this->render($showrule->getPattern(),'empty');
                $res = ob_get_contents();
                ob_end_clean();
                return $res;
        }


        function parseObjByDataArr($data){
        $showrule = $this->showrule;
        $res=array();
        for($i=0;$i<count($data);$i++){
                $res[] = $this->parseObjByData($data[$i]);
        }
        return $res;
        }


        function getDataByShowrule(){
                $showrule = $this->showrule;
                $book =array();

                $res = $this->{$this->uses[0]}->query($showrule->getSql($this));

                return($res);
        }


        }


I think it's not about MVC pattern it's about making parsing I just
do same controller which contains function for other controllers.
That's all.
Maybe that's all good for nothing and useless I don't know.. can
you show me how you would solve simple problem with News??

p.s. to clemos and Troy Schmidt sorry for my English it's a bit
technical))


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to