Using the Content Plugin in Articles and Modules


This article concentrates on using the Content plugin to show Downloads in Joomla! articles.  The Plugin may also be used in Custom Modules and in Download Descriptions.
Note: If you have allowed Registered Users to create Content then be aware that in
Joomla! Global Configuration - Filtering
that the default for Registered is 'No HTML'.
You need to set to say 'Default Blacklist'.

Select Download using Content Button

In the following the actual code needed in an article or module to referencence a Download looks like the following down05 where the value 25 is the id of the required Download.

This means finding the id value of the Download which can be tedious in the frontend.

Remembering later what is say Download 48 in content 48 can be annoying.  But note you can also write content 48A where TestUpload-en is a reminder of the name.  This works because the Content plugin ignores text following the file ID so it is not shown.

The simplest way to add a Download is to use the jDownloads Content Button Plugin.

So the first step is to go to Extensions - Plugins and make sure that both the Content Plugin itself and the Content Button plugin are both active as illustrated opposite.
 After activating the plugins then a button like plugin02 will be available on the Edit screen.  The position of the Download Button depends on which editor you are using, sometimes it is in the tool bar and others it is often at the foot of the edit page.

After clicking on the button then a popup screen like below will appear.  You can then search or scroll for the required Download.  Clicking on its name will then insert the correct Content Plugin code in the article or the Module.  You can also use the Content Plugin in the Description part of a Download.

View in Articles, Modules and Descriptions

Use <div> not <p>

If you are using a basic editor such as Code Mirror or similar then the Content Plugin code would appear as below, where in this example the 25 is the id of the Download.
Using a conventional WYSIWYG type editor such as JCE the entry in the article would look like the image below.
Again the Download and its surrounding text is again in a <div> ... </div> block.
Note that the JCE editor may be set to show the type of 'block' element.
So, as might be expected, the result appears as a single line in the Front End.


Now let us see what happens if a Paragraph block <p> ... </p> is used instead of a Div block <div>...</div>. 
The direct code as entered is shown below.
The view in the JCE editor is as shown below.

But in this case there is a line break immediately before the Download link!

Single05AThe reason is quite simple.  The basic HTML definition of a Paragraph is that it cannot hold another block element such as <div>.  This is consistent with ordinary language where a Paragraph does not contain an 'internal paragraph'.  Hence the browser automaticly generates a line break.

See the Appendix below about changing the 'mode' of typical WYSIWYG editors such as JCE and Ark from Paragraph to Div dynamically.

Use In Custom Modules

Adding a Download link to a custom module is the mostly the same as adding into an article.

That is in the Module tab your default editor will show any 'buttons' such as the plugin02 button to enable adding the relevant code as describe above.

But there is one more action required!

Select the Options tab, then ensure that the 'Prepare Content' field is set to Yes as indicated opposite.

Layout selection

The default layout for use in content is set in the jDownload Options - Plugin Tab.

A more flexible solution is to select the required layout in the content itself by using the form:
jd_file onlinelayout=='layout name'

For example, content 48B.  This must of course appear in the article before the first actual Download that is to use the layout.
Any Download layout may be used.  In these notes we use the simplest layout called 'Files link only' which comes as standard with jDownloads.

There are two other variations of this layout.  These are available either by downloading from Extra jD 3.9 Download Layouts (opens in a new window/tab) and using the Layouts button import button or by simply editing the Files link version as noted in the Edit layout Appendix below.

  1. Files link only    -----------------    Single04A This is a standard default Downloads layout which comes with jDownloads.
  2. Files link and icon --------------   Single04BNever shows the featured star.
  3. Files icon link and featured  --- Single04C   Only shows feature star if Download is featured.

Some Examples

Individual Downloads

It maybe that the Downloads are to be listed with some text as shown opposite.

Layout "Files link and icon" is used in this example.
The direct code is shown opposite.plugin04
It is also possible to show several Downloads as an unordered list.

Here the Downloads are contained in a <ul> ...</ul> rather than a <div> sequence.

It could of course be an Ordered list by using <ol> ... </ol>.e
The direct entry or code view would be:down04

From Categories

As well as inserting individual Download links there are also Content Plugin calls to list Downloads from Categories
  • Show Downloads from a single or several Categories: For example cat01 will list upto 12 Downloads from those categories with IDs 15, 3, 41 and 6.

  • Listing latest, top and last updated from any category: cat02 lists the 6 most recently updated Downloads selected from the categories with IDs 17, 3 and 15.

  • Listing latest, top and last updated from multiple categories: cat03 lists the 5 most downloaded Downloads from the categories with IDs 12,13 and 3.

This example shows a listing of all the Downloads in a specific category.

Again the layout "Files icon link and featured" is used.

The code used is simply

And now examples of Latest, Hottest and Updated.

Only the top 3 in each case are shown in this example.

Layout "Files icon link and featured" was used.

The code is as shown below.

With a little more effort the sequential listing could be arranged in columns as illustrated.
In this case the direct code would be as below.

Some Technical Details

When the Plugin code is generated from the short code { ...  } then jDownloads adds specific CSS class names to the plugin's enclosing <div> dependent upon the actual form of the plugin.

For example with a file short code such as down05 then the plugin code itself starts with

For say a Hottest short codehottest01 the plugin code starts with
This then allows each type of Content plugin to have its own styling. For instance in the three column example above each column could have had its own background colour.

Appendix 1 - Editing Layout

The standard 'Files Link Only' layout is very simple.  It is straightforward to edit the existing layout to create the other two layouts.

The first step is in the backend go to the  jDowndoads Control Panel  and select Layouts.  Next select the Downloads layouts and click on 'Files link only'.  This shows the line layout 01
Now click on the layout 02 button which will create a new layout called layout 03 .

So edit the title to become layout 04

Edit the layout code  layout by adding where indicated by the yellow background to give

layout 05
Next click on button save and you now have the additional layout. 

Whilst the details of the layout are still on screen click on layout 02
This will create a new layout called layout 06 so edit the title to become layout 07.

The next step is to add the code layout 08 to give

layout 09
where the code has been inserted as idicated by the yellow background.

Finally click on thebutton save close

Appendix 2 - Selecting <div> mode

The 'default' mode of most WYSIWYG editors such as JCE and Ark is the Paragraph mode.  It is very sraight forward to change the mode to <div>.

JCE Editor

For the JCE editor the 'editing' controls typically appear as opposite.

A simple Pull Down selection offers several 'modes'.

In this case select Div.

Obviously one can switch back and forth between the modes.

An advantage of the JCE editor is that it may be set to show the 'mode' of each block as indicated in the second picture opposite.

In most instances I use the Div mode all the time.

Ark Editor

The default setup for Ark is shown opposite.
 For Ark select Normal (DIV).  This then uses <div> ... </div> blocks.   ARK02

Colin Mercer February 2019, updated July 2020

Tags: index

Print Email