What we have learned so far controls the output of the linked articles on the article page.

But what if you are also outputting this Articles Field somewhere else in your site through Articles Anywhere, and you would like to display it with a different layout there?

In this tutorial, you will learn how to create and use an alternate Custom HTML Layout for Articles Field when displaying it with Articles Anywhere.

Introduction

As you may know, with Articles Anywhere (another Regular Labs extension), you can insert any Joomla articles data anywhere on your site.

And with the Pro version of Articles Anywhere, you can display any Joomla! Custom Field of an article using the name of that specific field. Let's say you want to show the value of the custom field "Speaker" - which has a field name speaker - of article "Conference". You can simply do:

{article Conference}
[speaker]
{/article}

When displaying a field of type Articles Field, Articles Anywhere will correctly use the Output and Layout you have defined for the field.

But what if you would like to output an Articles Field with a different/alternate layout when displaying it through Articles Anywhere?

Well, Articles Anywhere does allow you to customize the output of a custom field. So yes, this can also be done for fields of type Articles Field!

Overriding the Custom HTML

If you want to override the custom HTML field for Articles Fields, you can override the custom_html parameter to pass another Custom HTML Layout to that field. 

So if you have an Articles Field called [speaker], you can simply override the Custom HTML Layout set in the field parameters by doing:

[speaker custom_html="<a href='[url]'>[title]</a>"]

You can combine the data available for the Articles Field Custom HTML Layout with common presentational HTML. Links, images, headings, paragraphs, divisions, spans, lists, tables, and inline formatting are supported.

The HTML supplied through custom_html is sanitized after its data tags are replaced. Scripts, styles, embedded content, forms, event-handler attributes such as onclick, and unsafe URL schemes such as javascript: are removed. Use CSS classes instead of inline style attributes.

Because the custom_html attribute itself uses double quotes in these examples, use single quotes around HTML attribute values inside it. Encoding the angle brackets as &lt; and &gt; prevents the editor from changing the tag syntax; Articles Anywhere decodes them before safely rendering the HTML.

You can even add/override separators between the articles returned by Articles Field, if you desire:

[speaker separator=", " last-separator=" and " custom_html="<a href='[url]'>[title]</a>"]

For a complete overview of all the features included in Articles Field, head over to the full Documentation, and check out the Video Tutorials.