cgull 25 Light Poster

Hello,

I am trying the example from Bootstrap 3 for nested columns.

The problem is, the nested row is going out of the parent column.

So this code:

<div class="row" style="border: 1px solid red">
  <div class="col-md-9">
    Level 1: .col-md-9
    <div class="row" style="border: 1px solid blue">
      <div class="col-md-6">
        Level 2: .col-md-6
      </div>
      <div class="col-md-6">
        Level 2: .col-md-6
      </div>
    </div>
  </div>
</div>

The row with the blue border starts about 10px outside of the row with the red border.

Screenshot attached.
d20ec268e4f6a5a1a03172c26601f453
Why is that?

cgull 25 Light Poster

Thank you.

cgull 25 Light Poster

Thank you, was just wondering if one has better performance than the other.

cgull 25 Light Poster

Hello,

I am developing a site where I have once class file that deals with a few database tables.

My question is:

Is it better to have one big file (the class) and then require only this file or have a class for each table and then have more require statements in my code?

Thank you

cgull 25 Light Poster

Ok, checked another option, and it looks like what's breaking the sort of the array is the jquery datatable plugin that I use. The array returned is in the right order, but dataTable breaks it.

cgull 25 Light Poster

Thanks, but that didn't help, I am still getting this result:
1
10
2
3
4
5
6
7
8
9

cgull 25 Light Poster

Hello,

I have an array that I need to sort by keys.

The array looks like this:

Array
(
    [0] => Array
    (
        [question_title] => Question 8
            [question_description] => 
            [type_id] => 1
            [type_title] => Yes/No
            [question_number] => 8
        )

    [1] => Array
(
    [question_title] => Question 9
            [question_description] => 
            [type_id] => 1
            [type_title] => Yes/No
            [question_number] => 9
        )

    [2] => Array
(
    [question_title] => Question 10
            [question_description] => 
            [type_id] => 1
            [type_title] => Yes/No
            [question_number] => 10
        )

    [3] => Array
(
    [question_title] => Question 11
            [question_description] => 
            [type_id] => 1
            [type_title] => Yes/No
            [question_number] => 11
        )

    [4] => Array
(
    [question_title] => Question 7
            [question_description] => 
            [type_id] => 1
            [type_title] => Yes/No
            [question_number] => 7
        )
)

I need to sort this array by question number, the problem is I get this result
1
10
11
2
3

I tried many many ways, nothing works.

For example I tried:

usort($questions, function($a, $b) {
  return (int) $a['question_number'] - (int) $b['question_number'];
});   

And:

foreach ($questions as $key => $row) {
  $mykey = (int) $row['question_number'];
  $volume[$mykey] = array(
              'question_title'=>$row['question_title'],
              'type_title'=>$row['type_title'],
              'question_number'=>$row['question_number']
              );
}

sort($volume, SORT_NUMERIC);
$questions = $volume;

And:

foreach ($questions as $key => $row) {
  $mykey = (int) $row['question_number'];
  $volume[$mykey] = array(
                       'question_title'=>$row['question_title'],
                       'type_title'=>$row['type_title'],
                       'question_number'=>$row['question_number']
                       );
  }

array_multisort($volume, SORT_NUMERIC, $questions);
$questions = $volume;

Nothing works.

Any suggestions?

Thank you

cgull 25 Light Poster

Another update:
I added the class dataTable to the table, now when I go to the page I get an alert error:

DataTables warning (table id='example'): Requested unknown parameter '1' from the data source for row 0

cgull 25 Light Poster

An update:

My table looks like this now:

<table class="display" id="example" border="0" cellpadding="0" cellspacing="0">
    <thead>
    <tr>
    <th colspan="1" class="ui-state-default" rowspan="2">
    <div class="DataTables_sort_wrapper">
    Match<span class="DataTables_sort_icon css_right ui-icon ui-icon-carat-2-n-s"></span></div>
    </th>
    <th rowspan="1" colspan="3" class="ui-state-default" style="text-align:center">Results
    </th>
    </tr>
    <tr>
    <th colspan="1" rowspan="1" class="ui-state-default">
    <div class="DataTables_sort_wrapper">
    Team<span class="DataTables_sort_icon css_right ui-icon ui-icon-triangle-1-s"></span></div>
    </th>
    <th colspan="1" rowspan="1" class="ui-state-default">
    <div class="DataTables_sort_wrapper">Halftime<span class="DataTables_sort_icon css_right ui-icon ui-icon-carat-2-n-s"></span>
    </div>
    </th>
    <th colspan="1" rowspan="1" class="ui-state-default">
    <div class="DataTables_sort_wrapper">Final Score<span class="DataTables_sort_icon css_right ui-icon ui-icon-carat-2-n-s"></span>
    </div>
    </th>
    </tr>
    </thead>
    <tbody>
    <tr>
       <td>

            PBHS vs St Stithians<br>
            24/03/2012
        </td>

    </tr>

    <tr>

        <td></td>
        <td>PBHS 1st</td>
        <td></td>
        <td>14</td>
    </tr>

    <tr>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
    <tr>

        <td>

            PBHS vs St Stithians<br>
            24/03/2012
        </td>
        ....

