Webdesign MVC - going in the right direction?


socurious
25/12/2015 9:47 am
HOME ยป Programming Languages

I am trying to learn webdesign using the MVC design pattern. Right now, I am stuck at a point where my code gets more complex, and I am unsure about the structure and where to put which code parts.

I started with an index.php file as my controller, which right now does not much more than loading the Slim framework to render the different views

$app->get('/', function() use ($app){  
$app->render('header.php');  
$app->render('content.php');   
$app->render('footer.php');  
});  
$app->run();

Then I built a complex content.php where I do a lot of form data logic, reading from a server directory, and echoing the results mixed with html tags. That surely will violate the MVC pattern, right?

What is the general approach to this? Should I put all the logic inside the index.php, store the results in an array, and pass that to the framework's render function, like this:

$app->get('/', function() use ($app){ 

//Do something and store results in an Array

$app->render('header.php', anArray());  
$app->render('content.php', anArray());   
$app->render('footer.php', anArray());  
});  
$app->run();

How can I prevent index.php becoming too complex when doing so? Is there a different approach to take?


Related to : Webdesign MVC - going in the right direction?
Webdesign MVC - going in the right direction?
25/12/2015 9:47 am by socurious in Programming Languages

I am trying to learn webdesign using the MVC design pattern. Right now, I am stuck at a point where my code gets more complex, and I am unsure about the structure and where to put which code parts.

I started with an index.php file as my controller, which right now does not much more than


Custom Android Gallery Widget - How can I snap to the direction of onFling (never in the opposite direction)
by Barfo in Programming Languages

I have been trying for hours now to achieve something I believe pulse app has managed to do. That is to get the Android Gallery Widget to fling in one direction and then snap to the nearest item in that direction (default is snapping to the item which is closest to the center of the gallery). TAGS: Custom Android Gallery Widget snap direction

Automatically align the children of div to bottom in vertical direction and left in horizontal direction when the div is resized
by fstender in Programming Languages

I am trying to arrange the children elements of a div to bottom of it automatically,when the div is resized . here is my html . please help me . thanks.


<div style="width:200px;height:200px;border:1px solid red;vertical-align:bottom;">
<a>more...</a>
TAGS: Automatically align children bottom vertical direction
Aligning contents of a div right. Getting 'direction: rtl' effect, without specifying the widths? while keeping text direction in input fields
by Randy K in Programming Languages

Aligning contents of a div to right edge. Getting 'direction: rtl' effect (right to left), without specifying the width of the div? while keeping text direction in input fields going ltr(left to right). Is it possible? Applying direction: right to div almost acheives effect, except text fields i


How to get text direction in Android and change layout dynamically according to the direction?
by dawza in Programming Languages
I'm doing some research about feasibility of changing UI dynamically based on direction of a text. Although Google is supporting RTL languages (ref: Native RTL support in Android 4.2) but it doesn't cover a situation that application has mix of LTR and RTL contents.Google's solution is right if we h
How to render <form:checkboxes> in page direction instead of line direction?
by danielsdesk in Programming Languages

I need to bind Map<Long, String> to checkboxes in a form.


Here is my code:


<form:form modelAttribute="flowForm" action="${flowExecutionUrl}">
<table style="width: 100%">
<tr>
<td width="30%">Select A
How to draw line on a map if the guys is moving in zig zag direction or keep on changing the direction?
by dante in Programming Languages

Hi i want to just keep tracking of user in which directions he is moving i just wanna to know how can i draw it on map if guys keep on changing the track not in a straight line


Image that follows and moves into the direction to the direction the mouse is moved.
by dlouzan in Programming Languages
Hello
I'm having problems trying to figure out how to come up with a solution to this dilemma so any help would be more than greatful!
IN A NUT SHELL
I want to make an image (one that is larger than the actual stage itself) to follow and move into the direction to the direction that t
Detect direction of movieclip and rotate to face direction???
by DonMac in Programming Languages
Morning all!
Little thing bugging me here.....
I have a movie clip which moves around the stage randomly, but I want it to face the direction it randomly changes to. Can you help or shed some light for me?
Here is my code:
How to detect direction of movieclip and rotate to face direction
by Thomas Gueze in Programming Languages
Hi!
I have searched this forum, but Im not really sure what to search for, so I havent found anything similar to this. If anyone know, then please post the link to that thread.
I am trying to do some sort of aquarium with random moving amoebas.
But I want the amoebas (movieclips) to d
Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2014 © bighow.org All Rights Reserved .