0

I’m working on a blog and would love to make the markup for a single article its own template for embedding elsewhere so I don't have to repeat that markup in multiple places, but I don't know how to do this and still parse all entry tags. The markup for a single article will appear in multiple templates (blog/index, blog/single, etc.) and is exactly the same. Currently it appears like this in my blog/index template:

{exp:channel:entries channel="blog" dynamic="no"}
    {if post_theme}
        {post_theme}<article class="theme-{theme}" style="background-color: {background_color};">{/post_theme}
    {if:else}
        <article>
    {/if}
        <div class="interior">
            <header class="article-header {header_options}col-start-{col_start} col-end-{col_end} overlay-{headline_overlay} headline-size-{headline_size}{/header_options}">
                <h5><a href="{page_url}"><time>{entry_date format='%j %F %Y'}</time></a></h5>
                {categories}
                    <h2><a href="{path='blog/index'}">{category_name}</a></h2>
                {/categories}
                <h1>{title}</h1>
            </header>
            {blog_cover_image}
                {if image}
                    <figure class="cover-image {image_width}">
                        {if '{image_width}' == 'full-width'}
                            {exp:ce_img:single src="{image}" add_dims="yes" width="750" attributes='alt="{alt_text}"'}
                        {if:elseif '{image_width}' == 'text-width'}
                            {exp:ce_img:single src="{image}" add_dims="yes" width="500" attributes='alt="{alt_text}"'}
                        {/if}
                        {if caption}
                            <figcaption>
                                {caption}
                            </figcaption>
                        {/if}
                    </figure>
                {/if}
            {/blog_cover_image}
            <aside>
                <ul class="article-tags">
                    {exp:tag:tags
                        entry_id="{entry_id}"
                        orderby="tag_name"
                        sort="asc"
                    }
                        <li><a href="{path='blog/tag'}/{websafe_tag}" title="{tag}" style="font-size:{step}px;">{tag}</a></li>
                    {/exp:tag:tags}
                </ul>
            </aside>
            <div class="article-content">
                {blog_images}
                    {exp:mx_jumper:put name="image_{row_count}"}
                        <figure class="{placement} {size}">
                            {if '{size}' == 'full-width'}
                                {exp:ce_img:single src="{image}" add_dims="yes" width="750" attributes='alt="{alt_text}"'}
                            {if:elseif '{size}' == 'text-width'}
                                {exp:ce_img:single src="{image}" add_dims="yes" width="500" attributes='alt="{alt_text}"'}
                            {if:else}
                                {exp:ce_img:single src="{image}" add_dims="yes" attributes='alt="{alt_text}"'}
                            {/if}
                            {if caption}
                                <figcaption>
                                    {caption}
                                </figcaption>
                            {/if}
                        </figure>
                    {/exp:mx_jumper:put}
                {/blog_images}
                {exp:mx_jumper:out_global}
                    {blog_post_content}
                {/exp:mx_jumper:out_global}
                {if external_links}
                    <div class="external-links">
                        {external_links}
                    </div>
                {/if}
            </div>
        </div>
        <footer class="article-footer">
            <div class="interior">
                <ul class="tools">
                    <li class="permalink"><a href="{page_url}">Permalink</a></li>
                    <li class="tweet"><a target="_blank" href="http://twitter.com/home?status={page_url}">Tweet</a></li>
                    <li class="pinterest"><a target="_blank" href="http://pinterest.com/pin/create/button/?url={page_url}">Pinterest</a></li>
                    <li class="facebook"><a target="_blank" href="http://www.facebook.com/share.php?u={page_url}">Facebook</a></li>
                </ul>
            </div>
        </footer>
    </article>
{/exp:channel:entries}

Here is what I would rather do:

{exp:channel:entries channel="blog" dynamic="no"}
    {embed="blog/.article"}
{/exp:channel:entries}

I need everything between my {exp:channel:entries} tag to be an embed, but I don't know what to pass it so that all entry tags are parsed.

Ideas?

2

Since I couldn't found nothing that looks like a snippet on your code, you can use one.

Save all the internal code of exp:channel:entries tags on a snippet called snip_article and go ahead!

If you want a way to edit snippets as plain text files, give to SnippetsSync a try.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.