Welcome Guest, Not a member yet? Register   Sign In
  Quick Tutorial on Templating
Posted by: El Forum - 10-28-2007, 08:43 AM - Replies (2)

[eluser]Eric Barnes[/eluser]
Here is a small tutorial I wrote that shows how we are using a model as a wrapper around the template system.

I hope it is useful for some. Wink

http://68kb.com/2007/10/28/templating-with-codeigniter/


  Cannot extend pagination class?
Posted by: El Forum - 10-28-2007, 07:12 AM - Replies (6)

[eluser]fancms[/eluser]
Because there are several config settings for pagination that I would use over and over again it made sense (to me) to create a function where, when using it, I could simply plug in the 2 or 3 variables needed and all would be well.

However, when I tried to create a library extending the Pagination class (which I assume is what I would need to do to extend said class), I keep getting a Fatal error that says the pagination class does not exist. I've tried several different methods, including loading the Pagination class prior to using my library, and still no go. I double-checked that the library I wrote was in the /application/libraries folder. I'm simply stumped.

Here's the code I have for my library:

Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Quickpage extends Pagination {
    
function Quickpage() {
     parent::Pagination();
    
}
    
function go($pageit,$totalrows,$perpage)
     {
          $domain = $this->config->item('base_url');
          $config = array("base_url" => $domain.$pageit,
                          "total_rows" => $totalrows,
                          "per_page" => $perpage,
          );
          
          $this->pagination->initialize($config);

          return $this->pagination->create_links();
     }    
    
}
?>

The pagination function works fine by itself, so I'm totally confused here 8-/


  Problem with storing CI session
Posted by: El Forum - 10-28-2007, 07:09 AM - Replies (2)

[eluser]KusTov[/eluser]
Hello
I’m using CI session, PHP 5, Explorer 6 (accept all cookies).
Sometimes session don't pass to another page. In the same page there is no problem. In the DB I can see session records.
SiteConfig.php:

Code:
error_reporting(E_ALL);


config.php:

