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

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.

主站蜘蛛池模板: 柳林县| 师宗县| 凌源市| 钟祥市| 偃师市| 兴文县| 天长市| 信阳市| 望谟县| 江西省| 金沙县| 交城县| 哈巴河县| 方城县| 新宾| 余干县| 拜泉县| 绥化市| 阳春市| 于田县| 霍州市| 云和县| 林甸县| 贵港市| 安徽省| 本溪市| 融水| 拜泉县| 潼南县| 虹口区| 新和县| 三台县| 云安县| 宿州市| 东安县| 汶川县| 江孜县| 合山市| 灵川县| 赫章县| 边坝县|