Welcome Guest, Not a member yet? Register   Sign In
Issue with $page in tutorial
#1

[eluser]Unknown[/eluser]
I'm following along in the tutorial, at the static pages section (very early, I know). I absolutely could not get this to load the pages I was asking it to (using the url http://127.0.1.1/index.php/pages/view/about ), and it always returned the 404. I added to the code section below, and found that the variable $page is being set to pages, like so:

application/views/pages/pages.php

That's clearly not correct. Using the url http://127.0.1.1/index.php/page2/view/about gives

application/views/pages/page2.php

Code:
<?php

class Pages extends CI_Controller {
public function view($pagein)
{
  if( ! file_exists('/var/application/views/pages/'.$pagein.'.php'))
  {echo '/var/application/views/pages/'.$pagein.'.php';
   show_404();}

This is probably really easy to fix for someone who knows this framework a bit better.
#2

[eluser]Unknown[/eluser]
I didn't find any cached files that might have been causing an issue, but I ran across another issue that when I changed one of my views, it took a while for the change to show up when I was using the test page. Is there a cache that I would have to clear to get this to update faster? I looked in Application/Cache, but there was nothing other than the index.html and .htaccess files.
#3

[eluser]nagata[/eluser]
if you worry so much about cache, here ya go a code blocking it for sure Wink
Code:
$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");
  $this->output->set_header("Cache-Control: post-check=0, pre-check=0", false);
  $this->output->set_header("Pragma: no-cache");
put it somewhere in your view function...




Theme © iAndrew 2016 - Forum software by © MyBB