We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

[SOLVED] How can I embed a template within my posts?

How Do I?

Daem0n's avatar
Daem0n
61 posts
4 years ago
Daem0n's avatar Daem0n

Hey everyone,

I’m creating a blog using EE and I would like to know if it’s possible to embed a template within a post. I’m using a rich text editor field to add the main content for each blog post and I would like to be able to add some sort of snippet within the post that embeds a template. That template will hold things like ads or static content that I would like to be able to change in one place and update all relevant posts (hence why I thought I could do this with an embed).

To clarify, I’m already aware about embedding templates within other templates. What I’m looking to find is a way to add stuff within entries! For example, Google AdSense does that by injecting ads wherever their code things it’s valuable, but I’d like to be able to control that, on every post, depending on its word length.

Is something like this possible and if so how? Thanks in advance!

       
Andy McCormick's avatar
Andy McCormick
183 posts
4 years ago
Andy McCormick's avatar Andy McCormick

I’m honestly not 100% this works in the latest version but what you’re looking for is the Allow EEcode add-on https://github.com/EllisLab/Allow-Eecode. It’s free to use.

If there are any issues with it, let me know or open an issue directly in GitHub.

       
Daem0n's avatar
Daem0n
61 posts
4 years ago
Daem0n's avatar Daem0n

Thanks for the suggestion Andy. Unfortunately it doesn’t seem to work on EE 6.0.3. I can install the add-on but it doesn’t seem to do anything when I add the variable pair in either of my channel fields. Tested it in both a textarea field as well as an RTE one.

       
Andy McCormick's avatar
Andy McCormick
183 posts
4 years ago
Andy McCormick's avatar Andy McCormick

ok. let me try to test it out and see if it’s an easy fix. As far as I know, that’s currently the only option for achieving what you are trying to do.

       
Andy McCormick's avatar
Andy McCormick
183 posts
4 years ago
Andy McCormick's avatar Andy McCormick

Actually, I just tested and it seemed to work fine for me in 6.0.3. Are you using the embed="y" parameter in your code?

My code that is working looks like the following:

{exp:allow_eecode embed="y"}
    {blog_content} //this is a textarea field
{/exp:allow_eecode}
       
Daem0n's avatar
Daem0n
61 posts
4 years ago
Daem0n's avatar Daem0n

Thanks for testing this Andy! I was pretty sure I tried the `embed=”y” parameter and it didn’t work. Maybe I had a typo or something… 🤷‍♂️

It works perfectly now though after pasting your code. Thanks you!!!

       
Andy McCormick's avatar
Andy McCormick
183 posts
4 years ago
Andy McCormick's avatar Andy McCormick

that’s great to hear. let me know if you have any other troubles.

👍 1
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.