Search the Community
Showing results for tags 'mvc'.
-
Hi all, I have just put together a tentative proof of concept MVC framework proposal. After many weeks of slogging through an array of PHP MVC tutorials and courses (some of which I paid for) I have decided to strip back all the frills, bells and whistles to try and put together a core proof of concept that uses best practices. In this simplified example I am trying to test the viability of the framework itself... so there is no routing code or query string management and the controller and action are hard coded. Here is the repository: https://github.com/JethroHazelhurst/psr-4-mvc I like this framework because it: Has clear seperation of concerns Is not cluttered with static functions Is clearly namespaced - thanks to the PSR-4 autoloading Has a clear way of passing data to and from the model - e.g. $this->_view->foo = $this->_model->getBar(); Below is the directory structure: and here is a print_r of my Object structure: Questions I am interested in hearing any feedback on the idea... I can't see any glaring issues at them moment. Some questions in the back of my mind are: Are there any dangers in heavily depending on the parent::__construct() function to call parent classes? In the controller, is passing data from Model to View using $this->_view->foo = $this->_model->getBar(); good practice? Are there any dangers in using Namespaces? I am also interested in reading up on MVC framework best practices so if anyone can recommend some resources I would be very grateful. It seems like there are a million ways to write an MVC framework, I am confused as to which way is best practice. EDIT: Hmm, can't seem to get a list to display here...
-
Hi everyone, I have been working through various tutorials over the past couple of months and am currently trying understand PHP frameworks. One of the ways I am doing this is by trying to design my own very simple MVC framework from scratch. I am trying to re-factor an application (which I have already built using spaghetti procedural PHP). This application has a front end for teachers and a back-end for the administrators. I would like to separate concerns and have URL's like this http://example.com/{module}/{controller}/{method}/{param-1}/{param-2} Now the MVC framework I have cobbled together up to this point does not handle routing for 'modules' (I apologise if this is not the correct terminology), only the controller/method/params. So I have separated the public_html from the app logic and inside of the /app/ folder I have specified two folders, my default "learn module" and the "admin module" so that the directory tree looks like this: Apparently this design pattern is a "H"MVC? My Solution I am basically making use if the is_dir(); function to check if there is a "module" directory (such as "admin") and then unsetting the first URL array element $url[0] and reindexing the array to 0... then I am changing the controller path according to the URL... the code should be clearer... <?php class App { protected $_module = 'learn'; // default module --> learn protected $_controller = 'home'; // default controller --> home protected $_method = 'index'; // default method --> index protected $_params = []; // default paramatars --> empty array public function __construct() { $url = $this->parseUrl(); // returns the url array // Checks if $url[0] is a module else it is a controller if (!empty($url) && is_dir('../app/' . $url[0])) { $this->_module = $url[0]; // if it is a model then assign it unset($url[0]); if (!empty($url[1]) && file_exists('../app/' . $this->_module . '/controllers/' . $url[1] . '.php')) { $this->_controller = $url[1]; // if $url[1] is also set, it must be a controller unset($url[1]); $url = array_values($url); // reset the array to zero, we are left with {method}{param}{etc..} } // if $url[0] is not a module then it might be a controller... } else if (!empty($url[0]) && file_exists('../app/' . $this->_module . '/controllers/' . $url[0] . '.php')) { $this->controller = $url[0]; // if it is a controller then assign it unset($url[0]); $url = array_values($url); // reset the array to zero } // else if url is empty default {module}{controller}{method} is loaded // default is ../app/learn/home/index.php require_once '../app/' . $this->_module . '/controllers/' . $this->_controller . '.php'; $this->_controller = new $this->_controller; // if there are methods left in the array if (isset($url[0])) { // and the methods are legit if (method_exists($this->_controller, $url[0])) { // sets the method that we will be using $this->_method = $url[0]; unset($url[0]); } // else nothing is set } // if there is anything else left in $url then it is a parameter $this->_params = $url ? array_values($url) : []; // calling everything call_user_func_array([$this->_controller, $this->_method], $this->_params); } public function parseUrl() { // checks if there is a url to work with if (isset($_GET['url'])) { // explodes the url by the '/' and returns an array of url 'elements' return $url = EXPLODE('/', filter_var(rtrim($_GET['url'], '/'), FILTER_SANITIZE_URL)); } } } this so far appears to be working for me, but..... Question I am not sure if this is the preferred solution to this issue. Is calling the is_dir() check for every page request going slow down my app? How would you engineer a solution or have I completely misunderstood the issue? Many thanks in advance for your time and consideration!! Hazel,
-
Hi there, I'm learning PHP and working on building an ecommerce site using a MVC. I can display all six categories from the database on the index page however I only want to show four of these, as the links at the top will be the six categories. By using the next() method I can display all six categories: <?php while ($categories->next()) { ?> <section class="product"> <a href="products/<?= $categories->getURL() ?>"><h3 class="upper"><?= $categories->getName() ?></h3></a> <br/> <img src="<?= IMAGE_URL . $categories->getImage() ?>" style="width:80%; height:auto;" alt="Menu Tab"/> <h3 class="under"><a href="products/<?= $categories->getURL() ?>">SHOP NOW >></a></h3> </section> <?php } } } ?> I am wondering how to only extract certain products (each has a catID in the database). I thought the switch statement might be the answer and here was my attempt that did not work. I guess I am still not saying which catID to get but unsure how to fix this. Or is there another way not using switch? while ($categories->next()) { switch ($categories->getID()) { case 1: case 2: case 3: case 4: ?> <section class="product"> <a href="products/<?= $categories->getURL()?>"><h3 class="upper"><?=$categories->getName() ?></h3></a> <br/> <img src="<?=IMAGE_URL. $categories->getImage()?>" style="width:80%; height:auto;" alt="Menu Tab"/> <h3 class="under"><a href="products/<?= $categories->getURL()?>">SHOP NOW >></a></h3> </section> <?php break; default: return ""; } } } } ?> Any help would be greatly appreciated! Cheers
-
I am quite new to php and the mvc setup, I am developing a library app however starting at the very basics so as not to become overwhelmed! I am trying to do a basic insert to my book table, this is the code I have so far alsong with the error I am presented with. Model (models > adminarea_model.php) adminarea_model.php public function create($title_text) { $title_text = strip_tags($title_text); $sql = "INSERT INTO book (title) VALUES (:title)"; $query = $this->db->prepare($sql); $query->execute(array(':title' => $title_text)); $count = $query->rowCount(); if ($count == 1) { return true; } else { $_SESSION["feedback_negative"][] = FEEDBACK_NOTE_CREATION_FAILED; } return false; } View (views > admin > addBook.php) addBook.php <form method="post" action="<?php echo URL;?>admin/create"> <label>Text of new note: </label><input type="text" name="title" /> <input type="submit" value='Create this note' autocomplete="off" /> </form> Controller (controllers > admin.php) admin.php public function create() { if (isset($_POST['title']) AND !empty($_POST['title'])) { $book_model = $this->loadModel('Admin'); $book_model->create($_POST['title']); } header('location: ' . URL . 'admin/addBook'); } When I am on admin/addBook and I try to submit the form I receive the following error; Fatal error: Call to a member function create() on a non-object in C:\xampp\htdocs\logintest\application\controllers\admin.php on line 43 Any ideas where I am going wrong? Line 43 contains the following $book_model->create($_POST['title']); Thanks J
-
I am trying to create a simple forum in a MVC architecture. This is my database setup (the relevant part): Table: forum_categories `forum_categories` ( `cat_id` INT( NOT NULL AUTO_INCREMENT, `cat_title` VARCHAR(255) NOT NULL, `cat_desc` TEXT NOT NULL, PRIMARY KEY (`cat_id`), UNIQUE KEY (`cat_title`) Table: forum_topics `forum_topics` ( `topic_id` INT( NOT NULL AUTO_INCREMENT, `cat_id` INT( NOT NULL COMMENT 'foreign key with forum_categories table', `user_id` INT(11) NOT NULL COMMENT 'foreign key with users table', `topic_title` VARCHAR(255) NOT NULL, `topic_desc` TEXT NOT NULL, `topic_date` DATETIME DEFAULT NULL, PRIMARY KEY (`topic_id`), FOREIGN KEY (`cat_id`) REFERENCES forum_categories (`cat_id`) ON DELETE CASCADE ON UPDATE CASCADE Example of the functionality, I would like to achieve: Category 1 has cat_id = 1 Category 2 has cat_id = 2 Topic 1 has cat_id = 1 Topic 2 has cat_id = 2 Now when category 1 is selected I just want topic 1 to show. If category2 is selected I just want topic 2 to show. This prepared SQL statement achieves that: PREPARE stmnt FROM 'SELECT * FROM forum_categories fc JOIN forum_topics ft ON fc.cat_id = ft.cat_id WHERE fc.cat_id = ? ORDER BY ft.topic_date DESC'; SET @a = 1; EXECUTE stmnt USING @a; My Problem: I would like to move this functionality into my PHP MVC structure. Here is my attempt, which does not work (it shows all topics in all categories). Controller /** * Show all the topics in the chosen category */ public function showForumTopics() { $topic_model = $this->loadModel('Forum'); $this->view->forum_topics = $topic_model->getForumTopics(); $this->view->render('forum/viewTopics'); } Model /** * Gets an array that contains all the forum topics in the database. * Each array element is an object, containing a specific topic's data. * @return array All the forum topics */ public function getForumTopics($cat_id) { $sql = 'SELECT * FROM forum_categories fc JOIN forum_topics ft ON fc.cat_id = ft.cat_id WHERE fc.cat_id = :cat_id ORDER BY ft.topic_date DESC'; $query = $this->db->prepare($sql); $query->execute(array(':cat_id' => $cat_id)); return $query->fetchAll(); } View if ($this->forum_topics) { foreach($this->forum_topics as $key => $value) { echo '<p><strong>Title:</strong>' . $value->topic_title . '</p>'; echo '<p><strong>Description:</strong> ' . $value->topic_desc . '</p>'; echo '<p><strong>Author:</strong> ' . $value->topic_author . '</p>'; echo '<p><strong>Date:</strong> ' . $value->topic_date . '</p>'; } } else { echo 'No forum topics.'; } Help would be highly appreciated! Thank you!!
-
Hi everyone, So I'm relatively new to OO PHP and moreover, OO PHP with MVC design pattern. This may be a largeish post so please bear with me on this one! So here is a scenario that I'd like to understand. There are likely multiple ways to go about this, but it'd be nice to see what is said. I'll include what I think should be the solution here and hopefully i'll get some feedback about it. Scenario: A page needs to display a list of "parts" for a car. A database table already exists with these parts. The list of parts on the page need to be ordered by name on first load, but then can be re-ordered by users using a drop down list. They can also be filtered, and searched. A page also exists to display a single car part. What I think should be, and what i'm struggling with: Model: I will have a "part" object which represents an individual car part. The part object will use a database abstraction layer. On "new Part()" will generate an empty object. ->Load( id ) will load an individual part. Controller: I do not know how I would implement this. I know it would contain methods to Filter(), Search() and Order() and that would directly access the Model. View: I am lost here too, I need to display a list of car parts, and on another page, a single car part. I understand I should use the same Model for both. However I do not see how I would list the parts. Some Questions: Should I have another "model" that is a list of the "Part" model called PaetListModel, or should "Part" be able to generate that list? I clearly should have 2 views, one for singular part, one for list of parts. Should the view access the model to generate the list before using the data for output? Should the controller be used in the view instead of the model to generate the initial list (or singular) on page load? Should the filter functions in the controller reload the "PartsList" from wherever our list is stored? I think the most important question for me though is: How would YOU implement the above green scenario? I would like to learn from peoples examples so I get an idea of what road to follow
- 1 reply
-
- mvc
- design pattern
-
(and 3 more)
Tagged with:
-
Im trying to implement the PSR-0 autoloader found here : Autoloader I have simply copied and pasted the code as it is shown in the link so should work out of the box. Here is my file structure for my App: I believe i have set up the file structure correctly. App being the vendor, and then the folders below all being namespaces e.g. Frontend, Base, index will all be namespaces and subnamespaces. The autoloader classes specifies this code in order the initiate the autoloader: $classLoader = new SplClassLoader('Doctrine\Common', '/path/to/doctrine'); $classLoader->register(); And in my app i have used this: $classLoader = new SplClassLoader('App', SITE_ROOT); $classLoader->register(); The reason i have only put App as the namespace for the classLoader function is because i need to autoload all classes under the App folder. Here is the initiation of my router class which i believe should be autoloaded so i don't have to include it: $route = new router(); $route->setDefaultController(DEFAULT_CONTROLLER); $route->setDefaultMethod(DEFAULT_METHOD); $route->do_route(); $controller = $route->getController(); $method = $route->getMethod(); $arguments = $route->getArgs(); Is this correct? it doesnt seem to be loading any of the classes, not even the router class which is in the same directory as the autoloader? Im getting pretty confused about what should be parsed to the SPLClassLoader function shown above for a namespace. Any help in this area will be much appreciated Thanks
- 6 replies
-
- mvc
- autoloading
-
(and 2 more)
Tagged with:
-
I have a search class with pagination and I can get the first page to display correctly but the next page gives a bunch of undefined index(s). I know i need to pass the variables to the next page but it only uses one "View" and a "Class". I have tried to make all the $_POST variables into $_SESSIONS and that still did not work. Im sure if I could make the pagination stay at "Search" and not go to "Search?page=2" it might work, but I don't know how to do that exactly. Here is the Pagination and Search Function class/code: <?php class Search extends MainController{ function __construct(){ parent::__construct(); $this->view->url = $this->config->url; $this->view->ID = get_class($this); $this->view->Title = "Diablo 3 Online Auction House"; $this->view->msg = ""; $this->view->err = false; $itemName = isset($_POST['item_name']) ? $_POST['item_name'] : ''; $val_1 = $_POST['attrib1']; $val_2 = $_POST['attrib2']; $val_3 = $_POST['attrib3']; $val_4 = $_POST['attrib4']; $val_5 = $_POST['attrib5']; $val_6 = $_POST['attrib6']; $val_7 = $_POST['attrib7']; $val_8 = $_POST['attrib8']; $itemAttrib1 = $_POST['list_1']; $itemAttrib2 = $_POST['list_2']; $itemAttrib3 = $_POST['list_3']; $itemAttrib4 = $_POST['list_4']; $itemAttrib5 = $_POST['list_5']; $itemAttrib6 = $_POST['list_6']; $itemAttrib7 = $_POST['list_7']; $itemAttrib8 = $_POST['list_8']; $Quality = $_POST['quality']; $Type = $_POST['type']; $sub_Type = $_POST['sub']; $page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1; // If the page wasn't set, lets set $page to number 1 for the first page $sql = "SELECT * FROM items_us_sc WHERE item_name = :item_name AND quality = :quality AND type = :type AND sub_type = :sub AND ((attrib_1 = :prop1 AND value_1 >= :val1 OR attrib_2 = :prop1 AND value_2 >= :val1 OR attrib_3 = :prop1 AND value_3 >= :val1 OR attrib_4 = :prop1 AND value_4 >= :val1 OR attrib_5 = :prop1 AND value_5 >= :val1 OR attrib_6 = :prop1 AND value_6 >= :val1 OR attrib_7 = :prop1 AND value_7 >= :val1 OR attrib_8 = :prop1 AND value_8 >= :val1) AND (attrib_1 = :prop2 AND value_1 >= :val2 OR attrib_2 = :prop2 AND value_2 >= :val2 OR attrib_3 = :prop2 AND value_3 >= :val2 OR attrib_4 = :prop2 AND value_4 >= :val2 OR attrib_5 = :prop2 AND value_5 >= :val2 OR attrib_6 = :prop2 AND value_6 >= :val2 OR attrib_7 = :prop2 AND value_7 >= :val2 OR attrib_8 = :prop2 AND value_8 >= :val2) AND (attrib_1 = :prop3 AND value_1 >= :val3 OR attrib_2 = :prop3 AND value_2 >= :val3 OR attrib_3 = :prop3 AND value_3 >= :val3 OR attrib_4 = :prop3 AND value_4 >= :val3 OR attrib_5 = :prop3 AND value_5 >= :val3 OR attrib_6 = :prop3 AND value_6 >= :val3 OR attrib_7 = :prop3 AND value_7 >= :val3 OR attrib_8 = :prop3 AND value_8 >= :val3) AND (attrib_1 = :prop4 AND value_1 >= :val4 OR attrib_2 = :prop4 AND value_2 >= :val4 OR attrib_3 = :prop4 AND value_3 >= :val4 OR attrib_4 = :prop4 AND value_4 >= :val4 OR attrib_5 = :prop4 AND value_5 >= :val4 OR attrib_6 = :prop4 AND value_6 >= :val4 OR attrib_7 = :prop4 AND value_7 >= :val4 OR attrib_8 = :prop4 AND value_8 >= :val4) AND (attrib_1 = :prop5 AND value_1 >= :val5 OR attrib_2 = :prop5 AND value_2 >= :val5 OR attrib_3 = :prop5 AND value_3 >= :val5 OR attrib_4 = :prop5 AND value_4 >= :val5 OR attrib_5 = :prop5 AND value_5 >= :val5 OR attrib_6 = :prop5 AND value_6 >= :val5 OR attrib_7 = :prop5 AND value_7 >= :val5 OR attrib_8 = :prop5 AND value_8 >= :val5) AND (attrib_1 = :prop6 AND value_1 >= :val6 OR attrib_2 = :prop6 AND value_2 >= :val6 OR attrib_3 = :prop6 AND value_3 >= :val6 OR attrib_4 = :prop6 AND value_4 >= :val6 OR attrib_5 = :prop6 AND value_5 >= :val6 OR attrib_6 = :prop6 AND value_6 >= :val6 OR attrib_7 = :prop6 AND value_7 >= :val6 OR attrib_8 = :prop6 AND value_8 >= :val6) AND (attrib_1 = :prop7 AND value_1 >= :val7 OR attrib_2 = :prop7 AND value_2 >= :val7 OR attrib_3 = :prop7 AND value_3 >= :val7 OR attrib_4 = :prop7 AND value_4 >= :val7 OR attrib_5 = :prop7 AND value_5 >= :val7 OR attrib_6 = :prop7 AND value_6 >= :val7 OR attrib_7 = :prop7 AND value_7 >= :val7 OR attrib_8 = :prop7 AND value_8 >= :val7) AND (attrib_1 = :prop8 AND value_1 >= :val8 OR attrib_2 = :prop8 AND value_2 >= :val8 OR attrib_3 = :prop8 AND value_3 >= :val8 OR attrib_4 = :prop8 AND value_4 >= :val8 OR attrib_5 = :prop8 AND value_5 >= :val8 OR attrib_6 = :prop8 AND value_6 >= :val8 OR attrib_7 = :prop8 AND value_7 >= :val8 OR attrib_8 = :prop8 AND value_8 >= :val8))"; $arr = array(":item_name" => $itemName, ":quality" => $Quality, ":type" => $Type, ":sub" => $sub_Type, ":prop1" => $itemAttrib1, ":val1" => $val_1, ":val2" => $val_2, ":val3" => $val_3, ":val4" => $val_4, ":val5" => $val_5, ":val6" => $val_6, ":val7" => $val_7, ":val8" => $val_8, ":prop2" => $itemAttrib2, ":prop3" => $itemAttrib3, ":prop4" => $itemAttrib4, ":prop5" => $itemAttrib5, ":prop6" => $itemAttrib6, ":prop7" => $itemAttrib7, ":prop8" => $itemAttrib8); $ctr = $this->database->DBCtr($sql,$arr); $this->view->count = $ctr; // Lets set how many messages we want to display $per_page = "5"; // Now we must calculate the last page $last_page = ceil($ctr/$per_page); // And set the first page $first_page = "1"; // Here we are making the "First page" link if ($page == $first_page){ $this->view->first = "<li class='disabled'><a href='?page=".$first_page."'>First page</a></li>"; }else{ $this->view->first = "<li><a href='?page=".$first_page."'>First page</a></li>"; } // If page is 1 then remove link from "Previous" word if($page == $first_page){ $this->view->prev = "<li class='disabled'><a>Previous</a></li>"; }else{ if(!isset($page)){ $this->view->prev = "<li><a>Previous</a></li>"; }else{ // But if page is set and it's not 1.. Lets add link to previous word to take us back by one page $previous = $page-1; $this->view->prev = "<li><a href='?page=".$previous."'>Previous</a></li>"; } } // If the page is last page.. lets remove "Next" link if($page == $last_page){ $this->view->next = "<li class='disabled'><a>Next</a></li>"; }else{ // If page is not set or it is set and it's not the last page.. lets add link to this word so we can go to the next page if(!isset($page)){ $next = $first_page+1; $this->view->next = "<li><a href='?page=".$next."'>Next</a></li> "; }else{ $next = $page+1; $this->view->next = "<li><a href='?page=".$next."'>Next</a></li>"; } } // And now lets add the "Last page" link if ($page == $last_page){ $this->view->last = "<li class='disabled'><a href='?page=".$last_page."'>Last page</a></li>"; }else{ $this->view->last = "<li><a href='?page=".$last_page."'>Last page</a></li>"; } // Math.. It gets us the start number of message that will be displayed $start = (($page * $per_page) - $per_page); // Now lets set the limit for our query $limit = "LIMIT $start, $per_page"; $sql = "SELECT * FROM items_us_sc WHERE item_name = :item_name AND quality = :quality AND type = :type AND sub_type = :sub AND ((attrib_1 = :prop1 AND value_1 >= :val1 OR attrib_2 = :prop1 AND value_2 >= :val1 OR attrib_3 = :prop1 AND value_3 >= :val1 OR attrib_4 = :prop1 AND value_4 >= :val1 OR attrib_5 = :prop1 AND value_5 >= :val1 OR attrib_6 = :prop1 AND value_6 >= :val1 OR attrib_7 = :prop1 AND value_7 >= :val1 OR attrib_8 = :prop1 AND value_8 >= :val1) AND (attrib_1 = :prop2 AND value_1 >= :val2 OR attrib_2 = :prop2 AND value_2 >= :val2 OR attrib_3 = :prop2 AND value_3 >= :val2 OR attrib_4 = :prop2 AND value_4 >= :val2 OR attrib_5 = :prop2 AND value_5 >= :val2 OR attrib_6 = :prop2 AND value_6 >= :val2 OR attrib_7 = :prop2 AND value_7 >= :val2 OR attrib_8 = :prop2 AND value_8 >= :val2) AND (attrib_1 = :prop3 AND value_1 >= :val3 OR attrib_2 = :prop3 AND value_2 >= :val3 OR attrib_3 = :prop3 AND value_3 >= :val3 OR attrib_4 = :prop3 AND value_4 >= :val3 OR attrib_5 = :prop3 AND value_5 >= :val3 OR attrib_6 = :prop3 AND value_6 >= :val3 OR attrib_7 = :prop3 AND value_7 >= :val3 OR attrib_8 = :prop3 AND value_8 >= :val3) AND (attrib_1 = :prop4 AND value_1 >= :val4 OR attrib_2 = :prop4 AND value_2 >= :val4 OR attrib_3 = :prop4 AND value_3 >= :val4 OR attrib_4 = :prop4 AND value_4 >= :val4 OR attrib_5 = :prop4 AND value_5 >= :val4 OR attrib_6 = :prop4 AND value_6 >= :val4 OR attrib_7 = :prop4 AND value_7 >= :val4 OR attrib_8 = :prop4 AND value_8 >= :val4) AND (attrib_1 = :prop5 AND value_1 >= :val5 OR attrib_2 = :prop5 AND value_2 >= :val5 OR attrib_3 = :prop5 AND value_3 >= :val5 OR attrib_4 = :prop5 AND value_4 >= :val5 OR attrib_5 = :prop5 AND value_5 >= :val5 OR attrib_6 = :prop5 AND value_6 >= :val5 OR attrib_7 = :prop5 AND value_7 >= :val5 OR attrib_8 = :prop5 AND value_8 >= :val5) AND (attrib_1 = :prop6 AND value_1 >= :val6 OR attrib_2 = :prop6 AND value_2 >= :val6 OR attrib_3 = :prop6 AND value_3 >= :val6 OR attrib_4 = :prop6 AND value_4 >= :val6 OR attrib_5 = :prop6 AND value_5 >= :val6 OR attrib_6 = :prop6 AND value_6 >= :val6 OR attrib_7 = :prop6 AND value_7 >= :val6 OR attrib_8 = :prop6 AND value_8 >= :val6) AND (attrib_1 = :prop7 AND value_1 >= :val7 OR attrib_2 = :prop7 AND value_2 >= :val7 OR attrib_3 = :prop7 AND value_3 >= :val7 OR attrib_4 = :prop7 AND value_4 >= :val7 OR attrib_5 = :prop7 AND value_5 >= :val7 OR attrib_6 = :prop7 AND value_6 >= :val7 OR attrib_7 = :prop7 AND value_7 >= :val7 OR attrib_8 = :prop7 AND value_8 >= :val7) AND (attrib_1 = :prop8 AND value_1 >= :val8 OR attrib_2 = :prop8 AND value_2 >= :val8 OR attrib_3 = :prop8 AND value_3 >= :val8 OR attrib_4 = :prop8 AND value_4 >= :val8 OR attrib_5 = :prop8 AND value_5 >= :val8 OR attrib_6 = :prop8 AND value_6 >= :val8 OR attrib_7 = :prop8 AND value_7 >= :val8 OR attrib_8 = :prop8 AND value_8 >= :val8)) $limit"; $arr = array(":item_name" => $itemName, ":quality" => $Quality, ":type" => $Type, ":sub" => $sub_Type, ":prop1" => $itemAttrib1, ":val1" => $val_1, ":val2" => $val_2, ":val3" => $val_3, ":val4" => $val_4, ":val5" => $val_5, ":val6" => $val_6, ":val7" => $val_7, ":val8" => $val_8, ":prop2" => $itemAttrib2, ":prop3" => $itemAttrib3, ":prop4" => $itemAttrib4, ":prop5" => $itemAttrib5, ":prop6" => $itemAttrib6, ":prop7" => $itemAttrib7, ":prop8" => $itemAttrib8); $this->view->items = $this->database->DBQry($sql,$arr); $this->view->msg = "Successful Search"; $this->view->err = true; $this->view->render('Search/Index'); } } ?> here is the "Search/Index" View: <?php include_once("views/Header.php"); ?> <div class="container"> <?php if($this->err == true): ?> <div class="alert alert-success alert-dismissable"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> <?php echo $this->msg; ?> </div> <?php else: ?> <div class="alert alert-danger alert-dismissable"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> <?php echo $this->msg; ?> </div> <?php endif ?> <div class="well well-sm"> <div class="row col-xs-12"> <div class="btn-group"> <a class="btn btn-danger dropdown-toggle" data-toggle="dropdown" href="#" style="font-weight: normal;"><?php if ($url == '/us/sc') { ?>US Softcore<?php }elseif ($url == '/us/hc') { ?> US Hardcore <?php } ?> <span class="caret"></span> </a> <ul class="dropdown-menu open" style="padding: 5px;"> <li><a href="<?php echo $ahurl; ?>/sc">US Softcore</a></li> <li class="divider"></li> <li><a href="<?php echo $ahurl;?>/hc">US Hardcore</a></li> </ul> </div> </div> </div> <?php include("models/ItemSearch.php"); ?> <div class="row"> <div class="col-md-8"> <!-- Item --> <?php $count = 0; if (count($this->items)%3!=0) { //Append 1 or 2 items from start of array if needed } ?><div class="row"> <?php foreach ($this->items as $item): if (($count>0) and ($count%3==0)): ?></div><div class="row"><?php endif; ?><div class='col-md-4'> <div class="thumbnail"> <h4 <?php if ($item['quality'] == 'Legendary'): ?> class="item-title quality-orange" <?php elseif ($item['quality'] == 'Set'): ?> class="item-title quality-green" <?php elseif ($item['quality'] == 'Rare'): ?> class="item-title quality-yellow" <?php endif ?>><a class="item-title" style="text-decoration:none;" href="<?php echo $this->url; ?>Item-<?php echo $item['item_num']; ?>"><?php echo $item['item_name']; ?></a></h4> <a href="<?php echo $this->url; ?>Item-<?php echo $item['item_num']; ?>"> <img <?php if ($item['quality'] == 'Legendary'): ?> class="item-icon quality-orange" <?php elseif ($item['quality'] == 'Set'): ?> class="item-icon quality-green" <?php elseif ($item['quality'] == 'Rare'): ?> class="item-icon quality-yellow" <?php endif ?> src="<?php echo $this->url.$item['item_img']; ?>" align="left" /></a> <div class="caption"> <?php if ($item['armor'] == NULL){ echo ''; }else{ ?> <ul class="stat-basic"><li class="armor"><?php echo $item['armor']; ?></li>Armor</ul> <?php }if ($item['dps'] == NULL && $item['min_max'] == NULL && $item['aps'] == NULL){ echo ''; }else{ ?> <ul class="stat-basic"> <li class="dmg"><?php echo $item['dps']; ?></li><li class="dps"> Damage Per Second</li> <li><?php echo $item['min_max']; ?> Damage</li> <li><?php echo $item['aps']; ?> Attacks Per Second</li> </ul> <?php }?> <div class="prop"> <ul class="item-attrib"> <?php if($item['attrib_1'] == 'None' || $item['attrib_1'] == '' || $item['attrib_1'] == 'none' || $item['attrib_1'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_1']; ?> <?php echo $item['attrib_1']; ?></li> <?php }if ($item['attrib_2'] == 'None' || $item['attrib_2'] == '' || $item['attrib_2'] == 'none' || $item['attrib_2'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_2']; ?> <?php echo $item['attrib_2']; ?></li> <?php }if ($item['attrib_3'] == 'None' || $item['attrib_3'] == '' || $item['attrib_3'] == 'none' || $item['attrib_3'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_3']; ?> <?php echo $item['attrib_3']; ?></li> <?php }if ($item['attrib_4'] == 'None' || $item['attrib_4'] == '' || $item['attrib_4'] == 'none' || $item['attrib_4'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_4']; ?> <?php echo $item['attrib_4']; ?></li> <?php }if ($item['attrib_5'] == 'None' || $item['attrib_5'] == '' || $item['attrib_5'] == 'none' || $item['attrib_5'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_5']; ?> <?php echo $item['attrib_5']; ?></li> <?php }if ($item['attrib_6'] == 'None' || $item['attrib_6'] == '' || $item['attrib_6'] == 'none' || $item['attrib_6'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_6']; ?> <?php echo $item['attrib_6']; ?></li> <?php }if ($item['attrib_7'] == 'None' || $item['attrib_7'] == '' || $item['attrib_7'] == 'none' || $item['attrib_7'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_7']; ?> <?php echo $item['attrib_7']; ?></li> <?php }if ($item['attrib_8'] == 'None' || $item['attrib_8'] == '' || $item['attrib_8'] == 'none' || $item['attrib_8'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_8']; ?> <?php echo $item['attrib_8']; ?></li> <?php }if ($item['attrib_1'] == 'Has Sockets' && $item['value_1'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_1'] == 'Has Sockets' && $item['value_1'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_1'] == 'Has Sockets' && $item['value_1'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_2'] == 'Has Sockets' && $item['value_2'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_2'] == 'Has Sockets' && $item['value_2'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_2'] == 'Has Sockets' && $item['value_2'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_3'] == 'Has Sockets' && $item['value_3'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_3'] == 'Has Sockets' && $item['value_3'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_3'] == 'Has Sockets' && $item['value_3'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_4'] == 'Has Sockets' && $item['value_4'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_4'] == 'Has Sockets' && $item['value_4'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_4'] == 'Has Sockets' && $item['value_4'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_5'] == 'Has Sockets' && $item['value_5'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_5'] == 'Has Sockets' && $item['value_5'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_5'] == 'Has Sockets' && $item['value_5'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_6'] == 'Has Sockets' && $item['value_6'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_6'] == 'Has Sockets' && $item['value_6'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_6'] == 'Has Sockets' && $item['value_6'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_7'] == 'Has Sockets' && $item['value_7'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_7'] == 'Has Sockets' && $item['value_7'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_7'] == 'Has Sockets' && $item['value_7'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_8'] == 'Has Sockets' && $item['value_8'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_8'] == 'Has Sockets' && $item['value_8'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_8'] == 'Has Sockets' && $item['value_8'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php } ?> </ul> </div> </div> </div> </div><?php $count++; endforeach; ?> <!-- end item --> </div> </div> <ul class="pager"> <?php echo $this->first; echo $this->prev; echo $this->next; echo $this->count; echo $this->last; ?> </ul> </div> </div> </div> <?php include_once("views/Footer.php"); ?>
- 8 replies
-
- php
- pagination
-
(and 2 more)
Tagged with:
-
I'm looking for some advice on the best ways to handle the "view" part of the MVC pattern, specifically the loading of the view files, dependent on where you are in the system, what actions you've called, what the system requires, etc... In my previous projects, I've gone about this generally in two different ways. Method A: Example URL: mysite.com/report/view/1 Flow: Various routing & file including occurs Eventually this calls ReportController->view(1) which does whatever it needs to do..loads up a Report model with parameter "1", etc... Within the view() method we set the variables that we want to use in the ReportTemplate On __destruct of that controller object it calls Render() on the ReportTemplate object This Render method looks in "modules/reports/views" for 3 files: "header.html", "footer.html", <action>.html (in this case "view.html" If it can't find the <action> view, it looks for "index.html" If it can't find any of those files it loads the global files This way it automatically looks for a specific view for whatever module & action we have called Downsides to this include: Fairly limited in the layout as always have to have header, <action>, footer unless we override the Render() method for particular Templates, which isn't that big of a deal, just seems inelegant Might want to call a different template rather than just rely always on working it out from the querystring Method 2): Similar to Method A, but rather than having seperate template classes for each module and an overall Render() function that works the views out by itself, we manually load whatever templates we want, eg: ReportController->view(1) Does stuff Creates new Template object Template->set("somevar", $somevar)->set("var2", $var2)->etc... Template->load(/path/to/chosen/template) Template->display() Template->load(/path/to/some/other/template) Template->display() etc... Downsides of this include having to manually do it all the time. But it does allow to load whatever template/view you want, whenever you want. I'm aware neither of these is probably a particular good way to do it, so I was wondering what the best practices would be to actually handle the loading of views/templates in real-world professional systems. Thanks.
-
So I am working on an MVC application where the controller methods instantiate a factory that is suppose to return a model. In this case, the factory methods do some kind of work with a database or API to save/get/ data which then is placed inside a model and returned by the method. So lets say I have a factory method called createUser(email, password); Now I am going to call this method in the controller. I want my controller lean and mean and not fat! The model can be fat but NOT the controller and so my methods for validation at the moment are inside the model. Where do I call this validation? Inside the controller before the factory? Inside the createUser() method in the factory before it does it's database and api work to return a model??? Where?!? Here are two scenarios that come to mind: -Instantiate the User model inside the controller method before the factory and validate the input data. If it returns without any problems, send it to the factory to return a model of the User with the newly created data. -Instantiate the factory, call createUser(input data) and inside the create user method, do the model validation first before getting/saving the data to an API or database? If the validation fails in the createUser() method, return a model with error messages and any of the bad data. If their are no validation problems, return a model.
-
I am trying to create a rewrite rule that will let me keep the following URL clean: <script type="text/javascript" src="http://www.mysite.com/views/Page/js/jsfile1.js"></script> To be: <script type="text/javascript" src="http://www.mysite.com/js/jsfile1.js"></script> When I want to include JS and CSS files in any given view, I call: $this->view->js = array('Page/js/jsfile1.js', 'Page/js/jsfile2.js') ; Where Page would change according to the controller you are currently in. E.g. If I am on www.mysite.com/contact, any JS I load be redirected to: www.mysite.com/views/contact/js/jsfile1.js But in the header of my contact page you would only see: <script type="text/javascript" src="http://www.mysite.com/js/jsfile1.js"></script> How can this be done? Or does someone know of a better way to not expose the system directories such as /views etc in a PHP MVC framework (this is my own mini custom framework BTW)? I hope I'm making sense!
-
Hey, I'm a n00b on this forum, and this is my first thread/post. Hello to everyone! I just started a new position as a Senior PHP Developer to look at and improve the company's MVC application. It's a bit of a doozy, especially considering their MVC is built in-house. The controller methods, at least the key ones, are fat, fat, fat. A contract controller's edit method deals with not only prepping the page for editing, but also takes care of the saving once the form is submitted. At approximately 500 lines, it has if/for/while nesting issues, bad variable name conventions, no helpful comments. Very little of the saving logic is delegated to the models, as it should. To add to my troubles, the flow of the application itself is highly disjointed, business logic toggles I am missing are executed deep within nested if's/whiles/fors, and chews up my days quickly trying to lay breadcrumbs and track how/where my required values will be triggered. And once I figure out the ONE toggle I was missing, I get roadblocked by another one, found elsewhere, in another controller. So now the laying of breadcrumbs begins again. Frustrating. On a final note, the views themselves have a fair bit of logic, as well as deep nesting issues within them. SO I'd say they abide by MVC best practices 50% of the time. But man, that other 50%... I am about to have my first meeting with my manager to discuss the things I've seen, and managed to do, as well as have him lay out my initial tasks for improvements. My gut tells me we should start from scratch, but I doubt that will sell well. Another option would be to start fresh, in parallel with the current system. Here's a bit of logic I found in one VIEW... $i = 1; if ((is_array($contentForLayout[0]['x'])) & (!empty($contentForLayout[0]['x']))) { foreach ($contentForLayout[0]['form_config_archives'] as $EventForm) { if ($EventForm['order_id'] > 0) { echo '<tr>'; echo '<td><strong>Form # ' . $i . '</strong></td>'; $FormOpenDate = @strftime($DayTypeCall, strtotime($EventForm['form_open_date'])); if ($FormOpenDate == "December 31, 1969") { echo '<td class="red"><em>No Date Entered</em></td>'; } else { echo '<td>' . $FormOpenDate . '</td>'; } $FormCloseDate = @strftime($DayTypeCall, strtotime($EventForm['form_event_date'])); if ($FormCloseDate == "December 31, 1969") { echo '<td class="red"><em>No Date Entered</em></td>'; } else { echo '<td>' . $FormCloseDate . '</td>'; } $FormEventDate = @strftime($DayTypeCall, strtotime($EventForm['form_close_date'])); if ($FormEventDate == "December 31, 1969") { echo '<td class="red"><em>No Date Entered</em></td>'; } else { echo '<td>' . $FormEventDate . '</td>'; } if ($AllowOrderEdit == 1) { $EditOrderLink = '<a class="thickbox" href="/order/edit/' . $EventForm['order_id'] . '/1?width=1200&height=500" title="::Edit Form Order" style="text-decoration:underline;color:#0000FF">' . $EventForm['order_id'] . '</a>'; } echo '<td>'; echo $EditOrderLink; echo '</td>'; echo '<td>'; echo $EventForm['server']; echo '</td>'; echo '<td>'; echo $EventForm['peer_template']; echo '</td>'; $TotalPercent = $EventForm['donations_check'] + $EventForm['date_check'] + $EventForm['fields_check'] + $EventForm['basefee_check']; if ($TotalPercent < 50) { echo '<td style="color:#FF0000;font-weight:bold;">'; } else if (($TotalPercent > 51) && ($TotalPercent < 76)) { echo '<td style="color:#FF9900;font-weight:bold;">'; } else if (($TotalPercent > 76) && ($TotalPercent < 100)) { echo '<td style="color:#EE9900;font-weight:bold;">'; } else { echo '<td style="color:#009900;font-weight:bold;">'; } echo $TotalPercent . '%'; echo '</td>'; echo '<td>'; if ($EventForm['event_status_id'] == 0) { $TheFormStatus = '<span style="color:#FF0000;"><strong>Archive</strong></span>'; } else if ($EventForm['event_status_id'] == 1) { $TheFormStatus = '<span style="color:#009900;"><strong>Active</strong></span>'; } else if ($EventForm['event_status_id'] == 2) { $TheFormStatus = '<span style="color:#FF9900;"><strong>Pending/Test</strong></span>'; } else if ($EventForm['event_status_id'] == 3) { $TheFormStatus = '<span style="color:#B3B3A7;"><strong>Closed</strong></span>'; } echo $TheFormStatus; echo '</td>'; if ($AllowOrderEdit == 1) { $EditOrderForFormLink = '<a href="/event/forms/' . $EventForm['id'] . '/' . $EventForm['order_id'] . '/' . $contentForLayout[0]['order'][0]['contract_id'] . '/' . $contentForLayout[0]['order'][0]['event_id'] . '" title="::Edit Form Configuration"><img src="' . Utilities::getRelativePath() . 'images/icons/16/icon_quick_options_pub_16.png" /></a>'; } echo '<td>'; echo $EditOrderForFormLink . ' '; if (is_dir(ABSOLUTEROOTPATH . '/staging/' . $EventForm['order_id'])) { echo '<a title="::Staging Form" href="' . STAGINGPEER1URL . $EventForm['order_id'] . '/" target="_blank"><img src="' . Utilities::getRelativePath() . 'images/icons/16/icon_quick_testform_pub_16.png" /></a> '; } if (is_dir(ABSOLUTEROOTPATH . '/events/' . $contentForLayout[0]['subdir'] . '')) { echo '<a title="::Live Form" href="' . str_replace('events/', '', LIVEPEER1URL) . 'site/entryform/' . $contentForLayout[0]['subdir'] . '" target="_blank"><img src="' . Utilities::getRelativePath() . 'images/icons/16/icon_quick_liveform_pub_16.png" /></a> '; } if (file_exists(ABSOLUTEROOTPATH . '/events/' . $contentForLayout[0]['subdir'] . '/staff.php')) { echo '<a class="thickbox" title="::Staff Page" href="' . LIVEPEER1URL . $contentForLayout[0]['subdir'] . '/staff.php?TB_iframe=true&height=500&width=800"><img src="' . Utilities::getRelativePath() . 'images/icons/16/icon_quick_staffpage_pub_16.png" /></a>'; } echo '</td>'; echo '</tr>'; $i++; } else { echo '<td colspan="10"><br /><p>No archived forms available for this event.</p></td>'; } } } else { echo '<td colspan="10"><br /><p>No archived forms available for this event.</p></td>'; } At any rate, I figured asking for strategy advice on here may help me. Or at least get a bit of sympathy