Now I see the show xx entries and the search box, but I see much more than just 10 rows in the table and I still can't sort any column.

cgull 25 Light Poster

Hello,

This is the first time I am trying to use jQuery DataTable.

I read a lot of articles, but I can't make it work.

I hope someone can help.

I need to build a table that displays Rugby games scores.
The table I am building should look like this:

<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
    <thead>
        <tr>
            <th>Match</th>
            <th colspan="3">Results</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <th></th>
            <th>Team</th>
            <th>Halftime</th>
            <th>Final Score</th>
        </tr>
        <tr>
            <td colspan="4">Match: AA</td>
        </tr>
        <tr>
            <td></td>
            <td>Team A</td>
            <td class="center">1</td>
            <td class="center">2</td>
        </tr>
        <tr>
            <td></td>
            <td>Team B</td>
            <td class="center">1</td>
            <td class="center">2</td>
        </tr>
        <tr>
            <td colspan="4">Match: BB</td>
        </tr>
        <tr>
            <td></td>
            <td>Team A</td>
            <td class="center">1</td>
            <td class="center">2</td>
        </tr>
        <tr>
            <td></td>
            <td>Team B</td>
            <td class="center">1</td>
            <td class="center">3</td>
        </tr>
    </tbody>
</table>

I want the user to be able to sort the columns:
Match, Team, Halftime and Final Score.

The way my code is now, the user can't sort on anything and the Show entries and search input field are not there at all.

My jQuery code:

$(function() {
        $('#example').dataTable({
            bJQueryUI: true
        });
    });

I include these two files on the page:
<link rel="stylesheet" href="/shared/jQuery/jquery-ui-1.10.3.custom/css/smoothness/jquery-ui-1.10.3.custom.min.css">
<script src="/shared/jQuery/jquery.dataTables.js"></script>

Can someone please help?

cgull 25 Light Poster

Hello,

I am having a strange behaviour with jQuery slideToggle.

When I click the link with class "tracking" I want the div under it to slide down if it is "closed" and up if it is "open"

The problem I have is that when I click the link, the div slides down, up and down again.

If I use just toggle it works fine. Why is that?

My code:

<div id="trackAjax">
  <a href="#" data-orderid="<?php echo $orderId; ?>" class="tracking">Enter Tracking No</a>

  <div id="trackingBox<?php echo $orderId; ?>" style="display:none">
    <?php 
      $attr = array('id'=>'trackForm');
      echo form_open($url, $attr);
    ?>
    <div class="control-group <?php if(form_error('tracking_no')) echo 'error'; ?>" style="margin-bottom:2px">
      <?php echo form_input(array('name'=>'tracking_no', 'class'=>'input-medium trackingNo', 'style'=>'margin-bottom:2px', 'value'=>set_value('tracking_no', $tracking_no))); ?>
      <span class="help-block"><?php echo form_error('tracking_no'); ?></span>
      <?php echo form_submit('submit', 'Save', 'class="btn"'); ?>
      <input type="hidden" name="submitted" value="1" />
    </div>

  </div>
  <?php echo form_close(); ?>
</div>
<script>
$(function()
{
  $('.tracking').on('click', function() {
    var id = $(this).data('orderid');
    $('#trackingBox'+id).slideToggle();
    return false;
 });
});
cgull 25 Light Poster

Ok, found the problem, it was the csrf.

I added my function in the config file:
$config['csrf_exclude_uris'] = array('cart/admin/orders/set_paid');

And everything is back to normal.

cgull 25 Light Poster

Thanks pritaeas, but I see this library is still in development so rather not use it.

cgull 25 Light Poster

Hello,

I am developing a site with ci 2.1.4

I used this tutorial to create an event in google calendar:
Click Here

When I change a date on the view, it calls the controller function with ajax, used to work fine, now the page just hangs and I can’t figure out what is going on.

My controller function (Calling create_event from the zend_helper):

