Pixel & Tonic

Wygwam

version works on just rated
2.5 EE1 & EE2 $35
Buy Now Get Help

Template Tags

Wygwam comes with a few template tags to help your customize your template output.

To use them, place them within an {exp:channel:entries} tag pair that’s pulling in an entry with a Wygwam field.

Note: Replace “wygwam_field” in the following examples with the actual name of your Wygwam field.

Primary Tag

Returns the full contents of your Wygwam field.

{exp:channel:entries channel="blog"}
    <h1>{title}</h1>
    {wygwam_field}
{/exp:channel:entries}

“Read More” Tags

The following tags deal with Wygwam fields which use the new “Read More” separators.

:excerpt tag

If your field has a “Read More” separator, this returns your Wygwam field contents up until that point. Otherwise it will return the full contents of your Wygwam field.

:has_excerpt tag

For use in conditionals. Returns “y” if your Wygwam field has a “Read More” separator within it.

{wygwam_field:excerpt}

{if "{wygwam_field:has_excerpt}"}
    <a href="{path='blog/full-posts/{url_title}'}">Read more...</a>
{/if}

:extended tag

If your field has a “Read More” separator, this returns the remaining portion of your Wygwam field contents after that point. Otherwise it won’t return anything.

<h1>{title}</h1>
{wygwam_field:excerpt}

<div class="extended">
    {wygwam_field:extended}
</div>

Text-Only Mode

If you pass the parameter text_only="yes" to Wygwam’s primary, :excerpt, or :extended tags, Wygwam will remove all the HTML tags from the content, leaving only the text.

{wygwam_field text_only="yes"}

Images-Only Mode

If you pass the parameter images_only="yes" to Wygwam’s primary, :excerpt, or :extended tags, Wygwam will remove everything but the images from the content, and separate them with line breaks.

{wygwam_field images_only="yes"}

If you want to have complete control over the HTML output, use a tag pair:

<ul>
    {wygwam_field images_only="yes"}
        <li><img src="{src}" width="{width}" height="{height}" alt="{alt}" /></li>
    {/wygwam_field}
</ul>

Tag Parameters

The following parameters are available to help customize the images-only output:

images_only="yes"
Required to enable images-only mode.
delimiter=
Overrides the delimiter used to separate images when using a single tag (<br /> by default)
offset=
Skips the first X images
limit=
Limits the number of images to display

Variable Tags

The following variable tags are available within the tag pair:

{width}
The width of the image, whether it was specified in the style= or width= HTML attributes (if the former, “px” will be removed)
{height}
The height of the image, whether it was specified in the style= or height= HTML attributes (if the former, “px” will be removed)
Attribute tags ({src}, {alt}, {title}, etc.)
The value of the corresponding HTML attribute
Style tags ({style:float}, etc.)
The value of the corresponding inline CSS style