Posted By

AskoJr on 10/06/10


Tagged

php paging pages


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

summer_charlie


Paging


 / Published in: PHP
 

URL: http://asko.tumblr.com/

I know this might not be the safest, most glorious and fantastic way to do this. But it works for me, very well. And if all goes well, it works for you too and produces http://yoursite.com/?view=page URL\'s. Of coarse you will need to create $config[\'view_folder\'] variable where all the .php files will be in.

  1. <?php
  2. if(isset($_GET["view"])){ $v = $_GET["view"]; }
  3.  
  4. // if page exists, we display it.
  5.  
  6. if(!empty($v) && file_exists($config['view_folder'].'/'.$v.'.php'))
  7. {
  8. require($config['view_folder'].'/'.$v.'.php');
  9. }
  10.  
  11. // if page doesn't exist, we show 404.
  12.  
  13. elseif(!empty($v) && !file_exists($config['view_folder'].'/'.$v.'.php'))
  14. {
  15. require($config['view_folder'].'/404.php');
  16. }
  17.  
  18. // if $v is empty, we display front page.
  19.  
  20. elseif(empty($v) && file_exists($config['view_folder'].'/index.php'))
  21. {
  22. require($config['view_folder'].'/index.php');
  23. }
  24.  
  25. // if $v empty and front page doesn't exist, we show 404.
  26.  
  27. elseif(empty($v) && !file_exists($config['view_folder'].'/index.php'))
  28. {
  29. require($config['view_folder'].'/404.php');
  30. }
  31.  
  32. // if aliens...
  33.  
  34. else{
  35. // silence.
  36. }
  37.  
  38. }
  39. ?>

Report this snippet  

You need to login to post a comment.