Jump to content

Plugin code hooks


desti

Recommended Posts

20 hours ago, desti said:

sudo, that's right. 

Without violating the rules, I can only replace \IPS\Notification\Table(...) with \IPS\Db::i()->select(...) and my own template. 

Why create a framework and prevent it from being used?

 

I think you may be a bit confused though. There's nothing preventing you from using existing templates or calling existing methods and so on, you just can't copy and paste massive amounts of existing core code into your applications and so on.

I'd say it's mostly just use common sense.

Referencing a few lines in IPS core versus copying and pasting a 100-line method, there's an obvious difference between the two.

Link to comment
Share on other sites

2 hours ago, Makoto said:

I'd say it's mostly just use common sense.

Common sense can't be defined by rules. Few lines or big code block - does not matter, rules prohibit this.

/cookies/ page - 6 lines, i need sidebar. Override \IPS\Output? 

Remember how it used to be... Query database, process data, send to template, output. There was no hardcoded definition (well there was almost no) - now they are.  

		\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('cookies_about');
		\IPS\Output::i()->sidebar['enabled'] = FALSE;
		\IPS\Output::i()->bodyClasses[] = 'ipsLayout_minimal';

Why not 

		\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'system' )->cookies($sidebar, $class);

Template hook would solve all my problems.

Link to comment
Share on other sites

10 minutes ago, desti said:

Common sense can't be defined by rules. Few lines or big code block - does not matter, rules prohibit this.

This has been elaborated on, directly by @Lindy I believe, when this policy was announced. I believe his comment was along the same lines of "just use common sense."

Sometimes there is just one way to do things. You're not going to get in trouble for using a few lines of code that exists in the core software. You are going to get in trouble if you just copy and paste an entire 100-line method and maybe try to change just a few lines. This is bad programming practice anyways, for reasons stated above.

Widgets all use pretty much the same boilerplate base template. That's fine. That's how it's supposed to work. Not going to get in trouble for this.

Extensions all use the same auto-generated base code. That's.. obviously fine, this is intended. Not going to get in trouble for this.

It really is just a matter of using common sense. You're making a bigger deal out of this than is necessary.

Link to comment
Share on other sites

8 minutes ago, Makoto said:

Widgets all use pretty much the same boilerplate base template. That's fine.

Nope. I need transparent widget, but .ipsWidget (ipsBox) have background-color. Again someone decided for me what the widget should look like. 

Link to comment
Share on other sites

Just now, desti said:

Nope. I need transparent widget, but .ipsWidget (ipsBox) have background-color. Again someone decided for me what the widget should look like. 

Well.. then make a transparent widget. You can add a class to your custom widget to override the styling of ipsWidget however you want.

Link to comment
Share on other sites

Just now, desti said:

You don 't understand me again, I want to set out my class, not override someone else's. 

???

Why does it matter?

You're extending in existing framework, this is how that works. You're supposed to adhere to the basic standards of that framework to ensure everything integrates smoothly with the software.

Link to comment
Share on other sites

3 minutes ago, Makoto said:

PAC is a new one for me, but yeah that seems to fit IPS pretty well.

PAC and HMVC are very similar, IPS could be better described as one of those more than a pure MVC pattern. but the term MVC has been "liberalized" as you say, not just by IPS but by the whole web dev community as a whole, they all have their own approach to it. laravel/symfony are about the closest to the original pattern, but codeignitor/fuelphp/etc all also claim to be MVC, but they are HMVC.  I've seen dev's also use MVC interchangeably with OOP too, so the waters are muddy on what a MVC really is anymore :)

Link to comment
Share on other sites

1 minute ago, desti said:

Only one question, how to change widget background? 🙂 Simple and quick with beautiful code, not nasty set of code hooks. 

For all widgets, or just your own?

As I mentioned above, you can use CSS to style your own widgets however you want.

Link to comment
Share on other sites

1 minute ago, desti said:

Yep. 

Parent (and global) div has background-color defined. I need transparent.

Add your own class to the widget, create a CSS stylesheet in your plugin to define your own rules for the background color.

I don't even think you should need to use !important on the rule since plugin stylesheets are loaded last and will just override the default CSS rules.

Link to comment
Share on other sites

Just now, desti said:

Don't you think it 's too much to change a one CSS property?

No.

This is just the basic structure of a simple plugin.

You'll only need that one CSS file to make any styling changes or additions you need for your entire plugin going forward as well.

Link to comment
Share on other sites

We have a widget block on our forum index called "Popular Contributors". Let's imagine we want to make it a transparent bg instead of colored. You can do that with just css, no plugin even required.

li[data-blockid^="app_core_topContributors"] {
	background-color: transparent !important;
}

 

You can do that just by pasting in the line to your custom.css file. Sometimes you need to get creative and think outside the box a little bit. 🙂 

Link to comment
Share on other sites

bfarber, оk, it's great, but why background has color by default? Set it to transparent, let me set the color in my template!

Another question, why do you think the cookie page is always without sidebar and in the _minimal template? This must be my solution (or a skin developer 's solution). 

Link to comment
Share on other sites

Archived

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

  • Recently Browsing   0 members

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