Hi Bill,
You're being insanely helpful, and I really appreciate it. I've been
doing some more (re)reading of MVC concepts. I think part of the reason
I keep getting lost is because I'm -- for starters, more a designer
than anything else, and I sort of picked up PHP in order to start
building database-driven websites. But I really DO want to do it right.
I know I'm mixing my terminology left-right-and-center .... tonight I'm
going to try to compile all my notes into logical cheatsheets to help
me figure out what goes where and what does what, which I'm hoping will
help.
OK. But you're obviously thinking about this from the 'I have this page and
I want to change a part of it.' Another way of thinking about it would be
'where the difference between the pages that get generated is the content of
the "content" div.' It's small. Probably seems 'nit-picky'. But it'll
make a difference.
The "controller calls view" rather than "view asks for controller"
switch helps a LOT in terms of my understanding -- again, this probably
has something to do with how I'm used to querying the DB for data right
in the middle of my PHP code. (I can see how the MVC framework cleans
things up, now!).
> A simplified view of how the data would be
> grabbed & used in the portfolio bar:
This, and what follows, confuses me.
> To the left, a single record with a specified ID
> from the "feature" table would be displayed.
The page you sent us did not show what appeared to be a record (or it's
contents) but rather a link to a record. When I click the 'see more' link
it looks like the intention is to display some new content in the 'content'
div. Is that right?
The idea was to have a "feature" table with an image, some text, and a
link to the project_id. Ideally I could work it to the point at which I
could have more than one, and display them at random (from the PHP
mindset, I'd just count the rows, generate a random number between 0
and numrows, then grab & display the image, link, and text for the
given ID). But again, I'm thinking about this backwards, which is maybe
the problem. I assume the randomization would need to occur in the
controller, rather than the view?
The mockup shows images and a 'more' link for what looks like 3 categories
of projects. The images are links. What happens when one is clicked? What
happens when the 'more' link is clicked?
When an image is clicked, it would render the page for the project
data. Each project would contain a title and text, and would be
described as having many images, each with its own filename, title, and
text. I'm given to understand that, so long as both models describe
this data relationship (Image belongs_to :project and Project has_many
:images), I can create a single controller with an action to display
this data.
Terminology aside... yes. The project _controller_ should have a 'show'
action which will be rendered using the 'show.rhtml' view which will be
wrapped in the application layout and then sent back to the browser in
response to the visitor clicking a link to a particular project.
This makes sense.
And, from my understanding, the application.rhtml is basically a bunch
of static stuff wrapping a <%= yield %> snippet. Which will work for
everything except for the menu bar stuff.
Barring the "featured" bit for the moment, how do I tell the project
controller to render a 'list' action in the menu bar area, regardless
of what other controllers and actions are being called elsewhere in the
app?
I know you can use the yield code to show an ... (instance?) variable,
but can it be used to show the contents of an action?
At any rate, I'm going to try some more fighting with this this
evening, and hopefully I'll be better equipped to figure out how to do
this.
Thank you SO MUCH for all your help .... it helps me feel like I WILL
get there, eventually.
s