Common categories in joomla2.5 are summarized. Common classes in joomla2.5 are summarized. joomla2.5 class summary the previous article only studies the JImage class. Today, we continue to use other commonly used joomla built-in classes. I write them from the perspective of common classes, if the joomla2.5 function in PHP is frequently used for class summarization, joomla2.5 Class Summary
The previous article only studied the JImage class. Today, we continue to use other commonly used joomla built-in classes. I write them from the perspective of common use. If PHP functions are more convenient to use than Joomla built-in classes, if you really want to use it, check it yourself. I personally think that no matter how good the methods are, it can be well solved if PHP comes with functions, so using PHP built-in functions is the best. learning PHP is to learn built-in functions first. well, I will explain in detail the frequently used classes and methods.
1. document class, used to take the header of the current page element as the main operation.
$ Document = JFactory: getDocument (); $ document-> addScript ('1. js'); // add the js file $ document-> addScriptDeclaration ('alert (1) '); // add the js code $ document-> addStyleDeclaration (); // css $ document-> addStyleSheet('1.css '); $ document-> setMetaData ('Description', 'key '); // Set the description or keyword $ document-> setCharset ('utf-8'); $ document-> setTitle ('title ');
2. for file operations, you need to import jimport ('joomla. filesystem. file ');
$ J = new JFile (); getExt ($ file) // get the extension not included. getName ($ file) // get the file name exists ($ file) // check whether the file exists delete ($ file) // delete the file copy ($ old, $ new) // Copy upload ($ src) // upload write ($ file) // write the file read ($ file) // read the file move ($ old, $ new) // move the file
These methods are useful in file read/write, image file upload, and so on.
3. folder operations, jimport ('joomla. filesystem. folder'); generally, we import all the file folders during import, which are often used
JFolder: create ($ path, 777) // create a folder. multiple layers of JFolder: delete ($ path) // delete a folder, including JFolder :: exists ($ path) // check whether the folder has JFolder: copy ($ pathold, $ pathnew) // copy the folder JFolder: files ($ path) // list the arrays of files in the folder: folders ($ path) // list the arrays of the folders in the folder
Here we will talk about: static methods. many classes support static methods;
4. icon generation class, which is used to generate small icons in the background.
JToolBarHelper: title (JText: _ ('add personal information'), 'weblinks.png '); // title JToolBarHelper: addNew ('info. add'); // add JToolBarHelper: apply ('info. apply '); // save JToolBarHelper: save ('info. save '); // save and close JToolBarHelper: editList ('info. edit '); // edit JToolBarHelper: cancel ('info. cancel '); // cancel JToolBarHelper: deleteList ('info. delete '); // delete JToolBarHelper: trash ('info. trash '); // Recycle bin JToolBarHelper: pider (); // Split line JToolBarHelper: publish ('weblinks. publish ', 'jtoolbar _ PUBLISH', true); // publish JToolBarHelper: unpublish ('weblinks. unpublish ', 'jtoolbar _ UNPUBLISH', true); // cancel JToolBarHelper: back (); // return JToolBarHelper: help ('jhelp _ COMPONENTS_WEBLINKS_LINKS '); // help
5. other common methods
JString: transcode ('China', 'utf-8', 'gb2312'); // The conversion encoding JUtility: getToken (); // The user session ID is equivalent to JHtml:: _ ('form. token'); JUtility: isWinos (); // whether the win system outputs 1 JUtility: sendmail ('logove # qq.com ', 'yoby', 'logoove # foxmail.com ', 'topic ', 'This is content'); // The JUtility: gethash ($ var) to be configured for sending emails; // 32-bit random character JUtility :: return_bytes ('1k'); // The number of converted nodes supports g m kJRequest: getURI (); // get the current url JRequest: getMethod (); // The submission method is POST or GET JRequest: getbool ('I'); // Convert it to a Boolean JRequest: getint ('I'); // Obtain the entire JRequest :: getfloat ('I'); // Convert it to a floating point JRequest: getString ('I'); // Convert it to a string JRequest: getvar ('Var ', null, 'default', 'array'); // common. The second is the default value, and the third is the method, GET // post files cookie env server last data type has array int string float JRequest: setVar ('var', $ arr); // set, can be an array or character JURI: base (); // contains administrator absolute path parameter 1 is relative path JURI: root (); // root directory, parameter 1 is relative path
6. arrays are commonly used. this is the most commonly used
JArrayHelper: arrayUnique ($ arr2); // remove the duplicate element $ obj = new stdClass (); $ obj-> qq = '000000'; JArrayHelper :: fromObject ($ obj); // The object conversion array JArrayHelper: getValue ($ arr, 1); // Obtain the second value of the array, which can also be the subscript JArrayHelper :: toObject ($ arr); // conversion object JArrayHelper: toString ($ arr, '=', ''); // Convert it to a string separated by spaces. key = value JArrayHelper on the left:: toInteger ($ cid); // Convert the variable to an integer.
There are many other methods, such as databases, xml, and form generation. these methods are very important, but there are too many contents. I will discuss these methods later, basically, it is very common. to learn more about the api content, or read the core code, I will summarize it here to reduce your reading time, the comment below is very detailed. if you don't understand it, you can leave a message below. joomla is a very good CMS, but it is not popular in China. dedecms and discuz have a large number of users, I will study it later. if you like cms, don't miss it.
(Yoby original)
In the previous article, I only studied the JImage class. today, I continue to use other commonly used joomla built-in classes. I personally write them from a common perspective. If PHP functions...