Jump to content

Return table object in .../IpAddresses/Content.php ?


Recommended Posts

I may have other places where I would wish for a table and form object to be returned, rather than it just being sent straight to a template or returned as a string. But here is a concrete example:

Some background: Since upgrading a community from 3.4 to 4.0, moderators and administrators have several times told me they need the ability to view the full post directly from the IP-tools page (/modcp/ip-tools/&ip=%3A%3A1&area=core_Content_forums_Topic_Post). Having a link to the post on the topic title is not enough and makes it incredibly cumbersome for them to view the post content that has been posted from the IP they wish to review. It's currently one of their biggest pet peeves a month after the upgrade when it comes to how they moderate. 

So I'm thinking: instead of providing you the feedback, I'll just create a plugin for it. So I dive into the code and take a look in applications/core/extensions/core/IpAddresses/Content.php

Trouble is, it's "impossible". 

At a minimum I need two things:

  • Being able to add "content" to $table->include
  • Setting my own rows-template to be used, to make it look like I envision. I want the post content to be listed below the three columns that are already there, not "appended" as a fourth column.

But from the method findByIp you return a string, which is the already generated table. 

If you had returned the table object I would probably had a decent chance to extend the method findByIp, retrieve your table-object, make my changes to $table->rowsTemplate and $table->include and then return the altered table object. 

My only solution now seems like it would be to extend the method and copy the entire code and then make the changes. 

So as it is, I'll likely just make the necessary edits on the server itself. Because that'll be far more convenient for me in this case...

Could you make a method here that returns the table-object before the contents of it are actually generated?

Link to comment
Share on other sites

Yeah, a proper review would be great. I know I've had similar frustrations earlier, but I have pretty much just ended up giving up and moved on every time. I'll get back to you if I remember other cases where this stopped me. 

The biggest show-stoppers for me are circumstances where I can't change a Form-object because it's not returned anywhere or the same for a Table-object. 

Theoretically I guess I could extend \Table::__toString and then check \IPS\Dispatcher etc. to determine which table it is, and then do my changes... but that seems very nasty to me personally and something I do not want to do in a million years. I have a feeling it would just end up with lots of extensions on the table-classes from everyone...

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...