We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Using the Table Library in Accessory views

Development and Programming

Focus Lab Dev Team's avatar
Focus Lab Dev Team
1,129 posts
15 years ago
Focus Lab Dev Team's avatar Focus Lab Dev Team

EE: 2.1.3 build 20101220

In working on an Accessory view this weekend I noticed that I cannot use the HTML Table Library without injecting data into tables built on the CP pages. I tried using the ->clear() method in my view but it had no effect. Regardless of what I did, I was manipulating the tables in the CP.

Is there an alternate advised approach to using this library in Accessories or would this be considered a bug?

Thanks 😊

       
alexseinet's avatar
alexseinet
1 posts
15 years ago
alexseinet's avatar alexseinet

So are you saying that you cannot insert a table without it being added to one already in existence in that view?

       
Focus Lab Dev Team's avatar
Focus Lab Dev Team
1,129 posts
15 years ago
Focus Lab Dev Team's avatar Focus Lab Dev Team

Not quite. I think it’s more accurate to say you cannot use the HTML Table Library on a CP page that also uses it. You can always build tables on your own. It also shouldn’t really matter on your own module or extension views because they’re most often called apart from CP pages with tables.

I’ve only encountered this while building views for Accessories. I imagine there may be other instances of this possibility but I have not looked for them.

       
johnwbaxter's avatar
johnwbaxter
651 posts
15 years ago
johnwbaxter's avatar johnwbaxter

Whoops, i was logged in on the mrs’ account for that reply!

What if you assign the table class to another name using the loader?

$this->EE->load->library('table', '', 'my_table');
       
Focus Lab Dev Team's avatar
Focus Lab Dev Team
1,129 posts
15 years ago
Focus Lab Dev Team's avatar Focus Lab Dev Team
What if you assign the table class to another name using the loader?
$this->EE->load->library('table', '', 'my_table');

It’s been so long since I’ve used CI alone that I forgot you could do that. I’ll give it a go and see if it works. Cheers 😊

       
johnwbaxter's avatar
johnwbaxter
651 posts
15 years ago
johnwbaxter's avatar johnwbaxter

No problem, good luck with it!

       
Focus Lab Dev Team's avatar
Focus Lab Dev Team
1,129 posts
15 years ago
Focus Lab Dev Team's avatar Focus Lab Dev Team

Looks like that just jacks up all tables in the CP (that are built with this library at least). Nice thought though!

       
johnwbaxter's avatar
johnwbaxter
651 posts
15 years ago
johnwbaxter's avatar johnwbaxter

That shouldn’t happen…probably.

You could get creative and do something like this:

$TEST =& get_instance();

$TEST->load->library(‘table’, ”, ‘test_table’);

Worth a shot perhaps…

       
Wes Baker's avatar
Wes Baker
343 posts
15 years ago
Wes Baker's avatar Wes Baker

Erik,

Can you show me the code from the accessory? I have an idea of where the problem’s coming from, but I want to make sure.

Wes

       
Focus Lab Dev Team's avatar
Focus Lab Dev Team
1,129 posts
15 years ago
Focus Lab Dev Team's avatar Focus Lab Dev Team

Sure thing Wes. Here’s a filtered down version:

The accessory contains:

function set_sections()
{
    $this->EE =& get_instance();
    $this->EE->load->library('table');    
    $this->sections['Recent Deployment Notes'] = $this->EE->load->view('test', '', TRUE);
}

The views/test.php file contents:

<?php

$this->table->clear();

$this->table->set_heading(
    'heading 1',
    'heading 2',
    'heading 3',
    'heading 4'
);

$this->table->add_row(
    'col 1',
    'col 2',
    'col 3',
    'col 4'
    );

$this->table->add_row(
    'col 1',
    'col 2',
    'col 3',
    'col 4'
    );

$this->table->add_row(
    'col 1',
    'col 2',
    'col 3',
    'col 4'
    );

$this->table->generate();

?>

The end result can be seen in the attached image.

       
Greg Aker's avatar
Greg Aker
6,022 posts
15 years ago
Greg Aker's avatar Greg Aker

Erik,

Can you please file this a bug? If $this->table->generate() is being used in views, and not calling $this->table->clear(), this behavior will happen. So we need to fix this up. 😊

-greg

       
Greg Aker's avatar
Greg Aker
6,022 posts
15 years ago
Greg Aker's avatar Greg Aker

Actually, changed my mind. This is a CodeIgniter bug, which is fixed up here (https://bitbucket.org/ellislab/codeigniter/changeset/ba3b278d52e1), and will be on the next EE release.

Thanks!

-greg

       
Focus Lab Dev Team's avatar
Focus Lab Dev Team
1,129 posts
15 years ago
Focus Lab Dev Team's avatar Focus Lab Dev Team

Ah okay. Thanks for clearing that up. 😊

I know CI is slow to add features. How is it for patching bugs? In other words, since this is a CI bug how long do you think it will be until it’s patched in an EE release?

Thanks again!

       
Focus Lab Dev Team's avatar
Focus Lab Dev Team
1,129 posts
15 years ago
Focus Lab Dev Team's avatar Focus Lab Dev Team
If $this->table->generate() is being used in views, and not calling $this->table->clear(), this behavior will happen.

Just saw this statement. I wanted to verify what you meant. I did, in fact, call $this->table->clear() in my view file. That doesn’t affect the CI bug you found though I presume.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.