1
culex
Alternative to preloads ?
  • 2010/6/22 16:37

  • culex

  • Module Developer

  • Posts: 711

  • Since: 2004/9/23


Almost I have become used to working modules with preloads, at least I am now relying on the method. Now it seem this is perhaps / perhaps not supported in next versions of Xoops.

Basicly I Understand this adds a lot of styles and scripts to the header that could easily be added using theme insertion or added to the independent modules / blocks.

However in the xim modules as an example a lot of jquery is needed to be added to the header as well as styling + jquery code for the footer (showing online users and friendlist).

so both css, js and the file footer_bar.php uses preloads.

So what is a good alternative for xim to add script + style to header. This is a good idea anyway as we'd like to give xim to users with for instance Xoops 2.3.3 etc.

Xim is here
Programming is like sex:
One mistake and you have to support it for the rest of your life.

2
ghia
Re: Alternative to preloads ?
  • 2010/6/22 16:48

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Are these not things that should and could be easy done in some header.php of the module?
I would think that the preloads are reserved for uses where otherwise hacks to the core are needed as eg with the xLanguage module (or am I here totally on the wrong track?).

3
Peekay
Re: Alternative to preloads ?
  • 2010/6/22 18:04

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


What are preloads?
A thread is for life. Not just for Christmas.

4
trabis
Re: Alternative to preloads ?
  • 2010/6/22 18:11

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


You should use $xoTheme->addScript() and $xoTheme->addStyleSheet()

Preloads are rendered for every page and since scripts are only needed on blocks or module pages they should not be assign with preloads. If you have many blocks or many module pages that need the same scripts loaded, you would better create a file that makes the assignments and then include it on your scripts.
As Ghia said, using a header.php(or footer.php) would be the best way.

Btw, is not certain that preloads are going to be removed. If you need to hack core to build extra functionality, and if there is a preload that can help you, you should use it. But as I said before, preloads should be considered as hacks, use only if there is no other way.

5
culex
Re: Alternative to preloads ?
  • 2010/6/22 18:11

  • culex

  • Module Developer

  • Posts: 711

  • Since: 2004/9/23


Yes but in xim also you need these run on every page. I have tried with modifying the header or including this in the theme or in the xoops header, but still doesnt work as nice as preloads
Programming is like sex:
One mistake and you have to support it for the rest of your life.

6
trabis
Re: Alternative to preloads ?
  • 2010/6/22 18:19

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Why do they need to run on every page?

7
culex
Re: Alternative to preloads ?
  • 2010/6/22 19:53

  • culex

  • Module Developer

  • Posts: 711

  • Since: 2004/9/23


Because the messenger should be running on every page
Programming is like sex:
One mistake and you have to support it for the rest of your life.

8
trabis
Re: Alternative to preloads ?
  • 2010/6/22 20:22

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Ok.

An option is to add functionality into a block that return false.
A block with "return false;" will be rendered but not displayed by xoops. You only have to ask users to set the block as visible on every page.

9
culex
Re: Alternative to preloads ?
  • 2010/6/22 20:55

  • culex

  • Module Developer

  • Posts: 711

  • Since: 2004/9/23


Doh of course... We actually did this in the beginning but found preloads more easy to handle... How quickly I forget lol..

We had some problems havin ajax running like this but with some more tweaking I'm sure it'll work!

thanks Trabis
Programming is like sex:
One mistake and you have to support it for the rest of your life.

Login

Who's Online

167 user(s) are online (98 user(s) are browsing Support Forums)


Members: 0


Guests: 167


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits