Understanding Links

To insert a hyperlink into a content item, you can either code the HTML yourself, or use the editor. To insert a hyperlink with the editor, which is the easiest, follow these steps:

  • Highlight the text or item you'd like to turn into a hyperlink with your mouse.

  • Click on the chain button in the editor toolbar, shown in Figure 27. Please note there must be something highlighted, for the hyperlink buttons to become clickable. In this case "OUT OF 5" is highlighted.

    The hyperlink buttons

    Figure 27. The hyperlink buttons

  • A pop-up window, shown in Figure 28, appears with some text fields and option tabs. In the Link URL field, type (or paste) the link you want to insert. If you are trying to link to an anchor, use the drop-down menu to locate it by name (naturally, it must already be created for it to appear in the dropdown menu).

    The pop-up window for inserting hyperlinks

    Figure 28. The pop-up window for inserting hyperlinks

  • Use the Target drop-down menu to specify whether you want the link to open in a new window, this window, or otherwise. It is usually a good idea if you are linking to an external site, to use the target=_blank option, so that once somebody clicks that link, and leaves your site, they can easily return.

  • It is wise to give your link a title, which will have a positive SEO impact, so be sure to include it.

  • Finally click Insert in the bottom of the pop-up window, and you should see your new link in the content box you had been working in.

Though there are many options available for setting up a link in TinyMCE, we are going to cover the basic ones to get you off the ground with Joomla. If you need a TinyMCE tutorial, we recommend going to the developers' website: http://tinymce.moxiecode.com.

Joomla URLs

Before we dive into creating internal links to other pages within our Joomla site, let's take some time to understand the URLs constructed by the CMS. There are basically two types: the default URLs and Search Engine Friendly (SEF) URLs.

Default URLs

If we take a look at one for a typical content item:

http://www.example.com/index.php?option=com_content&task=view&id=1&Itemid=29

Though at first this URL may look big, scary and indecipherable, but it's actually based on a few key principles:

  • Component Name (option=): specifies the component being requested. In our example, option=com_content tells us this URL is for the content component.

  • Task (task=): specifies the task the component is being asked to view, such as view or edit.

  • Content ID (id=): specifies the ID of the content (Article, News Feed, etc.) you are requesting.

  • Instance ID (itemid=): basically, it is a number that identifies how to get to the page (id) you are requesting. Why? Because coming in from a menu, for instance, may result in drawing the page differently than coming in from a link on a page. Passing this is optional.

Using this standard format for URLs allows us to simply substitute the Content ID (id) number at the end of the line to insert the correct link. For example, if we wanted to create a link to an article with Content ID 3, we would use this URL:

http://www.example.com/index.php?option=com_content&task=view&id=3

SEF URLs

When setting up Joomla, or after, if you modified the Global Configuration → Site → SEO Settings, then you may have realized you could change how the URLs generated by Joomla appear. We didn't go into a lot of detail on these settings before, so here's a summary:

  • Search Engine Friendly URLs: when enabled, Joomla reduces the complicated URLs into something that is more readable. For instance, the URL we used in the last example would be reduced down to the following:

    http://www.example.com/index.php/component/content/article/3
  • Use Apache mod_rewrite: if you are using Apache and you have enabled mod_rewrite for it, then you can rename the htaccess.txt file in your root Joomla directory and enable this setting. Doing so removes the index.php part of the URL. So, if this and the SEF URLs options are enabled, our URL will further be reduced to this:

    http://www.example.com/component/content/article/3
  • Add Suffix to URLs: it's unlikely that you will need this option, but if for any reason you need your pages to end with a document type extension, such as .html, then you can enable this extension and it will do so. This would give us something like the following:

    http://www.example.com/component/content/article/3.html

At this point we are sure you are going to ask how to further control the SEF URL structure. What if, for instance, you want the URL we just created to be even further reduced to something like the following:

http://www.example.com/my-cool-article.html

This book isn't specifically going to go into all the detail for SEO and SEF URLs, but there are a few things we did want to point out in case you are interested on the subject matter:

  • For menu items you have created, the Search Engine Friendly URLs setting in Joomla, when enabled, uses the value you specified in the Alias field for the menu item for the URL.

  • If you are extremely gifted at coding .htaccess files, you can further rewrite URLs that Joomla makes "friendly" to be even friendlier—but there is only so far you can go. You can't, for instance, use the .htaccess file to put the title of the article in the URL unless it is already there.

  • If you really want control over the URLs, use a Joomla Extension like sh404SEF, which allows you to control URLs.

  • When using a Joomla Extension to control URLs, they are not always compatible with other extensions. So, be sure to select wisely.

Linking to Pages

With our Joomla URL primer out of the way, let's take a look at how to link to pages stored in Joomla. Unfortunately for all the amazing things Joomla does provide, there is no easy way to create links to pages without the help of an extension. Maybe this will be a feature in upcoming versions of Joomla, but for now you insert internal links within content items (if you are using the editor), using the same pop-up window that you use for external links.

The challenge however, is figuring out the URL for the internal page to which you wish to link. There are a couple of ways of finding out.

  • You can plainly publish the page and view it from the frontend, copy the URL, and then paste it into the Link URL field. This is true whether or not you enable or use any SEO/SEF settings or extensions.

  • You can use the ID number provided on the Article Manager page, shown in Figure 29, and use it in correspondence with the default Joomla URL for accessing articles.

    Article ID circled on the far right

    Figure 29. Article ID circled on the far right

As you can see, this can be a bit problematic. But don't worry—we have a solution. If you install the JCE (Joomla Content Editor), which includes both an Administration Component and an Editor Plugin, a new WYSIWYG editor will be available to you—one that allows you to browse pages in Joomla to quickly and easily link to them.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.174.57