5

I love using the excerpt option in Wygwam (CKEditor). I've looked high and low but as of yet, have been unable to find a way to have an exceprt show short of having a whole second field. I have seen a custom Twig filter running around that would allow to show first paragraph (which I could modify to show whatever) but I like the ease of doing it straight in the WYSIWYG. Anyone have any options? (looking for a solution for a news roll page)

(First P Twig filter) https://gist.github.com/james2doyle/6629712

6

You could use the Redactor's pagebreak plugin. Check out the docs.

If activated in your Redactor config, you will have the option to insert page breaks to your content, via a new “Insert Page Break” toolbar button.

Now you can get the first "page" in your template:

{% for entry in craft.entries.section('blog') %}
    <article>
        <h1><a href="{{ entry.url }}">{{ entry.title }}</a></h1>

        {{ entry.richTextFieldHandle.getPage(1) }}

        {% if entry.richTextFieldHandle.getTotalPages() > 1 %}
            <a href="{{ entry.url }}">Continue reading…</a>
        {% endif %}
    </article>
{% endfor %}
| improve this answer | |
  • Ah, this is grand Victor, thank you. This achieves what I want on this scale, though if I were ever to have multi-page entries, it wouldn't work as well. For my current circumstances, will work great! – Ryan Shrum Jun 27 '14 at 18:38
  • 1
    If you have multiple page articles you have three possibilities: (1) Ignore the first page and start the pagebreak at the second. (2) Write a simple redactor plugin which mimics the pagebreak functionality and call it excerpt. (3) Use a separate field for an excerpt. – Victor In Jun 27 '14 at 18:46

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.