Answers.Body: <p>The typical 'Craft' way of doing this would be via a Matrix field instead of a single text block field, so that editors can sandwich the dynamic content (which would be its own block type) in between whatever other block types they select. That way is very powerful, flexible, extensible, and clean...</p>
  
  <p>However, assuming migrating your content to a Matrix setup would be too onerous or undesirable for other reasons, there's nothing to stop you creating your own basic shortcode replacement functionality via Twig's <code>replace</code> filter. For example, in your body field you might insert arbitrary markers like <code>[list-of-entries]</code>... then in the template that outputs the field, you can go to town with defining what each shortcode represents and then <code>replace</code> them like this:</p>
  
  <pre><code>{% set listOfEntries %}
      &lt;ul&gt;
          {% for item in craft.entries.section('something').all %}
              &lt;li&gt;{{ item.title }}&lt;/li&gt;
          {% endfor %}
      &lt;/ul&gt;
  {% endset %}
  
  {% set parsedBody = entry.body|replace({
      "[dynamic-address-injection]" : craft.entries.section('something').one().addressField,
      "[video]" : entry.videos.one().embedCode,
      "[list-of-entries]" : listOfEntries
  }) %}
  
  {{ parsedBody }}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-21T09:38:20.723Z
Answers.Text: that sounds good will give it a try thanks. Reason for not using Matrix -> When we build websites one of our goals is to make administering it as easy as possible. Once you add a matrix field to manage what should be one block of content, the admin interface starts to get too complex for simple web administrators. You get an entire textblock dedicated to a small sentence. It really starts to become too complex/cluttered for what really should be a simple task of inserting dynamic content in the middle of some paragraphs.
Answers.UserDisplayName: Laurence Cope
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-21T09:39:34.500Z
Answers.Text: Wordpress has shortcodes which are great for this purpose and easy to setup. It would allow us to program in PHP code without having to develop a plugin which has now become complex in Craft 3. Plugin would also be over top just to list some entry titles and links for example in the middle of content. So a simplistic way to add dynamic content, and for the customer to manage the content, is the best. So thanks a lot, if this works it should ensure the simplicity of it. I will like to try to include a template in that code though to break out the coding into an includes file.
Answers.UserDisplayName: Laurence Cope
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-20T12:31:49.713Z
Answers.LastActivityDate: 2018-12-20T12:31:49.713Z
Answers.UserDisplayName: James Smith
Answers.Body: <p>There's also the <a href="https://github.com/samhernandez/craft-shortcodes" rel="nofollow noreferrer">Shortcodes</a> plugin</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-27T23:01:18.550Z
Answers.LastActivityDate: 2018-12-27T23:01:18.550Z
Answers.UserDisplayName: andrew.welch
Body: <p>I would like to display dynamic content in the middle of a text block. For example, a list of entries pulled in from the backend, in the middle of content. </p>
  
  <p>In Wordpress we can use Shortcodes. Does Craft have something similar? </p>
  
  <p>Can I just add an include statement to include a template? (I cant get this working using normal twig include code). </p>
  
  <p>I could create a new field for someone to add in in between two other text block fields, but its quote over the top for what should be a simple include statement to include a template. </p>
  
  <p>Thanks!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-12-21T21:53:14.607Z
Comments.Text: Not sure if it's what you're looking for, but check out this [Shortcodes](https://github.com/samhernandez/craft-shortcodes) plugin.
Comments.UserDisplayName: Lindsey D
Tags: <include><editor>
Title: How to include twig in the editor? e.g. Shortcodes for dynamic content
ThreadText: # How to include twig in the editor? e.g. Shortcodes for dynamic content
  
  (Asked by: username_0 on 2018-12-20)
  
  I would like to display dynamic content in the middle of a text block. For example, a list of entries pulled in from the backend, in the middle of content.
  
  In Wordpress we can use Shortcodes. Does Craft have something similar?
  
  Can I just add an include statement to include a template? (I cant get this working using normal twig include code).
  
  I could create a new field for someone to add in in between two other text block fields, but its quote over the top for what should be a simple include statement to include a template.
  
  Thanks!
  
  **Tags:** include, editor
  
  > **Comments:**
  > **username_1**: Not sure if it's what you're looking for, but check out this [Shortcodes](https://github.com/samhernandez/craft-shortcodes) plugin.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2018-12-20. Score: 3
  
  The typical 'Craft' way of doing this would be via a Matrix field instead of a single text block field, so that editors can sandwich the dynamic content (which would be its own block type) in between whatever other block types they select. That way is very powerful, flexible, extensible, and clean...
  
  However, assuming migrating your content to a Matrix setup would be too onerous or undesirable for other reasons, there's nothing to stop you creating your own basic shortcode replacement functionality via Twig's `replace` filter. For example, in your body field you might insert arbitrary markers like `[list-of-entries]`... then in the template that outputs the field, you can go to town with defining what each shortcode represents and then `replace` them like this:
  
  ```
  {% set listOfEntries %}
      <ul>
          {% for item in craft.entries.section('something').all %}
              <li>{{ item.title }}</li>
          {% endfor %}
      </ul>
  {% endset %}
  
  {% set parsedBody = entry.body|replace({
      "[dynamic-address-injection]" : craft.entries.section('something').one().addressField,
      "[video]" : entry.videos.one().embedCode,
      "[list-of-entries]" : listOfEntries
  }) %}
  
  {{ parsedBody }}
  
  ```
  
  > **Comments:**
  > **username_0**: that sounds good will give it a try thanks. Reason for not using Matrix -> When we build websites one of our goals is to make administering it as easy as possible. Once you add a matrix field to manage what should be one block of content, the admin interface starts to get too complex for simple web administrators. You get an entire textblock dedicated to a small sentence. It really starts to become too complex/cluttered for what really should be a simple task of inserting dynamic content in the middle of some paragraphs.  
  > **username_0**: Wordpress has shortcodes which are great for this purpose and easy to setup. It would allow us to program in PHP code without having to develop a plugin which has now become complex in Craft 3. Plugin would also be over top just to list some entry titles and links for example in the middle of content. So a simplistic way to add dynamic content, and for the customer to manage the content, is the best. So thanks a lot, if this works it should ensure the simplicity of it. I will like to try to include a template in that code though to break out the coding into an includes file.  
  
  ---
  
  ### Answer by username_3 on 2018-12-27. Score: 2
  
  There's also the [Shortcodes](https://github.com/samhernandez/craft-shortcodes) plugin
  
  
  ---
  
  