Code:
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_encrypt_cookie']    = false;
$config['sess_use_database']    = true;
$config['sess_table_name'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent']    = FALSE;

$config['cookie_prefix']    = "";
$config['cookie_domain']    = "";
$config['cookie_path']        = "/";

I use session this way:
first page:
Code:
$error ="Bla bla";
$this->session->set_userdata(array('_MSG_USER'=> $error));
$this->session->userdata('_MSG_USER'); //here it works

Second page (prints nothing):
Code:
<?=$this->session->userdata('_MSG_USER')?>

In Firefox it seems work. But I use DB session. I don't understand what the bug ?
Help me !!!


  Reload Problem, user tend to submit data twice
Posted by: El Forum - 10-28-2007, 03:14 AM - Replies (22)

[eluser]iive[/eluser]
I have gone through the user guide about <a href="http://ellislab.com/codeigniter/user-guide/libraries/validation.html">validation</a> and I found that if we submit the form back to the same function in our controller and if user press F5 or Reload Button in their browser, it tends to insert the record twice into db...

Any solution to avoid this issue? as user might just click yes to resubmit the POST data again on the browser warning dialog.


  Making my own PHP framework.
Posted by: El Forum - 10-28-2007, 02:05 AM - Replies (4)

[eluser]Moult[/eluser]
Hi, as one of my learning projects, I have decided to make a PHP framework.

I have had experience in PHP, I know OOP, classes, and I have recently been learning about MVC (about a couple of weeks). I want to make a PHP framework. I have been recommended to look at codeignitor. I have tried making modules but that doesn't exactly each me more about the framework itself. I'm not exactly sure how to start making the framework, can anybody give me any tips?


  Simple method to highlight active link
Posted by: El Forum - 10-27-2007, 11:08 PM - Replies (6)

[eluser]John_Betong[/eluser]
Hi All,

Wish List
I have always wanted a simple solution to highlight the active page link.
&nbsp;

I stumbled upon
I came across an ingenious solution and adapted it very quickly to this CodeIgniter site.
&nbsp;

Theory
In order to get the links to be highlighted:
1. a simple line of CSS code is required
2. the view code requires an individual &lt;body id='&lt;?= $PAGE ?&gt;'&gt;
3. each link requires an additional unique CSS 'class' statement
&nbsp;

Implementation, additions and changes
&nbsp;
&nbsp;
CSS File

Code:
#home         .home,
  #privacy     .privacy,
  #terms         .terms,
  #about         .about,
  #contact     .contact,
  #bizarre     .bizarre,
  #wisdoms     .wisdoms,
  #quotes     .quotes,
    #debug         .debug  
    {
        background:#f33 none; color:#fff
    }
&nbsp;
&nbsp;

Controller Code
Code:
function index() {
       ...
       ...
      $this->j_view($data);
    }

    function privacy() {
       ...
       ...
      $this->j_view($data);
    }

    function terms() {
       ...
       ...
      $this->j_view($data);
    }

  function j_view($data) {

    // $PAGE is used in View &lt;body id='$PAGE'&gt;
    $tmp             = $this->uri->segment(2);
    $data['PAGE']    = empty($tmp) ? 'home' : $tmp;
    ...    
    ...   // $this->load->view(header, container, left, right, footer, etc  , $data, TRUE);
    ...    
    $output = $this->load->view('view_001', $data, TRUE);
    echo $output;
    
   }//endfunc j_view(...)
&nbsp;
&nbsp;

View code
Code:
&lt;html&gt;
  
  &lt;?= $header ?&gt;
  
  &lt;body id=&lt;?=$PAGE ?&gt; &gt;

        <div id='header'>
            <a href="../"             class="home">     Home      </a>  &nbsp; | &nbsp;
            <a href="../joke/privacy" class="privacy"> Privacy    </a>  &nbsp; | &nbsp;
            <a href="../joke/terms"   class="terms">     Terms      </a>  &nbsp; | &nbsp;
            <a href="../joke/about"   class="about">     About us   </a>  &nbsp; | &nbsp;
            <a href="../joke/contact" class="contact"> Contact us </a>        
        </div>  
        
      <div id='box_left'>
        <a href='../joke/bizarre/'    class='bizarre'>Bizarre Searches</a><br />
        <a href='../joke/quotes'      class='quotes'>Quotes</a><br />                    
        <a href='../joke/wisdoms'     class='wisdoms'>Wisdom stuff</a>
        <br /><br />
      </div>        
        
        ...
        ... // container, messages, footer, etc
        ...

    &lt;/body&gt;
&lt;/html&gt;
&nbsp;
&nbsp;
Cheers,

John_Betong
&nbsp;
&nbsp;


  Validation Collection
Posted by: El Forum - 10-27-2007, 07:26 PM - Replies (7)

[eluser]Phil Sturgeon[/eluser]
I know there are many ways in which the validation library can be improved as validation is a tricky matter, but for the purpose of this post I dont really care.

Im looking to build a compilation of useful validation extentions so we can perhaps get some of them added. Im always thinking of new ones, so to get the ball rolling...

Post: Greater Than, Less Than & Equal To

Updated: Updated link to a more useful source.

What else have you guys got eh? Making these in an extention is so much easier than using callbacks! :p


  FlashNotice Helper - EZ to use and Sexy too
Posted by: El Forum - 10-27-2007, 06:51 PM - Replies (7)

[eluser]Andy Blackwell[/eluser]
Download it from the WIKI page
Preview Image

Time for me to contribute back to the community! So here's my first attempt...

For those that use or would like to use those one-time informational messages that display after an action of some type (like success, error, warning, info), I've made a helper for them.

Autoload the helper and now anywhere in your app you can add messages with this syntax:

Code:
FlashNotice::add('Your message goes here', 'error');
// the second parameter is an optional message type which can be
// any of the predefined values (info, success, warning, error)
// defaults to 'success'

Use those throughout your app and the helper stores them all in a Session var 'FlashNotice'

Then to diplay it in your view (preferably place this in a template header or something, so you only have to write it once)
Code:
FlashNotice::display();
// if there are any messages it will compile and display them,
// then destroy the Session var that stored them.
// otherwise it won't print anything to the page

I have created a default look and feel for the display. To use it, just include the folder with the Css and images, and include the stylesheet in your html.

I included an example of javascript code to utilize the close buttons on the box, and make the FlashNotice disappear from the page. You could also turn it into a modal box with a few tweaks if you wanted.

Hope some people find it useful.

As is, it's PHP5 only, since I used some things like private and static methods...sorry PHP4'ers!

Download it from the WIKI page


  User Manual Typ0 - Date Helper
Posted by: El Forum - 10-27-2007, 04:41 PM - Replies (1)

[eluser]Phil Sturgeon[/eluser]

Quote:$timestamp = '1140153693';
$timezone = 'UM8';
$daylight_saving = TRUE;

echo gmt_to_local($timestamp, $timezone, daylight_saving);

Missing a $ on the daylight_saving variable.

I really do have nothing better to be doing! :p


  Make your model explode!
Posted by: El Forum - 10-27-2007, 04:37 PM - Replies (1)

[eluser]Phil Sturgeon[/eluser]
If you want some flames coming out of your server, try to load any model within itself. Its a silly thing to do, but this self refferencing cashed my pc while running as localhost!

What can I say, it was a long night, ran out of coffee and copy + pasted the wrong line... it could happen to you too!


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Latest Threads
Best Way to Implement Aff...
by InsiteFX
07-07-2025, 03:06 AM
curl + response body
by michalsn
07-06-2025, 10:14 PM
AssetConnect - a powerful...
by Crenel
07-06-2025, 04:08 PM
twig and view cell
by foxbille
07-05-2025, 01:58 AM
The pipe operator in PHP ...
by InsiteFX
07-04-2025, 04:18 PM
Heads up for users using ...
by FlavioSuar
07-04-2025, 11:33 AM
Table (view class) Row ID
by grimpirate
07-03-2025, 11:22 PM
Happy 4th Everyone
by InsiteFX
07-03-2025, 09:31 PM
AbuseIPDB Module
by InsiteFX
07-03-2025, 09:27 PM
tool bar not showing
by Luiz Marin
07-03-2025, 04:46 AM

Forum Statistics
» Members: 155,679
» Latest member: 777jonline
» Forum threads: 78,441
» Forum posts: 379,735

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB