In this case, we'll use the Newsflash module to show a random article intro text from a selected category each time the page is loaded.. This will make the module display one random art
Trang 1Getting the Most out of Your Site:
Extending Joomla!
When you've got your basic Joomla!-powered site up and running, and you've
got all of your content and functionality covered, chances are you'll want more Maybe your client has some specific requirements, or maybe you just want to
increase the wow factor of your site and add some eye candy or cool effects
Doing more things with Joomla! and make your site stand out from the rest of
them—that's where extensions come in.
The real power of Joomla! lies in its extensibility If you need any functionality
that's not built into the basic Joomla! installation (or "core"), you'll very likely
find it in the huge treasure house that's called the Joomla! extension database Extensions are little pieces of software that you can download and install to
become part of the backend, extending Joomla!'s capabilities.
In this chapter, you'll:
Use Joomla!'s core extensions
Download and install extensions
Put extensions to work to enhance the frontend of your site or your
backend workspace
Trang 2Don't let the term extension confuse you; some extensions are part of the Joomla! core They
are integrated into the basic Joomla! package Many of these provide essential functionality
so you can't even uninstall them Joomla!'s search function, it's menu system, or it's Contacts functionality are examples of these pre-installed extensions This means you already have some extensions experience As soon as you start using Joomla!, you deploy extensions
In this chapter, we'll focus on the possibilities of some core extensions that we haven't covered yet and also on using third-party extensions We'll install some must-have
extensions and find out how they work
Extensions in all shapes and sizes
Before digging into the wonderful world of extensions, it's good to know they come in different shapes and sizes Basically, there are three types of extensions:
The big ones called Components You manage them through a special Components
menu in the backend They are the most comprehensive extensions, sometimes providing lots of administration options and settings Component output is usually displayed in the main content area An example is the Contacts components
(to manage a system of contacts, contact details, and contact forms)
The medium ones called Modules Modules are "blocks" that contain special
functionality You've already seen examples at work, such as the menu module
You manage modules in Extensions | Module Manager Modules usually turn up
around the main content area: in the left-hand side and right-hand side column,
or in the header and footer These module positions ('left', 'right', and so on) are predefined by the template designer In the following screenshot, you can see the default template is packed with module positions:
Trang 3 Tiny extensions called Plugins These are usually minor enhancements, such as an
extra button in the text editor that makes it easy to insert hyperlinks
Don't worry, you don't have to memorize this extensions typology Although technically and practically there are important differences between these three extension types, the bottom line is that they all extend Joomla!'s capabilities by adding extra functionality in the backend
of your site You just choose the tool that does the job—sometimes this means you'll use a component, sometimes a module, and sometimes a plugin (and sometimes even
a combination)
In the Extensions menu you'll also find Template Manager and Language
Manager We won't cover them here as they have very specific purposes:
Templates determine the site's layout, colors, and typography See Chapter 11
on using templates
Language files allow you to set the default language for the frontend and the
backend of the site On the frontend, this will translate all preset texts (such
as Read more and Written by) to a language of your choice See Chapter 2 on
installing Joomla!
Trang 4Where do you get them from?
Apart from the few dozen extensions that are part of the default Joomla! installation, you can find thousands of additional extensions developed by third parties on the Web Most of these are listed on http://extensions.joomla.org, the Joomla! Extensions Directory (or JED, as it is fondly called by the Joomla! community):
Here you'll see that extensions offer a wealth of new possibilities, whether it's better content presentation (through menus, link lists, and galleries), user interaction (using forums and comments), or backend tools (interface enhancements)
Browse the JED categories (navigation systems, forums, and so on) every now and again and
keep an eye on the New and Noteworthy section Make sure to check out the Editor's Picks and the Most Popular extensions to find some true gems It's a good idea to read other users
comments They will often give you a good indication of whether an extension is mature enough and whether the support by the developer is up to standards
The JED lists very many extensions, but there are much more extension portal sites and developer sites Just google for "Joomla! extensions" or "Joomla! extensions must-haves" and make sure you've got enough coffee prepared to embark on a long and adventurous online treasure hunt
Trang 5What do they cost?
Many Joomla! extensions are free or available for a reasonable fee Sometimes, developers require registration before you can download the extension
Enhancing your site using core extensions
Let's explore some extensions that are part of the Joomla! core package We'll put a few modules to work
Time for action – adding a Newsflash to the home page
When your site grows, it's important to make sure the home page properly reflects all of the content categories to prevent your valuable new content from staying unnoticed Using the Front Page Manager (see Chapter 4) you can set a selection of articles to show in central area of the home page But there are more ways to attract attention to specific articles In this case, we'll use the Newsflash module to show a random article intro text from a selected category each time the page is loaded Every time the visitor returns another item will be displayed in the Newsflash module position
1. Navigate to Extensions | Module Manager It may be hard to locate the Newsflash module in this multi-page listing, but there's a quick way to find it In the Type drop-down box, select mod_newsflash Now just this module is shown:
2. Click on the Module Name (Newsflash) to edit the module properties In the Title box, replace the default title Newsflash with an appropriate title In this example, we'll enter Recent Lectures as the module title.
3. Select Enabled: Yes to get the module to display.
4. Select Position: right to display the module in the right-hand side column.
Trang 65. In the Menu Assignment section, select Select Menu Item(s) from the List and set the module to show on the Home page only.
6. In the Module Parameters section, select the Category from which Joomla! should
show one or more article intro texts
7. In the Layout drop-down box, choose Randomly choose one at a time This will
make the module display one random article from the selected category each time
the visitor revisits this page (if you were to choose Horizontal or Vertical here you
could display a number of article intro texts listed either horizontally or vertically)
8. Set Show Images to Yes; this way the images in the article's intro text will be
dis-played Images will only fit if they aren't wider than the available module position, as bigger images aren't resized automatically In this case, images are displayed if they aren't wider than the right-hand side column (which is about 230 pixels)
9. Set Title Linkable to Yes to turn the title of the article into a hyperlink.
10. Select Read more Link: Show to show a Read more link after the intro text.
11. Select Article Title: Yes to show the article title (and not just the intro text).
12. Click on Save and click on Preview.
Trang 7The Newsflash module is shown above the Poll in the right-hand side column:
What just happened?
The Newsflash module can help you attract attention to a specific set of articles; every time the page is revisited (reloaded in the visitor's browser), a new random article intro text from
the selected category is shown Don't let the name Newsflash fool you as the module is
obviously not just for news items You can use it to show items from any category The fun part is that you can surprise the visitor with different content at every revisit, without having
to actually refresh your site
Trang 8Have a go hero – change the Newsflash settings
As with almost any module, the settings and parameters greatly determine the output of the Newsflash In the following screenshot, you can see what the output can look like if you change the position and layout settings:
Trang 9Here, the Position is set to Footer and the Layout is set to Vertical In # of Articles we've entered 2 to display two article intro texts from the Lectures category in one column This
way, the Newsflash module allows you to display article intro texts from a selected category,
something you can't achieve with the Front Page settings only The Front Page Blog Layout shows articles that are set to "Show on Front Page", regardless of the category they belong to
Using the same module twice (or more)
Suppose you want to use the Newsflash a few times on the same page Is that
possible? Yes, you can have multiple instances of any module on a given page
You've already seen an example of this if you have installed Joomla! with sample data, as the sample site shows various menus together on one page (such as
Main Menu, Top Menu, and User Menu) These are all copies of a single module type: mod_mainmenu.
Being able to use many instances of the same module means you can also have one Newsflash module showing a few teasers from Category A, and another one
just below that showcasing Category B To do this, just navigate to Extensions | Module Manager, select the Newsflash module, and click on Copy in the toolbar.
In the Module Manager a copy will show up named Copy of [module name].
Edit this copy to set it to show just what you want to You'll probably want to
give it another Title and set the source to another Category.
Another option—instead of copying an existing module—is to create a new
instance of the desired module from scratch; navigate to Extensions | Module
Manager, click on New, and select the type of module you want (we'll cover an
example in the following section)
Creating a custom HTML block
Imagine you want to add a block of information on your site, for example a short
announcement in a sidebar You can't use an article for this, as this will be displayed in the main content area But there's a nifty little module available in the Joomla! core that will help you out It's called the Custom HTML module
Time for action – add a short content block
On all the pages of Ugly Paintings, the SRUP people would like to announce a forthcoming
series of articles Let's use the Custom HTML module to achieve this.
1. This module isn't in use yet, so we can't adjust an existing copy of it Let's create a
new instance of it Navigate to Extensions | Module Manager and click on New
in the toolbar
Trang 102. In the Module: [New] screen, select Custom HTML and click on Next.
3. In the Module: [Edit] screen, enter the details First set the Title to something appropriate (in this example, we've entered Hacking Ugly Paintings) Set Show Title to No.
4. Make sure Position is set to left; the module will display below the Main Menu
(which is also assigned to this module position)
5. In the Menu Assignment section, choose Select Menu Item(s) from the List and
in Menu Selection: select the Ugly Paintings link This will make the module show
up on all of the pages that this menu link leads to
6. In the Custom Output screen, enter the text and images you'd like to show in this
block You can format the text using text editor buttons In this example, we've centered the text, made it bold, and added an image