public function set_paid()
 {
  $this->load->helper('zend');

  some code here....

  $title = $firstName . ' ' . $lastName . ' - order has been paid.';
  $where = 'Clarens';

  $content = "Order Details:\n";
  foreach($dets as $item)
  {
   $qty = $item['qty'];
   $coffee = $item['coffee'];
   $weight = $item['weight'];
   $content .= "Qty: $qty\nCoffee: $coffee\nWeight: $weight\n\n";
  }

  $content .= "Postage type: $postageType\n\n";
  $content .= "\nPostal Address:\n";

  foreach($addr as $item)
  {
   $addrLine1 = $item->addr_line_1;
   $addrLine2 = $item->addr_line_2;
   $suburb = $item->suburb;
   $city = $item->city;
   $postCode = $item->post_code;
   $province = $item->province;

   $content .= "$addrLine1\n";
   if($addrLine2)
    $content .= "$addrLine2\n";
   $content .= "$suburb\n$city $postCode\n$province"; 
  }

  create_event($title, $where, $content);

My zend helper:

<?php
//Changed this today, copied the Zend folder to application/libraries
/*if(ENVIRONMENT != 'production')
{
 ini_set("include_path", ini_get("include_path").PATH_SEPARATOR.str_replace("/", "\\", BASEPATH)."contrib\\");
 require_once ('Zend/Loader.php');
}
else
{
 ini_set("include_path", ini_get("include_path").PATH_SEPARATOR.BASEPATH."/contrib/");
 require_once 'Zend/Loader.php';
}*/
require_once (APPPATH . 'libraries/Zend/Loader.php');

function create_event($title, $where, $content)
{
 Zend_Loader::loadClass('Zend_Gdata_Calendar');
  Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
  // Parameters for ClientAuth authentication

 $user = "user";
 $pass = "pass";

 $service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
 $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
 $service = new Zend_Gdata_Calendar($client);

 // Create a new entry using the calendar service's magic factory method
 $event= $service->newEventEntry();

 // Populate the event with the desired information
 // …
cgull 25 Light Poster

My view IS php, I only posted the jquery part of it that was causing the problem.

cgull 25 Light Poster

Ok, changed this as well:
var postData = "type="+type + "orderId=" + orderId + "subtotal=" + subtotal;
To:
var postData = "type="+type + "&orderId=" + orderId + "&subtotal=" + subtotal;

Now it works, but the question is, is there no way to send the values without JSON and get the response as JSON?

cgull 25 Light Poster

Ok, found one problem:
alert(data.subtotal . ' ' . data.postage);
Changed to:
alert(data.subtotal + ' ' + data.postage);

So now the ajax call works, so now my code looks like this:

$.ajax({
            type: "POST",
        //  dataType: "json",
            //data: postData,
            data: { orderId: orderId, type: delivery_type, subtotal: subtotal },
            /*beforeSend: function(x) {
                    if(x && x.overrideMimeType) {
                            x.overrideMimeType("application/json;charset=UTF-8");
                    }
            },*/
            url: "<?php echo site_url('cart/calculate_delivery'); ?>",
            success: function(data)
            {
                    // 'data' is a JSON object which we can access directly.
                    // Evaluate the data.success member and do something appropriate...
                    alert(data.subtotal + ' ' + data.postage);
                    $('#delivery_cost').html(data.postage);
                    $('#total').html(data.total);
            }
        });

Alerting data.subtotal and data.postage I get:
undefined undefined

cgull 25 Light Poster

Tried that as well:

type: "POST",
        //  dataType: "json",
            //data: postData,
            data: { orderId: orderId, type: delivery_type, subtotal: subtotal },

Nada, nothing

cgull 25 Light Poster

Hello,

This is my first time trying to make an ajax call with JSON.

I am developing a site with CodeIgniter 2.1.4.

I am on the verge of throwing my computer away and find a job selling flowers....

Here's the story:

In my view I have a dropdown box:
<?php echo form_dropdown('delivery', $delivery, '1', 'id="delivery"'); ?>

When the user selectes a value in the dropdown box, I want to send some values to my controller and return some values.

In my view:

    $('#delivery').on('change', function()
    {
        var delivery_type = $(this).val();
        var orderId = $('#orderId').val();
        var subtotal = $('#subtotal').val();

        var postData = "type=" + delivery_type + "orderId=" + orderId + "subtotal=" + subtotal;
        alert(postData);

        $.ajax({
            type: "POST",
            dataType: "json",
            data: postData,

            beforeSend: function(x) {
                    if(x && x.overrideMimeType) {
                            x.overrideMimeType("application/json;charset=UTF-8");
                    }
            },
            url: "<?php echo site_url('cart/calculate_delivery'); ?>",
            success: function(data) {
                    // 'data' is a JSON object which we can access directly.
                    // Evaluate the data.success member and do something appropriate...
                    alert(data.subtotal . ' ' . data.postage);
                    $('#delivery_cost').html(data.postage);
                    $('#total').html(data.total);
            }
        });

        return false;
    });

It looks like the controller does not get all the posted values, so I am trying to test what is getting through.

My controller:

public function calculate_delivery($type=NULL)
    {
        if(!$type)
        {
            $ajax = TRUE; //Called from ajax, need to echo the result
            $type = $this->input->post('type');
        }
        else
        {
            $type = 2;
            $ajax = FALSE;//Not called from ajax, need to return the result
        }

        //Calculating postage
        $totalWeight = 0;
        $orderId = $this->get_open_order();
        $order = $this->order_dets_m->get_open_order($orderId);

        if($order)
        {
            foreach($order …
cgull 25 Light Poster

Hello,

I am looking at a git course and codeigniter best practice in tutsplus.

I am totally lost with all the installations I did since yesterday.

I installed git, cygwin and composer.

Now in the cygwin terminal I write: <code>composer -V</code> and I get my composer version.

Then I go to where my codeigniter site is installed: c:\sites\ci
And I put <code>echo @php "%~dp0composer.phar" %*>composer.bat</code> and I get the message: Could not open input file: composer.phar

Can you help please? I am totally confused with all these tools.

Do I need cygwin? I looked at google for hours and I just don't know where to go from here.

Can someone maybe help?

cgull 25 Light Poster

Ok, sorry, as you can see I try lots of things....

The folder is now in the public_html folder.

Now if I go to:
dev.mysite.co.za I get 404 Page not found

if I go to mysite.co.za/dev I get the Index of page.

What I really want is to get my index.php page that sits in: public_html/dev/public_html.... lol cry lol

cgull 25 Light Poster

Update:

I moved the dev folder to the root folder so now I actually have a sub domain...

But now When I go to: dev.mysite.co.za I get this default web page with instructions:

If you are the web site owner, it is possible you have reached this page because:

The IP address has changed.
There has been a server misconfiguration.
The site may have been moved to a different server.

I wrote my host, and will post here if I find the answer.

cgull 25 Light Poster

Hello,

I need help with htaccess and a sub domain.

I have a site I developed with ci 2.1.3

My folders structure is:
c:\sites\mysite
c:\sites\mysite\application
c:\sites\mysite\system
c:\sites\mysite\public_html\index.php
c:\sites\mysite\public_html\assets

In the public_html folder I have the htaccess file:

RewriteEngine On
RewriteCond $1 !^(index\.php|assets|images|robots\.txt|captcha)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] 

Now I uploaded my site to the live server to a sub directory called: dev
I created a subdomain: dev.mysite.co.za

I uploaded all the files to the dev directory.

When I go to: dev.mysite.co.za

I get the page Index of with a list of the directories that are in the dev directory.

What do I need to do in order to see the site on the sub domain?

Can someone please help?

cgull 25 Light Poster

And I used to love Firefox.... lol

cgull 25 Light Poster

cereal, you found it! autocomplete, solved the problem.
I tested it on Chrome and it was fine without the autocomplete, but firefox needed it.
I just don't understand why does it happen only on this form and not on other forms in my app.
WOW, thank you very much.

cgull 25 Light Poster

Just one more thing, the strangest thing is, after I refresh the page, I look at the page source and the fields values are equal ''. For example:

<div class="control-group ">
    <label>Name *</label>
    <input type="text" name="author" value="" class="input-large"  />    <span class="help-block"></span>
  </div>

But on th page itself I see this: Name: cgull, which is the name I inserted into the field and then submitted the form.

The source says value = '' so how does it display cgull in the name field???

This is driving me nuts.

cgull 25 Light Poster

Hi cereal,

Sorry, I wasn't on my comupter the whole day.

My problem is that I submit the form successfuly. The input fields are cleared. Then I refresh the page, and the input fields have the values that I submitted in them again.

I will look at your code deeper tomorrow as I can't do it now.

Looked at it quickly and it is a bit different than my code, so I need to figure out why your code works and mine doesn't.

I will post here if I find the solution.

Thank you very much for all the effort.

cgull 25 Light Poster

Ok, I still have a problem, when I refresh the page, after submitting the form, the values are back in the input fields.... any idea how to fix that as well?

cgull 25 Light Poster

cereal you're a STAR !!!!

I've been struggling with this problem for days, posted about it all over the world, your solution sloved the problem.

I can't thank you enough !!!

THANK YOU ! :)

cgull 25 Light Poster

Hi cereal,

What it does is creating an object with the input fields and setting their values to blanks.

cgull 25 Light Poster

Hello,

I am developing a site with CI 2.1.3

I have a blog module, in this blog I have a form to post a comment.

I am calling this form inside a view with:
echo Modules:: run('blog/comment');

When I submit this form with ajaxForm, or refresh the page, the values of the input fields are not being cleared.

My controller’s function for the comment form:

public function comment($postId)
{
 $this->load->helper('form');
 $this->data['success'] = FALSE;
 $this->data['postId'] = $postId;

 if(!isset($_POST['comment_submit']))
 {     
   $this->data['new_comment'] = $this->blog_comment_m->get_new();
 }
 else
 {
  $this->data['new_comment'] = $this->blog_comment_m->object_from_post(array('author', 'authur_email', 'content'));
  $this->load->library('form_validation');
  $rules = $this->blog_comment_m->rules;
  $this->form_validation->set_rules($rules);

  if($this->form_validation->run() == TRUE)
  {
    $this->data['success'] = TRUE;
        $this->data['new_comment'] = $this->blog_comment_m->get_new();
  }
 }

 $this->load->view('add_comment', $this->data);
}

The comment form:

<div id="commentAjax">
<?php $attr = array('id'=>'commentForm'); echo form_open(site_url('blog/comment/' . 

$postId), $attr); ?>
  <input type="hidden" name="post_id" value="<?php echo $postId; ?>" />
  <div style="border-top:2px groove #930"><h4>Leave a Comment</h4></div>

  <div class="control-group <?php if(form_error('author')) echo 'error'; ?>">
    <label>Name *</label>
    <?php echo form_input(array('name'=>'author', 'class'=>'input-large', 'value'=>set_value('author', $new_comment->author))); ?>
    <span class="help-block"><?php echo form_error('author'); ?></span>
  </div>

  <div class="control-group <?php if(form_error('author_email')) echo 'error'; ?>">
    <label>Email *</label>
    <?php echo form_input(array('name'=>'author_email', 'class'=>'input-large', 'value'=>set_value('author_email', $new_comment->author_email))); ?>
    <span class="help-block"><?php echo form_error('author_email'); ?></span>
  </div>

  <div class="control-group <?php if(form_error('content')) echo 'error'; ?>">
    <label>Comment *</label>
    <?php echo form_textarea(array('name'=>'content', 'value'=>set_value('content', $new_comment->content))); ?>
    <span class="help-block"><?php echo form_error('content'); ?></span>
  </div>
   <div>
        <?php echo form_submit('submit', 'Send Comment', 'class="btn btn-submit"');?>
      <input type="hidden" name="comment_submit" value="1" />
  </div>
  <?php echo form_close(); ?>

    <?php if($success): ?>
    <div style="border:1px solid #666; background:#9F9; color:#000; margin-top:10px; width:50%; padding:5px; font-weight:bold">
      <p>Thank you for your comment.</p>
      <p>To avoid spam, your comment has been submitted for approval.</p> …
cgull 25 Light Poster

OHHHH ! I FOUND IT!!!!

Oh dear, oh dear, it was the fact that I started using csrf on form submits, a new thing for me, and I didn't add this url to the config file.

Adding this:
$config['csrf_exclude_uris'] = array('blog/admin/review_comment');
Solved the problem......

OHHHHHHHHHHHHHHHHHHHHHH :)

Thank you very very much for all the help.

cgull 25 Light Poster

Sorry, another thing, the url is: mysite/admin/blog/review_comment
In my routes file I have this:

$route['blog/(:any)/(:num)'] = 'blog/$1/$2';
$route['blog/admin/$1/$2'] = 'blog/admin/$1/$2';

I tried without: $route['blog/(:any)/(:num)'] = 'blog/$1/$2';
didn't help

I tried without: $route['blog/admin/$1/$2'] = 'blog/admin/$1/$2';
didn't help

I tried without both, didn't help.

cgull 25 Light Poster

Sorry Atli, didn't see your other answer. Thank you for trying to help again.
If I look at the NET tab in firebug I see this: Status: 302 error found (Read about that, I am not redirecting anything not sure why I get this error.
In the Post tab I see this:
Parameters comment_id = 1
Source comment_id = 1 So it all looks fine to me? Is there anything else I should check? Thank you very much
I also went to the url directly and the url works fine.

Someone in stackoverflow suggested it might be something in my htaccess file but I don't think so. My htaccess file:

RewriteEngine On
RewriteCond $1 !^(index\.php|assets|images|robots\.txt|captcha)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

This is so frustrating..... :(

cgull 25 Light Poster

Thanks Atli, but that didn't help. $this->input->post("comment_id") is the same as $_POST['comment_id']. I don't think it matters if I use the ci function or not.

I tried your way anyway, and the $id remains blank.

I don't understand what is going on. Works fine everywhere else I use an ajax call in the application.

cgull 25 Light Poster

Thanks Atli, but that didn't help. $this->input->post("comment_id") is the same as $_POST['comment_id']. I don't think it matters if I use the ci function or not.

I tried your way anyway, and the $id remains blank.

I don't understand what is going on. Works fine everywhere else I use an ajax call in the application.

cgull 25 Light Poster

Hello,

I am developing a web site with codeigniter 2.1.3

I am using an ajax call to post data to my controller, but for some reason the data is not being sent.

I am using ajax calls all over the application and they all work well just not this one.

My view:

<div id="ajaxResult">
<div class="page-header"><h2>Review Comments</h2></div>
<div class="row-fluid">
    <div class="span12">
    <?php if(count($comments)): ?>
    <table class="table">
        <thead>
        <tr>
            <th>Author</th>
          <th>Email</th>
          <th>IP Address</th>
          <th>Date</th>
          <th>Comment</th>
          <th>Approve</th>
        </tr>
      </thead>
      <tbody>
        <?php foreach($comments as $comment): ?>
        <tr>
            <td>
                        <?php echo $comment->comment_author; ?>
          </td>
          <td><?php echo $comment->comment_author_email; ?></td>
          <td><?php echo $comment->comment_author_IP; ?></td>
          <td>
                        <?php
                            $date = new DateTime($comment->comment_date);
                            $date = $date->format('d/m/Y');

                            echo $date;
                        ?>
                    </td>
          <td>
            <?php echo $comment->comment_content; ?>
          </td>
          <td>
            <?php 
                        $approve = array(
                                        'name'        => 'comment_approved',
                                        'class'          => 'approve',
                                        'value'       => '1',
                                        'data-commentid' => $comment->id
                                        );

                        echo form_checkbox($approve);
                        ?>
          </td>
        </tr>
        <?php endforeach; ?>
      </tbody>
    </table>

    <?php else: ?>
    <p>No comments were found for review.</p>
    <?php endif; ?>
  </div>
</div>
</div>
<script>
$(function()
{
    $('.approve').on('click', function()
    {
        var id = $(this).data('commentid'); alert(id);

        $.ajax({
                    url: "<?php echo site_url('blog/admin/review_comment'); ?>",
                    type:'POST',
                    data: { comment_id: id },
                    success: function(data) { $('#ajaxResult').html(data); } // End of success function of ajax form
        }); // End of ajax call
    });
});
</script>

My controller function:

public function review_comment()
    {
        $this->load->helper('form');
        $this->load->model('blog_comment_m');

        if(isset($_POST['comment_id']))
        {
            $id = $this->input->post('comment_id');
            $data['comment_approved'] = 1;

            $this->blog_comment_m->save($data, $id);

            $this->data['comments'] = $this->blog_comment_m->get_by(array('comment_approved'=>0));
            $this->load->view('admin/review_comments', $this->data);
        }
        else
        {
            $this->data['comments'] = $this->blog_comment_m->get_by(array('comment_approved'=>0));
            $this->data['subview'] = 'admin/review_comments';
            $this->load->view('admin/_layout_main', $this->data);
        }
    }

I tried to alert …

cgull 25 Light Poster

Ok, somehow it works now. Thanks guys

cgull 25 Light Poster

Hello,

I need help with a menu I'm creating with a sprite image.

I don't know why, but on hover it moves up what looks like 1 pixel.

I have created a jsfiddle for it here: Click Here

Also, first time I am creating a jsfiddle so hope it's ok.

Can someone please help?

cgull 25 Light Poster

Thanks, but that won't work on the live server?

cgull 25 Light Poster

Sorry, maybe I should add some of my code here:
In my controller I have this code:

$filename = 'mypdf.pdf';
$pdfFilePath = "../uploads/$filename";

if(file_exists($pdfFilePath) == FALSE)
{
    ini_set('memory_limit','128M');
    $html = $this->load->view('email/invoice', $data, true); // render the view into HTML

    $this->load->library('pdf');
    $pdf = $this->pdf->load();
    $pdf->SetFooter($_SERVER['HTTP_HOST'].'|{PAGENO}|'.date(DATE_RFC822)); 
    $pdf->logo = file_get_contents(site_url('assets/img/logo.png'));
    $pdf->WriteHTML($html); // write the HTML into the PDF
    $pdf->Output($pdfFilePath, 'F'); // save to file because we can
}

$subject = 'Your order with Highland Coffee Roastery';
$body = 'email/send_order';
$emailToName = $data['user']->first_name . ' ' . $data['user']->last_name;

$attach = $pdfFilePath;
$emailSent = sendEmail('info@mysite.co.za', 'My Site', 'noreply@mysite.co.za', 'NoReply', $data['user']->email, $emailToName, $subject, $body, $data, $attach);

In my send email helper:

function sendEmail($fromEmail, $fromName, $replyTo, $replyToName, $emailTo, $emailToName, $subject, $body, $bodyData, $attach='')
{
    require_once APPPATH."libraries/phpmailer/class.phpmailer.php";
    $mail = new PHPMailer();
    $CI =& get_instance();

    $body             = $CI->load->view($body, $bodyData, TRUE);    $mail->IsSMTP(); // telling the class to use SMTP
    $mail->SMTPDebug  = 0;// enables SMTP debug information (for testing)
    $mail->IsHTML(true);

    if(ENVIRONMENT == 'development')
    {
        $mail->SMTPAuth   = true;                  // enable SMTP authentication
        $mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
        $mail->Host       = 'smtp.gmail.com'; // SMTP server
        $mail->Port       = 465;                    // set the SMTP port for the GMAIL server
        $mail->Username   = "myemail@gmail.com";     // GMAIL username
        $mail->Password   = "password";            // GMAIL password
    }

    $mail->SetFrom($fromEmail, $fromName);
    $mail->AddReplyTo($replyTo, $replyToName);
    $mail->Subject    = $subject;
    $mail->AltBody    = "To view the message, please use an HTML compatible email viewer!";     // optional, comment out and test
    $mail->MsgHTML($body);

    $address = $emailToName . ' ' . $emailTo; //"recipient address@someadress.com";
    $mail->AddAddress($emailTo, $emailToName);

    $logo = 'logo_small.png';
    $logoUrl = 'assets/img/logo_small.png';

    $mail->AddEmbeddedImage($logoUrl, 'logo', …
cgull 25 Light Poster

Hello,

I am developing a site with Codeigniter 2.1.3.

I am creating a pdf file with mpdf and I save the file in a folder outside the root folder.
So my folders look like this:
c:/mysite/uploads/mypdffile.pdf
c:/mysite/public_html

I looked at all kind of tutorials and forum posts about the php header function, but I can't understand how to use it to get the file.

I am using: $mail->AddAttachment($mypdf) but how do I get the file if it is in a folder outside the root folder?

Can someone please help?

Thank you

cgull 25 Light Poster

Managed to solve the problem, it was a mistake in the login form:
echo form_open(site_url('auth/login', $attr);
Should be:
echo form_open(site_url('auth/login'), $attr);

cgull 25 Light Poster

I am developing a site with Codeigniter 2.1.3

I am using HMVC to create ion_auth modules.

I am trying to separate my frontend and backend login system.

I created two modules for ion_auth: application/modules/auth - for the frontend application/modules/admin - for the backend

Both have the same files, except the admin auth controller is calling a different login view.

My homepage view calls the login view like this:

echo Module::run('auth/login');

Both auth controllers extend Frontend_controller which extends MY_Controller. MY_Controller is in application/core and it extends MX_Controller.

The login view for the frontend is using ajaxForm to submit the form:

<div id="login_form">
<?php
 $attr = array('class'=>'form-inline', 'id'=>'loginForm');
 $send = array('class'=>'btn btn-inverse', 'name'=>'signin', 'value'=>'Sign In');
 echo form_open(site_url('auth/login', $attr));
?>
<div >
 <img src="<?php echo site_url('assets/img/login.gif'); ?>" alt="Login" />
</div>
<div  left; font-size:11px; font-weight:bold;padding-top:25px;margin-right:45px">LOGIN</div>

<div left">
 <?php echo form_label('Cellphone', 'cellphone', array('class'=>'login-label')); ?>
</div>
<div class="span2"  padding-top:10px"><?php echo form_input('identity', set_value('identity', ''), 'placeholder="cellphone no" class="span2 phone" id="cellphone"'); ?></div>

<div left; margin-left:10px"><?php echo form_label('Password', 'password', array('class'=>'login-label')); ?></div>
<div class="span2"  padding-top:10px"><?php echo form_password('password', '', 'placeholder="password" class="span2" id="password"'); ?></div>
<div class="span1" ><?php echo form_submit($send); ?></div>
<input type="hidden" name="submitLogin" value="1" />
<?php echo form_close(); ?>
<div class="clearfix"></div>
</div>
<script>
$(function()
{
 var options = { 
 target: '#login_form',
 success:       showResponse  // post-submit callback 
 };

 $('#loginForm').ajaxForm(options);

// post-submit callback 
function showResponse(responseText, statusText, xhr, $form)  { 
   alert('status: ' + statusText + '\n\nresponseText: \n' + responseText + 
        '\n\nThe output div should have already been updated with the responseText.'); 
} 
});
</script>

I have a few problems:

Problem One: I read through the …

cgull 25 Light Poster

@JorgeM - It slides very quickly, it opens a div with a menu and text.

@RoryGren - If I try overflow: auto; on my sliderbox class it opens too big, it includes the li item in it as well.

Thank you

cgull 25 Light Poster

Hi,

I've made some changes so here is the url: Click Here

You can see the problem under the Phonebook section, first CLICK FOR MENU button under Kouga/Uitenhage
You can see that when it slides down, it hides the bottom border of the parent div.

My jquery:

$('.moreBtn').on('click', function()
    {
        $(this).parent().next().slideDown();
        //console.log($($(this).parent().next()));
//      var h = $($(this).parent().parent().parent().find('.more')).height();
        //console.log(h);
        //console.log($(this).parent().parent().parent().parent());
      //$($(this).parent().parent().parent().parent()).css('height', 'auto');
        //console.log($(this).parent().parent().parent().parent().height());

    //  $('.sliderBox').css('border', '5px solid red');
//      $(this).parent().parent().css('height', h+'px');

        return false;
    });

My sliderBox style (The div that needs to change height):

.sliderBox {
    padding: 15px 10px;
    background:#fff;
    -webkit-box-shadow: 0px 0px 5px 1px rgba(100,100,100,0.3);
    -moz-box-shadow: 0px 0px 5px 1px rgba(100,100,100,0.3);
    box-shadow: 0px 0px 5px 1px rgba(100,100,100,0.3);
    overflow:visible;
    margin-top: 12px;
    background:#fff;
    z-index:1;
    position: relative;
    width: 100%
}

The .main div that slides down style:

.sliderBox .more {
position: absolute;
top:2px;
left:0;
z-index:9;
display: none;
background-color: #fff;
width: 100%;
padding: 0 5px;
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
}

Thank you

cgull 25 Light Poster

Hello,

I need help with sliding down an element.

When it is sliding down I want the parent's div height to change so it will contain the sliding element.

My html:

<div class="sliderBox">
<ul>
  <li>
    <div class="main">

     <div class="publicationTitleOuter">
      <div class="publicationTitleInner">Kouga/Uitenhage</div>
     </div>

     <p class="issueDate">8 MAY 2013</p>

     <div style="margin-top:10px"></div>

     <div style="width: 121px; margin: 0 auto">
      <a href="http://www.thinklocal.co.za/magazines/thinklocal/kouga/2013-05-08-225" target="_blank">
      <img src="http://tl/assets/img/thinklocal/kouga/tl-kouga-2013-05-08-cover.jpg" alt="Think Local issue: 8 MAY 2013" width="121" height="163" class="issue" />
      </a>
     </div>

     <div style="margin-bottom: 10px"></div>

     <a class="moreBtn" href="#">CLICK FOR MENU</a>
    </div><!-- end main -->          

    <div class="more">
      <h2 class="title">Kouga/Uitenhage</h2>
      <div class="issuemain" style="vertical-align: middle; line-height: 216px; float: left; width: 180px">
       <a href="http://thinklocal.co.za/magazines/thinklocal/kouga/2013-05-08-225" target="_blank">
       <img src="http://tl/assets/img/thinklocal/kouga/tl-kouga-2013-05-08-cover.jpg" alt="Think Local issue: 2013-05-08" width="160" height="216" />
       </a>
      </div>
      <div class="closer"></div>
    </div><!-- end more -->          

</li>

My jquery:

$('.moreBtn').on('click', function()
{
    $(this).parent().next().slideDown();

    return false;
});

The div with the class "more" has a display: none style.
So when I click the CLICK FOR MENU button, the div with the class "more" should slide down, and the div with the class "sliderBox" should grow accordingly.

How do I do that?

Thank you

cgull 25 Light Poster

Showbiz carousel and cycle problem

Hello,

I am looking for a jquery guru that can help with a plugin that I bought.

The developer of the plugin does not answer me and I need to go live next week.

The plugin is called: Showbiz Carousel.

It is a carousel for content.

I need to tweak it and add jquery cycle to images in it and an external link on each image in the cycle.

I am trying to do this for the last week with no success, keep breaking things.

You can see the testing site at:Click Here

The Think Local carousel works fine because there is no cycle in it, but the Phonebook carousel with the cycle, does not perform well.

I have a few problems:

  1. When I hover over one image, and unhover, the cycle on all images stops working.

  2. The image size keeps changing when the cycle is on.

I tried to attach files here with no success, how can I add the files here?
With js, txt, php I get the error: The filetype you are attempting to upload is not allowed.
With zip: The file could not be written to disk.

So I put the plugin code here, I think the tweaking should go around line 468 [code]if (opt.hovereffect=="on") {[/code].

(function($,undefined){
    $.fn.extend({
        // OUR PLUGIN HERE :)
        services: function(options) {

        var defaults = {
            width:980,
            height:345,
            slideAmount:5,
            slideSpacing:20,
            touchenabled:"on",
            transition:1,
            mouseWheel:"on",
            slideshow:1000,
            hovereffect:"on",
            callback:null
        };

        options = $.extend({}, $.fn.services.defaults, …
cgull 25 Light Poster

Found the solution:

In the jquery I changed to success function:

var options = { 
        target: '#status',
        success: function(data) {
            if(data == 'success')
            {
                $('#status').hide();
                window.location.replace("http://thinklocal.dev/admin/province");
            }
    },
        error: function ajaxError(request, type, errorThrown)
{
    var message = "There was an error with the AJAX request.\n";
    switch (type) {
        case 'timeout':
            message += "The request timed out.";
            break;
        case 'notmodified':
            message += "The request was not modified but was not retrieved from the cache.";
            break;
        case 'parsererror':
            message += "XML/Json format is bad.";
            break;
        default:
            message += "HTTP Error (" + request.status + " " + request.statusText + ").";
    }
    message += "\n";
    alert(message);
} 
}; 

// pass options to ajaxForm 
$('#issueform').ajaxForm(options);

In my controller, if there are no errors in the form I echo success and return true:

echo "success";
return true;
cereal commented: thanks for sharing! +11
cgull 25 Light Poster

Thanks, but your way will not work for a form that needs file uploading.

and the tutorial you sent is a bit old and does not work with the jquery version I am using.

My form id is issueform.