Alex Tech Adventures The webs best tutorials!

Welcome, Guest
Please Login or Register.    Lost Password?

MVC share db-functions in more then one Model
(1 viewing) (1) Guest
Go to bottomPage: 1
TOPIC: MVC share db-functions in more then one Model
#243
MVC share db-functions in more then one Model 2 Years, 1 Month ago Karma: 1
I'm trying to learn Zend FW, get more and more for each day. Really cool to work with a framework.

But now I'm little bit stuck, and tired so I'm total empty of search terms when I tried to Google a solution.

I have to have a structure to make regaular pages with main content (WYSIWYG), a title, metatitle, meta desc and keywords.

The ID/SELECT should be from the URL (/www.domain.com/about/nicklas) but I want to be able to use the same solution for more then one Model, so i don't need to repeat source each time.

How do I make this effenctive and how do I "send" the pages-meta data into the layout-file?

Looking forward to get some nice tutorials from you to get me started.
Skatan
Fresh Boarder
Posts: 11
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#257
Re:MVC share db-functions in more then one Model 2 Years, 1 Month ago Karma: 16
>> want to be able to use the same solution for more then one Model, so i don't need to repeat source each time.
Sounds like you need to look into some OOP design patterns. Remember, that you do not have to have mode/controller/viewer in a 1-1-1 ratio. controller goes with viewer, yes, but you can have as much models as you want. They are not tied into controller directly and you can call models from other models. So make a class that performs that one special functionality and call it as necessary from anywhere (other models).

As far as sending data to layout, it is identical to sending values to view:
$this->view->varname = 'data'; // in controller
<?php echo $this->varname; ?> //in layout
so if you want to pass some custom data into, say, title then you would have something like
controller:
$this->view->title = 'page for nicklas' //taken from DB for example.
layout:
<?php echo $this->headTitle($this->title); ?>

Hope i understood your problem correctly.
alexanderrv
Administrator
Posts: 279
graph
User Offline Click here to see the profile of this user
Gender: Male tmthv2 alexchatonly@hotmail.com Location: Freeport, Bahamas Birthdate: 1989-04-14
The administrator has disabled public write access.
 
Go to topPage: 1
Moderators: alexanderrv
You are here: Home Forum

Statistics

Members : 1401
Content : 42
Web Links : 1
Content View Hits : 191194

Poll

Interested in TinyBrowser and TinyMce plugin for ZF?
 

Who's Online

We have 34 guests online