ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Embed Template into weblog

July 06, 2007 9:18am

Subscribe [4]
  • #1 / Jul 06, 2007 9:18am

    kingdoz

    45 posts

    I have a weblog with one of the fields being a textarea. I need to embed a template in one of the entries of that weblog, but not for each one. I tried putting the code {embed="site/tp_news"} in the content block, but its not parsed by EE, is there a way to enable this?

  • #2 / Jul 06, 2007 9:25am

    silenz

    1651 posts

  • #3 / Jul 06, 2007 10:44am

    kingdoz

    45 posts

    thanks

  • #4 / Jul 06, 2007 10:57am

    kingdoz

    45 posts

    doesnt work if i have tinymce enabled as tinymce converts the characters to their ASCII equivalent, any way around this?

  • #5 / Jul 06, 2007 11:10am

    kingdoz

    45 posts

    in fact, i tried it in a plain old fashioned text box and the output still didnt get parsed - its definately installed (listed as installed under utilities > plugins)

    im bamboozled

  • #6 / Jul 10, 2007 6:24am

    kingdoz

    45 posts

    can anyone help?

  • #7 / Jul 10, 2007 8:46am

    Mark Bowen

    12637 posts

    Hi there,

    I don’t think (personally) that trying to embed a template in that way is the best way to go. The way I would do it is as follows :

    Say I have the template that I want to add in to certain pages and not others. We will take your example template for instance :

    {embed="site/tp_news"}

    What I would do is have a drop down field in the weblog called something like Embed TP News (embed_tp_news). I would have simply Yes or No as the entries for the drop down.

    Then when I create a new entry or edit an existing one all that is required is to select Yes if I want the template to appear and No if I don’t or even better still don’t select anything instead of No so that you don’t have to do this on all the entries rather you will just select Yes for the ones that you do want to have the template embedded in.

    Then in your template you would have code something like the following :

    {if embed_tp_news == "Yes"}
    {embed="site/tp_news"}
    {/if}

    Pretty sure that code should be correct. Basically what you are doing is checking whether Yes was selected in the drop down field and if so then the extra template will get spat out to the page. If not then it will not get added.

    This has the bonus that you can add the template very quickly to a page when creating an entry.

    That’s just the way I would do it though. There are probably a million other ways of achieving this as EE seems to have so many ways of doing things due to the excellent nature of how it has been conceived so everyone can work out their own best ways of creating things.

    Hope that helps.

    Good luck with everything.

    Best wishes,

    Mark

  • #8 / Jul 10, 2007 9:20am

    Derek Jones

    7561 posts

    Mark, that’s a much better idea than allowing those tags to be parsed in entries.  Another way would be to have a drop-down field with template names of approved templates to embed such as:

    --
    .random_news
    .random_photos
    .random_sponsor

    and then in the template:

    {if embed_template != '--'}
        {embed="embeds/{embed_template}"}
    {/if}
  • #9 / Jul 10, 2007 12:23pm

    Mark Bowen

    12637 posts

    Hi Derek,

    See that goes to show exactly what I said before!! EE is the most flexible software out there for this kind of thing and there are so many different ways of doing the same thing that it really is down to personal preference in the end. Great idea though. I have actually used that before on sites but I thought with this just being the one template that Yes / No would be easier but I suppose this is even better as you are able to add new items as and when you see fit which really makes for powerful layout options!!

    I’m sure that kingscotty will love that idea.

    Best wishes,

    Mark

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases