collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 426
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

Thanks for having an interest with our portal. If you have any requests for features, have a look at the Feature Requests board.

Author Topic: Mod adding custom block  (Read 4948 times)

0 Members and 1 Guest are viewing this topic.

Offline Arantor

  • Comrade
  • *
  • Posts: 3
  • SMF Version: 2.0.9
  • SP Version: 2.3.6
Mod adding custom block
« on: December 22, 2014, 12:46:28 PM »
I'm working on my gallery, and I've built a custom integration for my gallery to expose a block to SimplePortal - I didn't have it patch PortalBlocks.php and extend sp_gallery() because everything else is done without file edits, and while I can provide code for SP to add to sp_gallery(), I'd rather not have to ask for it to be added when I can provide the support on my end (meaning that if I change APIs or anything, I can worry about maintenance myself without having to expect SP to do any maintenance or expect users to upgrade)

So, I found myself adding it to the database manually (which is fine), but of course there are going to be problems when uninstalling the gallery when there is a block in place.

What happens is that I expose a new function, sp_levgal(), which is added to smf_sp_functions, which is fine right up until the gallery is uninstalled, because sp_levgal() no longer exists and the portal throws a fatal error because of it on any page that it runs. (Including the admin panel if you try to edit the block because the function still doesn't exist)

Part of me thinks it might be an idea to have a function_exists call before running any block function because this does seem a bit fragile, though I'm aware that most mods don't bother to extend SP and expect SP to do the work (or use sp_php blocks)

In the meantime I can have my mod remove any such blocks on uninstall, I was just hoping I could figure out how to preserve the block settings in the interim.

Of course, if the SP team would prefer that I don't try to maintain such a block myself and would prefer to have the code I use integrated into sp_gallery, that's doable too, I just thought I'd keep all the workload on my side.

Would appreciate thoughts.

Offline [SiNaN]

  • Mr. SimplePortal
  • Developer
  • *
  • Posts: 6782
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: Mod adding custom block
« Reply #1 on: December 22, 2014, 01:58:38 PM »
Hello and welcome to SimplePortal!

Unfortunately the parts of SimplePortal that deals with the blocks haven't gone through a real refactoring since the first time I coded them, like 5-6 years ago, at a time when I knew a lot less than the little I know today. So they aren't really pretty. We have been meaning to move towards a plug-in approach, which would make sharing and installing custom blocks a lot easy, but it never happened.

If we were doing more frequent releases, I would have wanted to add support for your mod in sp_gallery() function myself. In case of the other mods, I just get the data and output the data the way I want. For your mod, I could have made it more a like a wrapper, letting you decide what to show and how to show. However, I don't really know when we'll have the next release - it maybe in a few weeks or a few years.

So at this point, the best option seems like you handle everything with your mod. I'll certainly add a check to make sure the block functions exist before we use them. I'll be sure to let you know before we're releasing a new version too, to see if you have any ideas to make SimplePortal easy to work with when you are adding custom blocks.
And slowly, you come to realize... It's all as it should be...

Offline Arantor

  • Comrade
  • *
  • Posts: 3
  • SMF Version: 2.0.9
  • SP Version: 2.3.6
Re: Mod adding custom block
« Reply #2 on: December 22, 2014, 02:14:32 PM »
Yeah, a plugin approach would be good :) Lemme know if there is anything I can do to help.

I have no problem handling everything in LevGal itself, it's more the interfacing and assumptions made that need to be born in ind, though I totally get how come the assumptions were made. And I figured keeping it on my side would minimise the workload on the SP team.

Adding to smf_sp_functions has some interesting consequences if not maintained; in addition to the function existing, it might also be an idea to check the language strings existing at least for the add-block page (since they seem to be made for the block list page, as it reports 'Unknown block type')

I'm also finding a side issue related to the calling of functions, which has consequences for testing for existence; large parts of my mod are in classes with an autoloader, in this case LevGal_Portal_SimplePortal, and for some reason the autoloader wasn't kicking in when I tried to set up LevGal_Portal_SimplePortal::execute as the function name. The language strings were fine, it existed and everything looked like it should work, but it couldn't find it when it tried to run, because for some reason it wasn't loading. I've solved it by creating a wrapper function but it is possibly something to bear in mind. Though it wouldn't surprise me to have made a mistake last night while tired (and now I have it working, I haven't changed it to try it out)

Offline Arantor

  • Comrade
  • *
  • Posts: 3
  • SMF Version: 2.0.9
  • SP Version: 2.3.6
Re: Mod adding custom block
« Reply #3 on: December 27, 2014, 12:58:05 PM »
Fun fact, after examining both TinyPortal and PortaMX, SimplePortal remains the easiest to add support for new blocks/block types :)

Offline Eliana Tamerin

  • Comrade
  • *
  • Posts: 2889
  • Gender: Female
  • SMF Version: 2 RC2
  • SP Version: 2.3.2
Re: Mod adding custom block
« Reply #4 on: December 27, 2014, 01:02:48 PM »
That's good to hear, I know [SiNaN] will be proud.
Ms. Eliana TamerinIt should be painfully obvious by now that I don't respond to support PMs. Don't send me PMs for support. They will be ignored and deleted, post on the Support Boards to get support.