Subject:*
<
Name/Email:*
<
Message Icon:*
<
Select*
<
Message:*
<



Click the Preview to see the content in action.
Options:*
<
Confirmation Code*
<
7 + 7 = ?  
Input the result from the expression
Maximum attempts you can try: 10
*
<
   

Re: Preloads, what are they and how can I use them?
by irmtfan on 2013/3/19 4:02:05

Quote:

A preload can also be used instead of creating a cron job.

Yes. but i prefer to use it just as it is. load needed functions before load the module.
for example protector need it because it want to protect other modules and core.
userlog also need it because it want to log other modules and core.

I think using a hidden block is better for a cron job because cron job is a part of module not core or other modules. Also it will be more customizable by end user. he can activate the block in some parts of his website.

preloads seems nice and clear but the underlaying part is a core hack.

@redheadedrod :
without preloads you have to hack XOOPS255/footer.php or XOOPS255/mainfile.php to add your needed codes to core. preloads are invented just to solve this issue.

It is just a trigger to include/load your added codes at your needed place.

Re: Preloads, what are they and how can I use them?
by redheadedrod on 2013/3/17 8:36:45

Ok let's start a little sooner in the food chain here...

Doesn't make sense to me how to use it if I don't know what actually happens.

Lets start from the aspect that I have no clue what a preload is. Not even a hint...

From the links and comments here things are not really clear but with the comment zyspec gave I am beginning to wonder if I might not be getting a better hint about what they might be.

If I had to guess today what a preload is I would guess it is a function that is run at some point in a page load but prior to accessing any modules or block contents thus it happens every time a page loads. (From zyspec's comment this would make sense.)

From the structure mentioned by irmtfan and his comments plus the links I am guessing that the structure of preloads are similar to delegates in C#. In other words the preloads are sorted into a queue that would be run one at a time in the order placed into the queue.

So if I am right things would make better sense BUT at what point in the system do these preloads get run? Will I still have access to all of the normal xoops variables? Obviously if this is the case you really don't want to do a large query if you use it in a module and the comments about including it in a module etc make more sense as well.

Also, is there a specific order for these preloads? Core preloads first then modules I assume?

Thanks... Hopefully I am on the right track to clarity with this.

Rodney
Re: Preloads, what are they and how can I use them?
by zyspec on 2013/3/17 3:05:25

irmtfan,

A preload can also be used instead of creating a cron job. For example if a module needs to check the status of some event or activity a preload can accomplish this so that it can all be contained within XOOPS instead of forcing inexperienced site administrators to learn about cron jobs.

You are right that other methods could be used - hacking a theme, hacking the core, or a hidden block but using a preload is a cleaner solution in my opinion that requires no action by the site administrator. You are also correct stating that the preload must be tested very carefully. Improper use of a preload could potentially bring down the whole site, not just the module using the preload.
Re: Preloads, what are they and how can I use them?
by irmtfan on 2013/3/17 2:19:18

I think my example of preloads usage is clear enough.

I forgot to mention defining the class.

sop the whole instruction would be this:
1- create YOUR_MODULE/preloads/core.php file

2- add the class and the related function name of preload by removing all dots, add a "event" and uppercase of the first letters for all.

eg: core.footer.start => eventCoreFooterStart

le="color: #000000"><?php defined('XOOPS_ROOT_PATH') or die('Restricted access'); class UserlogCorePreload extends XoopsPreloadItem { // to log main part of modules function eventCoreFooterStart($args) { include dirname(dirname(__FILE__)) . '/include/log.php'; }


The class name for any module would be {$Modulename}CorePreload
Re: Preloads, what are they and how can I use them?
by redheadedrod on 2013/3/15 19:21:03

Ok, I did look through the threads and there was no clear examples of a preload and how they are used. Maybe I am just being dense with this subject and I am sure once the light goes on it will make a lot of sense but that bulb is pretty dim at the moment.

Don't know that a full understanding will be necessary to be able to finish up the PDO stuff but would be nice to know what I am tweaking.

Who's Online

205 user(s) are online (161 user(s) are browsing Support Forums)


Members: 0


Guests: 205


more...

Donat-O-Meter

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

Latest GitHub Commits