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.

Set a custom template variable

September 25, 2011 8:46pm

Subscribe [3]
  • #1 / Sep 25, 2011 8:46pm

    onblur

    16 posts

    I need to output the category for an entry a few times in an entry’s template.

    So I want to get the output from the following and assign to a variable so I can reuse within the template:

    {exp:channel:entries channel="product" limit="1" status="open"}
        {categories}{category_name}{/categories}
    {/exp:channel:entries}

    Note - the variable won’t be passed to an template to embed, but used in the template itself.

    How do it do that?

  • #2 / Sep 26, 2011 10:45am

    Mark Bowen

    12637 posts

    Hi onblur,

    There isn’t anything built-in to ExpressionEngine that allows you to re-use parts of code like that however if you take a look on devot-ee.com there are a few items that might well help you out with this :

    MX Jumper

    Stash

    NSM Transplant

    Does that help at all?

    Thanks,

    Mark

  • #3 / Sep 26, 2011 3:39pm

    onblur

    16 posts

    Thanks, Mark - that’s got me pointed in the right direction. Cheers!

  • #4 / Sep 27, 2011 2:19am

    John Henry Donovan

    12339 posts

    Glad Mark was able to help. Feel free to start a new thread if you have any more questions.

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

ExpressionEngine News!

#eecms, #events, #releases