masterdrue Posted March 11, 2013 Report Share Posted March 11, 2013 Hi.. Going through video's 11-12 for the creation of (m_categories.php), when I added the line of code, <?php $this->get_data('page_nav'); ?> in public header I ended up with a navigation that displayed the "li" tags themselves in the navigation. Index.php <li class="active"><a href="http://localhost/dapouda/">View All</a></li><li><a href="http://localhost/dapouda/index.php?id=3">Clothing</a></li><li><a href="http://localhost/dapouda/index.php?id=2">Electronics</a></li><li><a href="http://localhost/dapouda/index.php?id=1">Toys</a></li> So I went back through both videos and checked line for line any possible typo's, then copied in the project source to see if it would work correctly and I get the same result. Also note, that I did get the correct array output from the part of "echo pre tags" section. I rechecked public header <div class="secondarynav"> <strong>0 items ($0.00) in cart</strong> | <a href="<?php echo SITE_PATH;?>cart.php">Shopping Cart</a> </div> <h1><?php echo SITE_NAME; ?></h1> <ul class="nav"> <?php $this->get_data('page_nav'); ?> </ul> which appears to match the source project also. m_categories.php /* Create page parts */ /** * Returns an unordered list of links to all category pages * * @access public * @param string (optional) * @return string */ public function create_category_nav($active = NULL) { // get all categories $categories = $this->get_categories(); // set up all item $data = '<li'; if (strtolower($active) == 'home') { $data .= ' class="active"'; } $data .= '><a href="' . SITE_PATH . '">View All</a></li>'; // loop through each category if ( ! empty($categories)) { foreach($categories as $category) { $data .= '<li'; if (strtolower($active) == strtolower($category['name'])) { $data .= ' class="active"'; } $data .= '><a href="' . SITE_PATH . 'index.php?id=' . $category['id'] . '">' . $category['name'] . '</a></li>'; } } return $data; } One thing I did notice in Chromes view, was quotes after UL (see nav-error2).. So I'm ultimately at a loss and hope you can steer me down the right path. Thanks... Drue Quote Link to comment Share on other sites More sharing options...
falkencreative Posted March 12, 2013 Report Share Posted March 12, 2013 I'm not really seeing any mistakes in the code above, though it's possible I might be missing something. Can you post your template object's get_data() function? That's another thing that might be messing things up. Quote Link to comment Share on other sites More sharing options...
masterdrue Posted March 12, 2013 Author Report Share Posted March 12, 2013 Hi Ben, Thanks for the response. I assume your asking for m_template.php, if it's another file, let me know.. Thanks again.. /* Template Class handles all templating tasks - displaying views, alerts, errors and view data */ class Template { private $data; private $alert_types = array('success', 'alert','error'); function __construct(){} /* * Loads specified url * * @access public * @param string, string * @return null */ public function load($url, $title = '') { if($title !=''){$this->set_data('page_title',$title);} include($url); } /* * Redirects to specified url * * @access public * @param string * @return null */ public function redirect($url) { header("Location: $url"); exit; } /* Get Set Data */ /* * Saves provided data for use by the view later * * @access public * @param string, string, bool * @return null */ public function set_data($name, $value, $clean = FALSE) { if($clean = TRUE) { $this->data[$name] = htmlentities($value, ENT_QUOTES); } else { $this->data[$name] = $value; } } /* * Retrieves data based on provided name for access by view * * @access public * @param string, bool * @return string */ public function get_data($name, $echo = TRUE) { if(isset($this->data[$name])) { if($echo) { echo $this->data[$name]; } else { return $this->data[$name]; } } return ''; } /* Get Set Alerts */ /* * Sets an alert message stored in the session * * @access public * @param string, string (optional) * @return null */ public function set_alert($value, $type = 'success') { $_SESSION[$type][]=$value; } /* * Returns strings, containing multiple list items of alerts * * @access public * @param * @return null */ public function get_alerts() { $data =''; foreach($this->alert_types as $alert) { if (isset($_SESSION[$alert])) { foreach($_SESSION[$alert] as $value) { $data.= '<li class="' . $alert . '">' . $value . '</li>'; } unset($_SESSION[$alert]); } } echo $data; } } Quote Link to comment Share on other sites More sharing options...
falkencreative Posted March 12, 2013 Report Share Posted March 12, 2013 The only other thing I can think of is that maybe when you are creating the menu using set_data() in your controller, you're passing in "True" as the third parameter, meaning that htmlspecialchars() is being called, and any code is being escaped rather than being processed properly by the browser. If that isn't it though, I'm not really sure what's going on. If you've checked the controller code and made sure that the above isn't happening, you can try zipping your entire project and emailing it to me (ben [at] killersites.com) and I'll take a look as soon as I have time. Quote Link to comment Share on other sites More sharing options...
masterdrue Posted March 12, 2013 Author Report Share Posted March 12, 2013 Strange because I followed each video to suite..but theres always a margin for a typo.. I did perform the checks as was demonstrated. I'll go back through and swap out source for my code to see if i can isolate it and hone in on it.. thanks again.. Quote Link to comment Share on other sites More sharing options...
masterdrue Posted March 24, 2013 Author Report Share Posted March 24, 2013 Success... Unbelievable.. After line by line review, watching the video's umpteen more times.. i discovered that I misused the comparison operator in the get set data function in m_template.php. Before public function set_data($name, $value, $clean = FALSE) { if($clean = TRUE) //Notice 1 equal { $this->data[$name] = htmlentities($value, ENT_QUOTES); } else { $this->data[$name] = $value; } } After public function set_data($name, $value, $clean = FALSE) { if($clean == TRUE) { $this->data[$name] = htmlentities($value, ENT_QUOTES); } else { $this->data[$name] = $value; } } Unbelievable how 1 oversight can completely stop production. Quote Link to comment Share on other sites More sharing options...
falkencreative Posted March 24, 2013 Report Share Posted March 24, 2013 Yep, that would do it. It's an easy mistake to make. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.