News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Integration hooks for 2.1

Started by Night09, December 22, 2014, 07:25:06 PM

Previous topic - Next topic

margarett

Back-compat is mostly broken already! ...
Whatever theme edits existed, puff, gone
Most changes to Load.php will probably be different. Same for Subs.php

Sooooooo.... ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Arantor

Indeed... but I'm a big fan of encouraging this stuff to be reviewed properly rather than doing the bare minimum ;)

live627

Quote from: margarett on December 22, 2014, 09:39:20 PM
Quote from: live627 on December 22, 2014, 07:56:07 PM
Quote from: margarett on December 22, 2014, 07:42:32 PM
* margarett thinks we should remove the "Mod authors" reference as we will be forcing the usage of hooks more and more...
and break tons of mods? Bad idea.
I actually think so. Most mods will not work in 2.1 except if using hooks already... So if we could help ourselves, it would be nice ;)
Those lines help curb conflicts, however weak the argument may be.

Here's the thing: if I saw a mass adaption of hooks,  I'd  be in favor.

margarett

Well, we can't do much about already-approved mods but, as long as I have anything to say about new approvals, we will be requiring the use of hooks ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Arantor

If it weren't such a time sink I'd be encouraging old mods to be reviewed again.

Kindred

yeah...   I would as well...  but we don't currently have the team to do it. :(
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

Either that or write new versions of old mods, like galleries ;D

Hj Ahmad Rasyid Hj Ismail

For me, just classify the mods into three category: Fully hook, partially hook and manual mod. Let everybody makes whatever type of mods they want. Let everybody learns. When somebody ask for hook tutorials, nobody really cares. So, why must be so strict or serious about this? What would that benefits anyway? To whom? Enough said with regards of the above. I don't see that being enforced and I personally vote for it not to be enforced. (Yeah, I know. Nobody will care about any votes either.)

Kindred

people can do whatever they want with mods that they write.

However, going forward, if the mod is to be accepted on our customization site, here, then the authors will be requested to use hooks whenever possible.
If a code edit is needed, because there is no hook to use, then fine... but hooks are to be used whenever possible.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Antes

Quote from: Kindred on December 23, 2014, 08:13:38 AM
people can do whatever they want with mods that they write.

However, going forward, if the mod is to be accepted on our customization site, here, then the authors will be requested to use hooks whenever possible.
If a code edit is needed, because there is no hook to use, then fine... but hooks are to be used whenever possible.

True, but you are missing a point that Hook related tutorials are really lacking. So you can't actually expect people to learn things on wild-guesses.

@ahrasis But we still in early stages of release "first beta", I'm sure developers will come with something to help mod authors to upgrade their mods to hook-only (if possible) version and write some guides to teach newcomers how to code with Hook system.

Kindred

no. I am not missing the point at all...

Someone should WRITE the tutorials -- and what better way to learn what is needed and what can be done that doing it and documenting? :P
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

vbgamer45

Hooks are nice cause removing some file edits.
I have some concerns though on how it scales when every single mod starts using hooks since from my understanding each will add a file in "integrate_pre_include" so that includes more files in memory for each page load.
Some hooks need to be improved some as menu level hooks right now it seems I have to order the array myself in order to insert the exact spot of where I want a menu


Some current things I don't like about the mod site approvals
The mod site is way too strict, never been a big fan.
It just turns off developers for a couple reasons: The mod site is geared for simple mods, very few large scale mods go though the mod site now. Takes months to review a modification unless it is simple that's why you mostly see BBC code mods now. For me personally that's why I rather submit something very basic has a better chance of getting approved then making some that is huge when I know it will take much longer to get approved.

It's better to have a mod then none at all in most cases. Requirements should be does the mod install/uninstall cleanly, works as stated, use smf functions, security checks and that is about it. That's how it was in the past and we had a ton of developers.

The customize team should be either more focused on updating the customize site,maintaining official smf mods/themes and writing tutorials/documents on how to code. Instead of approvals that is boring work and no one likes doing it. I kind of regret giving some mods back to customize team because now they just are not maintained at all.

Another thing you can't easily see what mods you have pending approval not visible in an easy place. only area is  latest submissions
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Hj Ahmad Rasyid Hj Ismail

Don't get me wrong. I am not against the hook thingy. I am all towards it. Mods under me are mostly set to be upgraded to hook version slowly but surely. Some are even ready for 2.1. I did write and when I am freer, will continue to write tutorial about the mods.

I also read your post about using hook vbgamer. Even a simple css hook for SMF2.1 is being debated when you can either use the context html or css to do it with integrate menu buttons to change menu image. For me it is simple, whatever hook is in there, it can be used.

And I do agree with your above comments and suggestions. The mod site should be simpler.

P/S: I don't simply sit and wait for the biggest delicious cake when plenty of other cookies are just as good and very much available. ;D

Arantor

I continue to be amazed at the lack of understanding of hooks.

vbgamer45

I continue to be amazed that there are no good guides you pretty much have to go by what other people have done and that hooks are not the answer to everything.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Kindred

yes. the mod site should be ALOT of things...  and plans for the mod site redesign have been around almost since the release of 2.0, but we have a limited team who have limited time.. :P
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

Quote from: vbgamer45 on December 23, 2014, 09:58:53 AM
I continue to be amazed that there are no good guides you pretty much have to go by what other people have done and that hooks are not the answer to everything.

Because http://wiki.simplemachines.org/smf/Integration_hooks is not a thing or anything.

Hooks aren't the answer to everything but more use can be made than people are making. I mean, my gallery is hooks only - and that includes its own gallery-specific pretty URLs. Oh, and making hooks in places where there aren't hooks, *without* file edits.

The problem is, few people care enough to really bother making use of the things available because file edits are easier (and less reliable)

Suki

Quote
I have some concerns though on how it scales when every single mod starts using hooks since from my understanding each will add a file in "integrate_pre_include" so that includes more files in memory for each page load.

This is not the case on 2.1. Yes, each mod will add 1 or more files but only when necessary/requested and is up to the mod author to decide how/what to include.

Quote
Some hooks need to be improved some as menu level hooks right now it seems I have to order the array myself in order to insert the exact spot of where I want a menu

The whole point of having a hook somewhere is that you can manipulate the passed var(s), you can manipulate every single var in global scope available at the moment that particular hook is been called and not only that, you can do pretty much anything you want, you have a function/method called exactly at one point in the process, the rest is up to you.


Quote
I continue to be amazed that there are no good guides you pretty much have to go by what other people have done and that hooks are not the answer to everything.

There is no guides mostly because there cannot be any guides on "how to use them", it really is up to you and your understanding of PHP.

True, hooks aren't a panacea but they really, really help.

- Support issues, I get none, the only support requests I answer are feature request or install/uninstall issues. 
- Easy to maintain/upgrade. I got my whole code in 1 single file or files, combing that with the most basic level of MVC and you have nothing to worry about.

Yes, not everything can be done with hooks and file edits are still necessary, fine, for that I would strongly suggest to keep your code logic completely separated from SMF, it is somehow difficult to explain.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Hj Ahmad Rasyid Hj Ismail

Quote from: Kindred on December 23, 2014, 10:10:56 AMwe have a limited team who have limited time..
People have reasons when they shy away...

vbgamer45

I am using hooks for most things in 2.1 based on what I can understand. I do agree less support requests most of my mods I avoid doing edits as much as possible for this reason.
I think some more hook helper functions need to be added mainly when dealing with arrays been using stuff like this

function articles_menu_buttons(&$menu_buttons)
{
global $txt, $user_info, $context, $modSettings, $scripturl;

#You can use these settings to move the button around or even disable the button and use a sub button
#Main menu button options

#Where the button will be shown on the menu
$button_insert = 'mlist';

#before or after the above
$button_pos = 'before';
#default is before the memberlist
   
    articles_array_insert($menu_buttons, $button_insert,
     array(
                    'articles' => array(
'title' => $txt['smfarticles_menu'],
'href' => $scripturl . '?action=articles',
'show' => allowedTo('view_articles'),
'icon' => '',
   
   
    )
    )
    ,$button_pos);
       



}

function articles_array_insert(&$input, $key, $insert, $where = 'before', $strict = false)
{
$position = array_search($key, array_keys($input), $strict);

// Key not found -> insert as last
if ($position === false)
{
$input = array_merge($input, $insert);
return;
}

if ($where === 'after')
$position += 1;

// Insert as first
if ($position === 0)
$input = array_merge($insert, $input);
else
$input = array_merge(
array_slice($input, 0, $position),
$insert,
array_slice($input, $position)
);
}

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Advertisement: