Note that there are some explanatory texts on larger screens.

plurals
  1. POCodeIgniter calendar/planning application, structuring and execution
    primarykey
    data
    text
    <p>This project is literally making me lose sleep. I think about it all day long, I dream about it at night, and when I lie awake I think about it some more. It's seriously getting me to the point of crying, haha. I don't know how to structure my application and I don't know how to execute my ideas. </p> <p>First of all, a short introduction. I study Interactive Multimedia Design, and I have a course called 'Project'. As the name suggests, we have to think up and create a project, more specifically a web application, using PHP, HTML/CSS, MySQL, AJAX, .. whatever technology we want to use. Since we also have to challenge ourselves to a certain extent, I decided to learn and use the CodeIgniter framework for this project. We have to show our professors what we are able to achieve. (This application won't be deployed or used, though. It's just a showcase.)</p> <p>I will be creating a web application, a calendar/planner for students. They can keep track of their classes and homework, free time, etc. Here's a screenshot of what I'm trying to achieve:</p> <p><img src="https://i.stack.imgur.com/zJwwk.jpg" alt="Web app page"></p> <p>I already threw out the slider and fixed this by using AJAX requests for the next/previous buttons. You can see the latest version of the website <a href="http://www.obscura-design.be/planner/" rel="nofollow noreferrer">here</a>.</p> <p>However, I'm not happy with my code. I'm not happy with what I'm doing. To be brutally honest, I'm confused. I'm hopelessly confused.</p> <p>I have read blogs, books, websites about CodeIgniter, about the MVC model; I have a fairly decent knowledge of PHP and I picked up the framework rather quickly. But still, so confused.</p> <p>I started by coding my <a href="http://www.obscura-design.be/login" rel="nofollow noreferrer">login form</a>. All good. I have a login controller, with an <code>index()</code> function, a <code>go()</code> function which focuses on form validation (using the form_validation library) and setting the session. It handles error messages through AJAX and communicates with the database through my login model. I suppose this follows the MVC pattern fairly well.</p> <p>The actual 'planner' page is a whole different story though. One of the first things I was wondering about is whether or not I can use/call functions from a view. If I follow the MVC guidelines, I would say I cannot. So what I'm doing now is stacking all the data in $data arrays in my controller and then echo'ing those out through jQuery AJAX calls, straight into my webpage.</p> <p>This brings forward my first, ridiculously simple, question. Is this okay? One of my main concerns is of course users who don't have javascript enabled; the application simply doesn't work. I have read about graceful degradation and progressive enhancement, but I'm just not sure if this application is do-able without JS. </p> <p>Another thing I'm not sure about (AJAX-wise) is the fact that I have two different AJAX-calls on $(document).ready, and then like four more when the user clicks on different elements. It also bothers me that jQuery <code>.html()</code> doesn't actually put the contents inside my html tags (when I view source).</p> <p>The list of days at the top gets generated by a function called <code>init_days()</code>. I populate the list using one of the $(document).ready() AJAX calls. It works fine, but the function is a huge mess. In the controller, I create an array <code>$data</code> and echo the whole list (complete with html tags) into <code>$data['calendar']</code>; I then output this straight into the <code>&lt;ul&gt;</code> tags:</p> <pre><code> // populate initial calendar $.ajax( { type: "POST", url: "/planner/init_days", success: function(data){ $("#days_loader").hide(); $(".month").prepend(data['month_name'] + " " + current_year); $("#day_list").html(data['calendar']).fadeIn(); } }); </code></pre> <p>However, when using the next and previous buttons, I kind of call the same function, just with a <code>data:</code> option to submit the new month (and, if necessary, year). This seems a bit redundant to me; putting (almost) the same code three times. Not sure how to fix this.</p> <p>My <strong>main problem,</strong> where I'm stuck now, is the part beneath the days. I have those 'Woe, 20 april' table headers, but then underneath that I need to get my actual events. I'm not sure what would be the best approach to creating this feature. Should I put it in a table? But then how would I put certain events on the right place? For now, all I have achieved is a function which outputs all events for a certain day into an array, like so:</p> <pre><code>Array ( [0] =&gt; Array ( [id] =&gt; 1 [title] =&gt; Test Event [description] =&gt; Dit is een test event. [day_start] =&gt; 2011-04-20 [day_end] =&gt; 2011-04-20 [user_id] =&gt; 1 [time_start] =&gt; 11 [time_end] =&gt; 12 ) [1] =&gt; Array ( [id] =&gt; 2 [title] =&gt; Test Event 2 [description] =&gt; Dit is een tweede event. [day_start] =&gt; 2011-04-20 [day_end] =&gt; 2011-04-20 [user_id] =&gt; 1 [time_start] =&gt; 12 [time_end] =&gt; 13 ) ) </code></pre> <p>I'm not sure if a table is the best way to go. The main thing that bothers me is that I'm working with hours and all of these different hours have their own place on the page, if that makes sense. (like 9 am would go on top of the column, 11 pm would be at the bottom, duh). </p> <p>I'm willing to provide a link to my source code (github) if anyone would like to take a look at my mess and perhaps try to put me on the right track again. Perhaps I AM on the right track, still; I just don't feel that way. I got stuck at the displaying-events part, and I just feel horrible because I'm not happy with what I wrote (even though most of it works, at this point). </p> <p>As I'm on Easter break at the moment, I can't contact my teacher for another week, so I'm willing to provide a 100-150 rep bounty for a good, helpful answer to this huge rant/question.</p> <p>If there are any books, websites, blogs I should read on design patterns, MVC, CodeIgniter, and PHP best practices in general, please also provide them. Thanks a lot.</p> <p>If you got to this point, thanks for reading all the way. I appreciate it. </p> <p>EDIT: My source code is here: <a href="https://github.com/cabaret/Studieplanner" rel="nofollow noreferrer">https://github.com/cabaret/Studieplanner</a></p> <p>PS: This question is a follow-up to <a href="https://stackoverflow.com/questions/5615270/web-app-slider-showing-days-of-the-months-feature">my previous question.</a> I have taken a lot of steps forward since then, but I'm still not happy and incredibly confused, mostly. I appreciate any help.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload