Jump to content

longki

Member
  • Posts

    25
  • Joined

  • Last visited

Everything posted by longki

  1. Hello, I'm using codeigniter to construct my website. And, there is something strange. when I open this : http://localhost/kamarlpoas/news/blog/rik_maslao_aslku_huner_as_smaio/1/1/1/1/1/1/1/1/12/12/23/3/23/3/23/23/23/34/3/31 It will open http://localhost/kamarlpoas/news/blog/rik_maslao_aslku_huner_as_smaio So, in this case, my website ignore /1/1/1/1/1....etc My Question, how to make if someone open "http://localhost/kamarlpoas/news/blog/rik_maslao_aslku_huner_as_smaio/1/1/1/1/1/1/1/1/12/12/23/3/23/3/23/23/23/34/3/31", it will go to show_404 ?
  2. Thanks Ben. I've understood has used my own library :cheers:
  3. Hello, i try to make an Ajax pagination, but I got error. Here is my code : Here is My Panel Controller : <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Panel extends MY_AuthController { public function __construct() { parent::__construct(); $this->load->model("paneldata"); } public function index() { $this->load->view('template/header/panel.php'); $this->load->view('containt/panel.php'); $this->load->view('template/footer/panel.php'); } public function general_post($awal = 0) { $this->load->library('pagination'); $this->load->model('paneldata'); $config['base_url'] = base_url() . '/panel/general_post'; $config['total_rows'] = $this->paneldata->jumlahpost(); $config['per_page'] = 3; $this->pagination->initialize($config); $data['link'] = $this->pagination->create_links(); $data['row'] = $this->paneldata->postview($awal); //Transkrip Script $this->load->view("section/post.php",$data); } //SOME CODE BELOW HERE } Here is my Panel View for header (template/header/panel.php): <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> <?php echo link_tag('public/css/kickstart.css'); ?> <?php echo link_tag('public/css/kickstart.css'); ?> <?php echo link_tag('public/css/mine/panelstyle.css'); ?> <?php echo link_tag('public/css/mine/footer_acl.css'); ?> <?php echo '<script src="' . base_url() . 'public/js/jquery.min.js"></script>'?> <?php echo '<script src="' . base_url() . 'public/js/kickstart.js"></script>'?> <?php echo '<script src="' . base_url() . 'public/js/administration.js"></script>'?> </head> <body> And here is for content (containt/panel.php): <body> <div id="wrapper2"> <header id="logo" class="col_4"> <?php echo '<img src="' . base_url() . 'public/css/img/Logo2.png">'?> </header> <div id="tabcont" class="col_12"> <ul class="tabs left"> <li><a href="#tabr1">General</a></li> <li><a href="#tabr2">User</a></li> <li><a href="#tabr3">Gallery</a></li> <li><a href="#tabr4">Construction</a></li> </ul> <div id="tabr1" class="tab-content"> <div id="menu" class="col_3"> <ul class="menu vertical"> <li id="post"><a href="#">Post</a></li> <li id="events"><a href="#">Events</a></li> <li id="pages"><a href="#">Pages</a></li> <li id="user"><a href="#">User</a></li> <li><a href="#">Post</a></li> </ul> </div> <div id="content" class="col_9"> </div> </div> <div id="tabr2" class="tab-content">Tab2</div> <div id="tabr3" class="tab-content">Tab3</div> <div id="tabr4" class="tab-content"> <div id="menu" class="col_3"> <ul class="menu vertical"> <li id="post"><a href="#">Post</a></li> <li id="events"><a href="#">Events</a></li> <li id="pages"><a href="#">Pages</a></li> <li id="user"><a href="#">User</a></li> <li><a href="#">Post</a></li> </ul> </div> <div id="content" class="col_9"> </div> </div> </div> </div> Here is my javascript code for administration.js: $(document).ready(function() { /*UNTUK TABEL GENERAL*/ $('#tabr1 #content').load('panel/general_post'); $('#tabr4 #content').load('panel/construction_post'); $("#tabr1 #events").click(function(event){ $('#tabr1 #content').load('panel/general_event'); }); $("#tabr1 #post").click(function(event){ $('#tabr1 #content').load('panel/general_post'); }); $("#tabr1 #user").click(function(event){ $('#tabr1 #content').load('panel/general_user'); }); /*UNTUK TABEL CONSTRUCTION*/ $("#tabr4 #post").click(function(event){ $('#tabr4 #content').load('panel/construction_user'); }); /*UNTUK PAGINATION*/ $("#pagination a").click(function(event){ event.preventDefault(); /* get some values from elements on the page: */ //var $page = $( this ), // url = $page.attr( 'href' ); /* Send the data using post */ // var posting = load( url ); /* Alerts the results */ //posting.done(function( data ) { // alert("succes"); //$('#tabr1 #content').html(data); //}); alert('succes'); $('#isi').load('panel/general_user'); }); }); As you see, I use ajax to change the content of containt/panel.php. for example, if click at div#tabr1 #post, it will prevendefault and go to panel/general_post. After that, the content will change to section/post.php (because at function general_post on panel controller, it will load view section/post.php). Here is section/post.php : <!----><script type="text/javascript" src="http://localhost/2014/14_10_16_peduli_palu_ajax/public/js/jquery.min.js"></script> <script type="text/javascript" src="http://localhost/2014/14_10_16_peduli_palu_ajax/public/js/administration.js"></script> <!----> <a class="search" href="#">+ Advanced Search</a> <div style="clear:both"> </div> <a class="search" href="#"><i class="icon-refresh"></i> Refresh</a> <div style="clear:both"> </div> <div id="isi"> <table class="striped"> <tr> <td>Id</td> <td>Author</td> <td>Category</td> <td>Title</td> <td>Content</td> <td>Date Created</td> <td>Date Modified</td> <td>Action</td> </tr> <?php foreach($row as $r):;?> <tr> <td><?php echo $r->id; ?></td> <td><?php echo $r->author1; ?> <?php echo $r->author2; ?></td> <td><?php echo $r->category; ?></td> <td><?php echo $r->title; ?></td> <td><?php echo implode(' ', array_slice(explode(' ', $r->content), 0, 10)) . "..."; ?></td> <td><?php echo $r->date_created; ?></td> <td><?php echo $r->date_modified; ?></td> <td><a href="#"><i class="icon-edit"></i></a> <a href="facebook.com"><i class="icon-remove"></i></a></td> </tr> <?php endforeach; ?> </table> </div> <div id="pagination"> <?php echo $link; ?> </div> As you see in first and second line, I input the script. Why do i do this ? Because, section/post.php will not load any script in page, because section/post.php is just called by ajax (Look at admistration.js). But, if I do this, I got errors (I can't click <a> elements, I can't scroll the page, etc). And if i do not input the script (in first and second line on section/post.php), I can click the <a> elements, but the script is not worked (because section/post.php does not identify the script) What should I do ? I Hope you understand my question..
  4. I'm sorry Ben, I still do not understand enough to construct my own Library. I have used some instruction in your link, and get nothing. Here is my code. I think it's so tedious and troublesome to use this method. Here is my core controller <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class MY_HeaderController extends CI_Controller { public function __construct() { parent::__construct(); if(!($this->uri->segment(1))) { $this->data['tithead'] = 'Home - Paluadv'; }else if($this->uri->segment(3)){ if($this->uri->segment(2) == "blog"){ $this->load->model("paneldata"); $data = $this->paneldata->blogview($this->uri->segment(3)); if($data){ $this->data['tithead'] = $data[0]->title; } }else{ $this->data['tithead'] = ucfirst($this->uri->segment(3)) . ' - Paluadv'; } }else if($this->uri->segment(2)){ $this->data['tithead'] = ucfirst($this->uri->segment(2)) . ' - Paluadv'; }else if($this->uri->segment(1)){ $this->data['tithead'] = ucfirst($this->uri->segment(1)) . ' - Paluadv'; } } } Here is my actual Home Controller inherited from MY_HeaderController (my own controller) <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Home extends MY_HeaderController { public $data; public function __construct() { parent::__construct(); //$this->load->library('Template'); } public function index() { if ( ! $this->session->userdata('admin')) { $this->load->view('template/header/home.php',$this->data); //Repetition $this->load->view('containt/home'); //Second Repetition $this->load->view('template/footer/home.php'); //If not admin, call this view }else { /*Because in administration.php (additional view for admin) there is additional css, i use this code. */ $this->data['css'] = 'footer_acl'; $data['tithead']=$this->data['tithead']; $data['css']=array($this->data['css']); $this->load->view('template/header/home.php',$data); //Repetition $this->load->view('containt/home'); //Second Repetition $this->load->view('template/footer/administration.php'); //If admin, call this view } } function logout() { //remove all session data $this->session->unset_userdata('admin'); $this->session->sess_destroy(); redirect(base_url(), 'refresh'); } } Here is my header view. <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title><?php echo $tithead ?></title> <?php echo link_tag('public/css/mine/style.css'); ?> <?php echo link_tag('public/css/kickstart.css'); ?> <?php echo link_tag('public/css/mine/adminstyle.css'); ?> <?php if(isset($css)){ foreach($css as $c): echo link_tag('public/css/mine/' . $c. '.css'); endforeach; } ?> <?php echo '<script src="' . base_url() . 'public/js/jquery.min.js"></script>'?> <?php echo '<script src="' . base_url() . 'public/js/kickstart.js"></script>'?> </head> <body> //Some HTML STUFF To Identify whether the user is admin or not, I just use simple validation. But, as you see, there are some repetition code, and that is not efficient. As you tell me to use my own library, and i got trouble in that. Can you give me clue how to make library about this case ? Btw, here is my footer for admin <footer> <div class="tengah"> <div class="col_6"> <p>Site powered by Kickstart. Is created and developed by Andrew Skiolsa</p> <p></p> </div> <div class="col_6"> <p class="right">Copyright ® Andrew Skiolsa 2014 New York. All right Reserved</p> </div> <div class="acl col_6"> <?php echo anchor(base_url() . 'panel',"Administration Control Panel"); ?> | <?php echo anchor(base_url() . 'home/logout',"Log Out"); ?> </div> </div> </footer> </div> </body> </html> and for usual user <footer> <div class="tengah"> <div class="col_6"> <p>Site powered by Kickstart. Is created and developed by Andrew Skiolsa</p> <p></p> </div> <div class="col_6"> <p class="right">Copyright ® Andrew Skiolsa 2014 New York. All right Reserved</p> </div> </div> </footer> </div> </body> </html>
  5. Sorry, "Template" here is a helper ? as what i've understnad, in the template we have some functions that call menu1 (Menu that can be seen by user : Home, About, Contact Us, Gallery), and the other function is function that call menu2 (Menu that can be seen by admin : Home, About, Contact Us, Gallery, Settings).
  6. Hello, I just used Codeigniter here. And i'm just a beginner. In this case, i want to make a homepage. If guests open the homepage, the main menu will be : -Home -Gallery -About -Contact Us But, if admin open the homepage (After log in), the main menu will be : -Home -Gallery -About -Contact Us So, I tried to use this code FOR EACH CONTROLLER : public function index() { $this->load->helper('html'); $this->load->helper('url'); if($this->session->userdata('logged_in')) { $session_data = $this->session->userdata('logged_in'); $data['title'] = 'Home - Rubalang'; $data['username'] = $session_data['username']; $data['id'] = $session_data['id']; $data['name'] = $session_data['name']; $data['position'] = $session_data['position']; $this->load->view('templates/header', $data); $this->load->view('templates/menu1'); $this->load->view('home/home1'); $this->load->view('templates/footer', $data); } else{ $data['title'] = 'Home - Rubalang'; $this->load->view('templates/header', $data); $this->load->view('templates/menu1'); $this->load->view('templates/menuadmin'); $this->load->view('home/home1'); $this->load->view('templates/footer', $data); } } We can see, I've made 3 sections of menu. menu1 and menuadmin. I do this because if i combine thoose two menu, i can't separate which menu can be seen by Admin, and which menu can be seen by user/guests. But Actually it's tedious and troublesome. I have to write that code on every controller (Because that is main menu) Is there any proper way to implement that ?
  7. longki

    Php Framework Vs Cms

    That's the answer.. Thanks Ben.. Thanks so much.. your parable makes me understand
  8. longki

    Php Framework Vs Cms

    Sorry, I mean CMS ..
  9. longki

    Php Framework Vs Cms

    What kind of Web application that Joommla can't make, but PHP framework can ?
  10. What is the advantages and disadvantages of using CMS like joomla, wrodpress ? What is the different with using PHP framework?
  11. longki

    Laravel

    Hello Ben, it's simple question.. i Can't attach CSS Style in Laravel.. i'm so confuse, where is the precise place to save the css style ?
  12. longki

    Laravel

    Hello Ben, i've red the article that you gave to me.. Btw, i'm little bit confuse about this..
  13. longki

    Laravel

    Hello Ben, sorry for bothering you many times i have 1 question here.. 1. I have red about Filter in Laravel guide in http://palusport.com/l4.pdf (in page 20).. I don't quite understand about this code : Route::get('user', array('before' => 'old', function() { return 'You are over 200 years old!'; })); that I don't understand, what is the use of "Before" (There is After Function also) ? for example, i run this on my browser : http://localhost/public/index.php/user, it will be redirected to home.. i Know that, because inside filter.php, i found this : Route::filter('old', function() { if(Input::get('age') < 200) { return Redirect::to('home'); } }); But I don't know How it works ? i didn't see the 'age' Variable was sent ?
  14. longki

    Laravel

    http://palusport.com/l4.pdf This is the article that i read..
  15. longki

    Laravel

    I read an article about laravel, and get stuck in this section. Environment Configuration this is the article statement : Next, we need to instruct the framework how to determine which environment it is running in. The default environment is always production. However, you may setup other environments within the bootstrap/start.php file at the root of your installation. In this file you will find an $app->detectEnvironment call. The array passed to this method is used to determine the current environment. You may add other environments and machine names to the array as needed. 1 <?php 2 3 $env = $app->detectEnvironment(array( 4 5 'local' => array('your-machine-name'), 6 7 )); You may also pass a Closure to the detectEnvironment method, allowing you to implement your own environment detection: 1 $env = $app->detectEnvironment(function() 2 { 3 return $_SERVER['MY_LARAVEL_ENV']; 4 }); You may access the current application environment via the environment method: Accessing The Current Application Environment 1 $environment = App::environment(); I don't quite understand, what the functions for ?
  16. longki

    Laravel

    I want to ask something again.. I used to build website with these two files, index.php, and function.php .. i wonder, how laravel do it? in index.php, i just include function.php, and call the function get_header from function.php.. does laravel do like that as well? because, i think it's completely redundant if i have to write header for each page, whereas each pages has the same header.. index.php function.php
  17. longki

    Laravel

    Thanks Ben.. What about this ? http://www.palusport.com/public/ That is my website.. and i want to use laravel framework.. but i got the error message "Mcrypt PHP extension required. " what should i do?
  18. longki

    Laravel

    http://www.wikihow.com/Install-Laravel-Framework-in-Windows I'm following that article.. Btw, i have overcame the problem.. Thanks Ben.. Btw, i have red an article in http://laravel.com/docs, that after the installation, we learn about routing. So, i red this http://laravel.com/docs/routing.. It teachs about get, post, etc.. But i don't quite understand about that. Every time we want to post something, we have to go to routes.php ?
  19. longki

    Laravel

    Hello There.. i so confuse how to install laravel.. i have download the laravel, and also the composer.. after i red some article in the internet, they said that before we install the laravel, we have to enable the php_opensll first.. But i can't find it in php.ini.. And i have no file ext in xampp/php/ext.. What should i do?
  20. longki

    Codeigniter

    Thanks for the answer.. i've bought some books in local bookstore.. i was trying to use Controller in some Controller class.. But, i think i would not be longer to learn Codeigniter.. as you said earlier, i think i have to switch over to Laravel..
  21. longki

    Codeigniter

    Hello Everyone.. i want to ask many things about codeigniter.. I hope some of you can help me, because even google can't. i start with one question. 1. I have downloaded codeigniter from ellislab (CMIIW), and i found that the class Controller is written like this : "CI_Controller".. While in my textbook, the class Controller is written "Controller".. that's why, i can't use code from my book.. because, every time i replace the "CI_Controller" with "Controller", the code will not running properly.. :-( I need some help about codeigniter.
  22. longki

    Oop In Php

    Hello everyone.. I'm new in PHP.. i've learnt it for 4 months.. and i want to continue to OOP in PHP.. i've understood about OOP.. but i don't know how to use it in making a website.. I need some guide to guide me step by step.. And, where can i get the material of OOP in PHP ? Thanks in advance
  23. Thanks for your answer.. but, i want to make a shopping cart with my own skill.. what should i learn ? i have bought some books about OOP in PHP.. they explain about making a class, function, some patterns (database pattern, factory pattern, etc), but they don't explain how to use it with HTML, and CSS.. they don't explain how to make a website with oop.. i'm afraid that what i've learnt is useless..
  24. Hello everyone.. I want to ask you about how to make a e-commerce.. I've asked this to some people, they said that i have to master at this follow : 1. OOP in PHP 2. mastering one php framework 3. Ajax Is that true ? i want to make a website with a Shopping cart.. and, after i learnt about oop in php, what should i need ? i really confuse ..
×
×
  • Create New...