官术网_书友最值得收藏!

Where do I start?

To get started with plugin development, first we need to decide what problem we are trying to solve or what functionality we are trying to implement.

Let's assume that you have a website with various phone numbers listed on the site, and that this site is popular with people who access the site through a smartphone. Currently, to call one of the numbers, the user has to remember the number to dial it, or perhaps they jot it down on a piece of paper or attempt to select and copy the number through their browser. This is not very user-friendly, a much better way to do this would be to change the phone number to a click-to-call link, so the user can just click the phone number and their phone will call it. Now, you could go through the website and manually change all the phone numbers to these links, but that would be inconvenient. Assuming our phone number is in the format 1234-5678, we could change it to this HTML code to create a click-to-call link.

<a href="tel: 1234-5678">1234-5678</a>

Wouldn't it be better if we wrote a plugin that identified phone numbers in all our Joomla! articles and automatically changed them to these click-to-call links? Well that's exactly what we are going to do.

The following screenshot is an example of what the plugin will do when we have finished creating it. When a mobile user clicks on the phone number, it will allow them to easily call the number.

So now that we know what we are trying to achieve, the first thing to do would be to check the Joomla! Extension Directory (JED) to make sure that a solution to this problem does not already exist. Why reinvent the wheel if you can find something that already does the job or does something similar you could adapt? So let's assume that we've had a look at the JED (http://extensions.joomla.org) and we can't find a suitable plugin and we want to create our own.

The next step is to come up with a unique name for this extension; in this case we will call it as plg_content_clicktocall. The first part of the name ( plg ) indicates that this is a plugin extension. Then we identify what type of plugin this is; in this case, it's a content plugin. Then we add our unique name, preferably something short that describes this plugin; in our case, this is clicktocall. Once you have a name, it's a good idea to search the JED and Google to make sure that it is truly unique as you will have problems listing the extension on the JED later if it is not unique. Many developers add their initials or business name to the extension to avoid name conflicts.

主站蜘蛛池模板: 东乌珠穆沁旗| 平泉县| 荣昌县| 乌鲁木齐市| 宜春市| 三穗县| 通山县| 维西| 泗水县| 孟州市| 获嘉县| 博爱县| 潼南县| 于田县| 秦皇岛市| 天津市| 张家港市| 庄浪县| 紫金县| 炎陵县| 钟祥市| 五大连池市| 武邑县| 克拉玛依市| 鄯善县| 晴隆县| 方山县| 云安县| 吉水县| 拜城县| 左云县| 文昌市| 山西省| 从化市| 台北县| 温州市| 莎车县| 陈巴尔虎旗| 黔西县| 革吉县| 敦化市|