Jump to content



Welcome to AstaHost - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!

Toggle shoutbox Shoutbox Open the Shoutbox in a popup

@  yordan : (25 May 2013 - 09:50 PM) Hi, Agyat What's New?
@  yordan : (25 May 2013 - 07:59 PM) Yay, Shoutbox Is Back! Yahooo!
@  agyat : (24 May 2013 - 05:15 PM) O Dear, Where Are You? Without Your Words This Sb Is ..
@  agyat : (23 May 2013 - 01:23 AM) Wow! Mr. Sb Back Home.
@  OpaQue : (23 May 2013 - 12:44 AM) Ting
@  OpaQue : (24 April 2013 - 02:44 PM) I guess, Time to run Mycent script.
@  OpaQue : (24 April 2013 - 02:43 PM) wow.. not much spam. except habatt posting lot of links.. :P
@  yordan : (23 April 2013 - 01:04 PM) You're welcome, agyat. Nice to have been helpful. Second lesson: try full words, "you" instead of "EW".
@  agyat : (23 April 2013 - 05:03 AM) @YORDAN: tHANK EW FOR YOUR FIRST LESSON.   :D
@  yordan : (22 April 2013 - 09:43 PM) @agyat : "why don't you help me", or "please help me", or "please teach us"
@  yordan : (22 April 2013 - 09:42 PM) welcome back, velma
@  velma : (22 April 2013 - 07:51 AM) **yawns** Good to be back, wonder what is going on here :)
@  agyat : (22 April 2013 - 03:50 AM) Oh! so, why don't help me learn english..
@  yordan : (21 April 2013 - 08:38 PM) The goal mentioned by shiu : "learning english, learning computer"
@  agyat : (21 April 2013 - 06:31 PM) WHAT GOAL?
@  yordan : (20 April 2013 - 10:39 AM) yes, that's our goal. simultaneouly learning English and teaching/learning computer using.
@  shiyu : (20 April 2013 - 07:30 AM) learning english,learning computer
@  yordan : (19 April 2013 - 01:11 PM) Oh, I see, it's just a trick in order to force people looking at your texte. Somehow smart, maybe.
@  agyat : (19 April 2013 - 02:54 AM) And of course I know it is not SEO friendly.
@  agyat : (19 April 2013 - 02:52 AM) There may be two possible answers for that ....


1) Shout was posted using mobile keypad.

2) To force people read content carefully and/or with more concentration.

Replying to Php: Need Ideas On How To Create Api Hooks !


Post Options

    • Can't make it out? Click here to generate a new image

  or Cancel


Topic Summary

miCRoSCoPiC^eaRthLinG

Posted 09 April 2009 - 03:42 PM

Thanks guys! I managed to implement it successfully with all the help I got here :o

Cheers,
m^e

Posted 31 March 2009 - 10:58 PM

essentially what you have here is this.

function addAction($actionName, $functionName){

{

 global $actions;

 $actions[$actionName][] = $functionname;

 return true;

}

function performActions($actionName){

  global $actions;

  foreach($actions[$actionName] as $function)

  {

         // perform $function

   }

}

performActions would go where ever you want the hooks to happen. So if you want something to happen after submitting a form page, but before it goes to the database you would insert a call tot he 2nd function.

-reply by theNetimp

vujsa

Posted 27 March 2007 - 02:34 AM

Well, I can try to explain my understanding of how Joomla and Mambo accomplish this.

Joomla has 3 specific types of addons.
Components, Modules, and Mambots.

A component is it's very own system that relies on the Joomla structure to intereact with the user.
Basically, any PHP script can be converted to a Joomla component by following the rules that Joomla requires.
A component can be nearly completely stand alone and only interact with Joomla when otuput is displayed. Then, the configuration file of the component tells Joomla what to look for. When the corect URL is requested, the script is executed.
/index.php?option=com_frontpage&Itemid=1 tells joomla to execute the frontpage component in the main content area of the template! For the most part, Joomla doesn't care what that script does or what it displays!

A module on the other hand is a much smaller script usually and can interact with components and mambots if needed. These are loaded in the order which they are arranged by the admin based on the menu item and user level at the time of the request. Again, Joomla really doesn't care what the module does or what it displays.

With both Components and Modules, you can nearly completely avoid the use of any Joomla functions or classes but rely on your own method of programming. It is easier in the end to just learn to use the Joomla code to write your scripts since they already have the security and error checking needed for best results. For example, it is much easier to use the Joomla database class to perform your database queries through since it does most of the work for you. Basically, when Joomla comes to a place in the template asking for content like a module, it includes the installed modules for that position in the specifed order. In the end, Joomla just uses require () or include() to insert the content.

Mambots on the otherhand require much more specific Joomla code to work since you have to return certain values to Joomla for the mambot to work in most cases. For example, a Joomla searchbot requires the returned search results to be presented to Joomla in a very specific way and not following the guidelines for this will result in errors. This is so that Joomla knows how to use the returned data. BAsically, a Joomla Searchbot simple performs a search of the database for a particular component. Content Mambots are usually more complicated since they interact with the content prior to being passed to the browser. This is usually the last step in the preocess of displaying a web page. These can do things like replace special tags in the content with the correct value. The same concept as is used for Bulletin Board code!

I don't suggest that you clone the Joomla method but this method offers several benefits.
Instead of using "hooks", which allow for additional code to be added, this method actively seeks the additional code. This makes installations as easy as uploading the required files and updating the database . In scripts like IPB, you have to modify several files for every addon! Then if you have several addons already installed, it can cause confilcts or make it hard to find the "hooks" since the code has changed so much. The other benefit is that usually, Joomla addons are still valide after you upgrade Joomla since they are mostly stand alone! I think this simplicity and seperation of code is what has made Mambo and Joomla so popular. The downside is that it can be a little tricky managing everything since a component may have several modules and mambots that need to be configured independently.

I hope that this gives you a few ideas to work with. ;)

vujsa

miCRoSCoPiC^eaRthLinG

Posted 27 March 2007 - 01:54 AM

As far as I've figured out you wouldn't require any temp file. The code can be directly injected on-the-fly while the main program executes. Code injection here is nothing but a simple require or include statement. There has to be some way you can define some sorta callback mechanism so that the code in inserted at the right point.

vizskywalker

Posted 27 March 2007 - 12:07 AM

I have a couple starts of ideas, but I want to look more into them first. But I'll tell you one of them. The first idea I have is to right a function that copies the contents of a file and mixes it with the main code into a temp file, and then call the temp file with an include statement, but I don't really know if that is feasible. But I'll look into this more for you and post back when I find something. (I'm pretty busy this week, so it may not be until the weekend).

~Viz

miCRoSCoPiC^eaRthLinG

Posted 26 March 2007 - 05:13 AM

Hey guys,
I've been working on a AJAX powered CMS for quite a while now. Am done with most of the important aspects - except one, i.e. plug-ins. I've studied how apps like WordPress utilise API Hooks to add in plug-ins (hooks offer various injection points in the main CMS's code, where a plug-in can inject it's own code).

What I couldn't figure out is how to create one. Anyone here done this before? Can you gimme some examples or guide me to some tutorials on doing this?

Thanks,
m^e

Review the complete topic (launches new window)